mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-24 04:46:07 -08:00
feat(jellyfin): queue series neighbor episodes in the mpv playlist (#338)
This commit is contained in:
1 parent
713cdb3ef8
commit
926e6b047e
45 files changed
+2295
-197
No files matched your search
@@ -210,8 +210,17 @@ function M.create(ctx)
|
||||
})
|
||||
end
|
||||
|
||||
local function is_app_managed_playlist_entry()
|
||||
local path = mp.get_property("path")
|
||||
local managed_paths = state.app_managed_playlist_paths or {}
|
||||
return type(path) == "string" and managed_paths[path] == true
|
||||
end
|
||||
|
||||
local function on_start_file()
|
||||
if should_show_overlay_loading_osd() then
|
||||
if is_app_managed_playlist_entry() then
|
||||
state.skip_managed_subtitle_rearm_once = true
|
||||
state.app_managed_playback_pending = true
|
||||
elseif should_show_overlay_loading_osd() then
|
||||
process.start_overlay_loading_osd()
|
||||
end
|
||||
if state.pending_reload_media_identity ~= nil then
|
||||
@@ -322,12 +331,27 @@ function M.create(ctx)
|
||||
state.pending_reload_reason = nil
|
||||
state.app_managed_playback_pending = false
|
||||
state.app_managed_playback_active = false
|
||||
state.app_managed_playlist_paths = {}
|
||||
state.app_playlist_entry_options = {}
|
||||
end
|
||||
|
||||
-- Applies the app's per-file options to an entry it loaded with loadlist, the way loadfile
|
||||
-- options would apply.
|
||||
local function apply_app_playlist_entry_options()
|
||||
local path = mp.get_property("path")
|
||||
local options = type(path) == "string" and state.app_playlist_entry_options[path] or nil
|
||||
for _, option in ipairs(options or {}) do
|
||||
mp.set_property("file-local-options/" .. option[1], option[2])
|
||||
end
|
||||
end
|
||||
|
||||
local function register_lifecycle_hooks()
|
||||
mp.register_event("start-file", on_start_file)
|
||||
mp.register_event("file-loaded", on_file_loaded)
|
||||
mp.register_event("shutdown", on_shutdown)
|
||||
mp.add_hook("on_load", 50, apply_app_playlist_entry_options)
|
||||
-- Tells the app it can rely on the hook above (read as PLUGIN_ENTRY_OPTIONS_USER_DATA).
|
||||
mp.set_property_native("user-data/subminer/playlist-entry-options", true)
|
||||
mp.register_event("end-file", function(event)
|
||||
process.stop_overlay_loading_osd()
|
||||
process.disarm_auto_play_ready_gate()
|
||||
|
||||
@@ -27,6 +27,34 @@ function M.create(ctx)
|
||||
state.skip_managed_subtitle_rearm_once = true
|
||||
state.app_managed_playback_pending = true
|
||||
end)
|
||||
-- Playlist entries the app queued (Jellyfin neighbor episodes). mpv starts them on its own,
|
||||
-- so start-file recognizes them by path instead of waiting for subminer-managed-subtitles-loading.
|
||||
mp.register_script_message("subminer-managed-playlist-entries", function(...)
|
||||
local paths = {}
|
||||
for _, path in ipairs({ ... }) do
|
||||
paths[path] = true
|
||||
end
|
||||
state.app_managed_playlist_paths = paths
|
||||
-- Options belong to queued entries; drop those the app no longer queues.
|
||||
for path in pairs(state.app_playlist_entry_options) do
|
||||
if not paths[path] then
|
||||
state.app_playlist_entry_options[path] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
-- `<path> <name> <value> ...`: options for an entry the app loads with loadlist, where mpv
|
||||
-- (before 0.42) cannot take both a playlist title and per-file options.
|
||||
mp.register_script_message("subminer-playlist-entry-options", function(path, ...)
|
||||
if type(path) ~= "string" or path == "" then
|
||||
return
|
||||
end
|
||||
local args = { ... }
|
||||
local options = {}
|
||||
for index = 1, #args - 1, 2 do
|
||||
options[#options + 1] = { args[index], args[index + 1] }
|
||||
end
|
||||
state.app_playlist_entry_options[path] = options
|
||||
end)
|
||||
mp.register_script_message("subminer-menu", function()
|
||||
ui.show_menu()
|
||||
end)
|
||||
|
||||
@@ -34,6 +34,9 @@ function M.new()
|
||||
pending_reload_reason = nil,
|
||||
app_managed_playback_pending = false,
|
||||
app_managed_playback_active = false,
|
||||
app_managed_playlist_paths = {},
|
||||
-- path -> { { name, value }, ... }: per-file options the on_load hook applies (mpv < 0.42).
|
||||
app_playlist_entry_options = {},
|
||||
auto_start_retry_generation = 0,
|
||||
session_binding_generation = 0,
|
||||
session_binding_names = {},
|
||||
|
||||
Reference in new issue
Block a user