mirror of
https://github.com/ksyasuda/mpv-youtube-queue.git
synced 2024-11-22 03:19:54 -08:00
Compare commits
No commits in common. "84a860f596eefc699a63a692b890471063beacc9" and "fa2014acd681c35a0027e8b13ae67ba27d24aca1" have entirely different histories.
84a860f596
...
fa2014acd6
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
test.sh
|
||||
.git/*
|
@ -165,14 +165,14 @@ local function open_channel_in_browser()
|
||||
open_url_in_browser(current_video.channel_url)
|
||||
end
|
||||
|
||||
local function _print_internal_playlist()
|
||||
local count = mp.get_property_number("playlist-count")
|
||||
print("Playlist contents:")
|
||||
for i = 0, count - 1 do
|
||||
local uri = mp.get_property(string.format("playlist/%d/filename", i))
|
||||
print(string.format("%d: %s", i, uri))
|
||||
end
|
||||
end
|
||||
-- local function _print_internal_playlist()
|
||||
-- local count = mp.get_property_number("playlist-count")
|
||||
-- print("Playlist contents:")
|
||||
-- for i = 0, count - 1 do
|
||||
-- local uri = mp.get_property(string.format("playlist/%d/filename", i))
|
||||
-- print(string.format("%d: %s", i, uri))
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local function toggle_print()
|
||||
if destroyer ~= nil then
|
||||
@ -320,20 +320,19 @@ function YouTubeQueue.reorder_queue(from_index, to_index)
|
||||
-- Check if the provided indices are within the bounds of the video_queue
|
||||
if from_index > 0 and from_index <= #video_queue and to_index > 0 and
|
||||
to_index <= #video_queue then
|
||||
-- move the video from the from_index to to_index in the internal playlist.
|
||||
-- playlist-move is 0-indexed
|
||||
if from_index < to_index and to_index == #video_queue then
|
||||
mp.commandv("playlist-move", from_index - 1, to_index)
|
||||
elseif from_index < to_index then
|
||||
mp.commandv("playlist-move", to_index - 1, from_index - 1)
|
||||
else
|
||||
mp.commandv("playlist-move", from_index - 1, to_index - 1)
|
||||
end
|
||||
|
||||
-- Remove from from_index and insert at to_index into YouTubeQueue
|
||||
-- Swap the videos between the two provided indices in the video_queue
|
||||
local temp_video = video_queue[from_index]
|
||||
table.remove(video_queue, from_index)
|
||||
table.insert(video_queue, to_index, temp_video)
|
||||
|
||||
-- swap the videos in the mpv playlist
|
||||
-- playlist-move is 0-indexed and works the opposite of what is expected
|
||||
-- ex: playlist-move 1 2 will move the video at index 2 to index 1
|
||||
mp.commandv("loadfile", video_queue[to_index].video_url, "append")
|
||||
mp.commandv("playlist-move", #video_queue, to_index - 1)
|
||||
mp.commandv("playlist-move", to_index - 1, from_index - 1)
|
||||
mp.commandv("playlist-move", from_index - 1, #video_queue)
|
||||
mp.commandv("playlist-remove", #video_queue)
|
||||
else
|
||||
print_osd_message("Invalid indices for reordering. No changes made.",
|
||||
MSG_DURATION, style.error)
|
||||
@ -346,17 +345,11 @@ function YouTubeQueue.print_queue(duration)
|
||||
local ass = assdraw.ass_new()
|
||||
local current_index = index
|
||||
if #video_queue > 0 then
|
||||
local half_limit = math.floor(options.display_limit / 2)
|
||||
local start_index, end_index
|
||||
|
||||
if selected_index <= half_limit then
|
||||
start_index = 1
|
||||
else
|
||||
start_index = selected_index - half_limit
|
||||
end
|
||||
|
||||
end_index = start_index + options.display_limit - 1
|
||||
if end_index > #video_queue then end_index = #video_queue end
|
||||
local start_index = math.max(1,
|
||||
selected_index - options.display_limit / 2)
|
||||
local end_index = math.min(#video_queue,
|
||||
start_index + options.display_limit - 1)
|
||||
display_offset = start_index - 1
|
||||
|
||||
ass:append(
|
||||
style.header .. "MPV-YOUTUBE-QUEUE{\\u0\\b0}" .. style.reset ..
|
||||
@ -634,12 +627,7 @@ mp.register_event("end-file", on_end_file)
|
||||
mp.register_event("track-changed", on_track_changed)
|
||||
mp.register_event("playback-restart", on_playback_restart)
|
||||
|
||||
-- keep for backwards compatibility
|
||||
mp.register_script_message("add_to_queue", YouTubeQueue.add_to_queue)
|
||||
mp.register_script_message("print_queue", YouTubeQueue.print_queue)
|
||||
|
||||
mp.register_script_message("add_to_youtube_queue", YouTubeQueue.add_to_queue)
|
||||
mp.register_script_message("toggle_youtube_queue", toggle_print)
|
||||
mp.register_script_message("print_internal_playlist", _print_internal_playlist)
|
||||
mp.register_script_message("reorder_youtube_queue", YouTubeQueue.reorder_queue)
|
||||
-- }}}
|
||||
|
Loading…
Reference in New Issue
Block a user