__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
-- WirePlumber
--
-- Copyright © 2024 Collabora Ltd.
--
-- SPDX-License-Identifier: MIT
--
-- Select the media role target
cutils = require("common-utils")
lutils = require("linking-utils")
log = Log.open_topic("s-linking")
SimpleEventHook {
name = "linking/find-media-role-target",
after = { "linking/find-defined-target",
"linking/find-filter-target" },
before = "linking/prepare-link",
interests = {
EventInterest {
Constraint { "event.type", "=", "select-target" },
},
},
execute = function (event)
local _, om, si, si_props, _, target =
lutils:unwrap_select_target_event (event)
local target_direction = cutils.getTargetDirection (si_props)
local media_role = si_props["media.role"]
-- bypass the hook if the target is already picked up or if the role is not
-- defined
if target or media_role == nil then
return
end
log:info (si, string.format ("handling item %d: %s (%s) role (%s)", si.id,
tostring (si_props ["node.name"]), tostring (si_props ["node.id"]), media_role))
for si_target in om:iterate {
type = "SiLinkable",
Constraint { "item.node.direction", "=", target_direction },
Constraint { "device.intended-roles", "+" },
Constraint { "media.type", "=", si_props["media.type"] },
} do
local roles_json = si_target.properties["device.intended-roles"]
local roles_table = Json.Raw(roles_json):parse()
for _, target_role in ipairs(roles_table) do
if target_role == media_role then
target = si_target
break
end
end
if target then
break
end
end
-- set target
if target ~= nil then
log:info(si,
string.format("... media role target picked: %s (%s)",
tostring(target.properties["node.name"]),
tostring(target.properties["node.id"])))
event:set_data("target", target)
end
end
}:register()
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| find-best-target.lua | File | 3.97 KB | 0644 |
|
| find-default-target.lua | File | 1.65 KB | 0644 |
|
| find-defined-target.lua | File | 4.25 KB | 0644 |
|
| find-filter-target.lua | File | 2.9 KB | 0644 |
|
| find-media-role-target.lua | File | 1.92 KB | 0644 |
|
| find-user-target.lua.example | File | 925 B | 0644 |
|
| get-filter-from-target.lua | File | 3.33 KB | 0644 |
|
| link-target.lua | File | 5.23 KB | 0644 |
|
| prepare-link.lua | File | 3.79 KB | 0644 |
|
| rescan-media-role-links.lua | File | 6.46 KB | 0644 |
|
| rescan.lua | File | 8.35 KB | 0644 |
|