mirror of
https://github.com/ksyasuda/mpv-youtube-queue.git
synced 2024-10-28 04:44:11 -07:00
Compare commits
No commits in common. "6abfe30d441e68b624f7394fc7f66ed8612b87f2" and "3bbbcae0b8a467b0b47e51ab22af2c0000e079c9" have entirely different histories.
6abfe30d44
...
3bbbcae0b8
10
README.md
10
README.md
@ -54,10 +54,8 @@ This script requires the following software to be installed on the system
|
||||
- `print_current_video - ctrl+P`: Print the name and channel of the currently
|
||||
playing video to the OSD
|
||||
- `print_queue - ctrl+q`: Print the contents of the queue to the OSD
|
||||
- `save_queue - ctrl+s`: Saves the queue using the chosen method in
|
||||
`default_save_method`
|
||||
- `save_queue_alt - ctrl+S`: Saves the queue using the method not chosen in
|
||||
`default_save_method`
|
||||
- `save_queue - ctrl+s`: Saves the remainder of the queue (excluding the
|
||||
currently playing video) to the database for retrevial at a later time
|
||||
- `remove_from_queue - ctrl+x`: Remove the currently selected video from the
|
||||
queue
|
||||
- `play_selected_video - ctrl+ENTER`: Play the currently selected video in
|
||||
@ -65,10 +63,6 @@ This script requires the following software to be installed on the system
|
||||
|
||||
### Default Options
|
||||
|
||||
- `default_save_method - unwatched`: The default method to use when saving the
|
||||
queue. Valid options are `unwatched` or `all`. Defaults to `unwatched`
|
||||
- Whichever option is chosen is the default method for the `save_queue`
|
||||
binding, and the other method will be bound to `save_queue_alt`
|
||||
- `browser - firefox`: The browser to use when opening a video or channel page
|
||||
- `clipboard_command - xclip -o`: The command to use to get the contents of the clipboard
|
||||
- `cursor_icon - ➤`: The icon to use for the cursor
|
||||
|
@ -1,5 +1,4 @@
|
||||
add_to_queue=ctrl+a
|
||||
default_save_method=unwatched
|
||||
download_current_video=ctrl+d
|
||||
download_selected_video=ctrl+D
|
||||
move_cursor_down=ctrl+j
|
||||
@ -13,7 +12,6 @@ play_previous_in_queue=ctrl+p
|
||||
print_current_video=ctrl+P
|
||||
print_queue=ctrl+q
|
||||
save_queue=ctrl+s
|
||||
save_full_queue=ctrl+S
|
||||
remove_from_queue=ctrl+x
|
||||
play_selected_video=ctrl+ENTER
|
||||
browser=firefox
|
||||
|
@ -64,8 +64,6 @@ local options = {
|
||||
backend_host = "http://localhost",
|
||||
backend_port = "42069",
|
||||
save_queue = "ctrl+s",
|
||||
save_queue_alt = "ctrl+S",
|
||||
default_save_method = "unwatched",
|
||||
load_queue = "ctrl+l"
|
||||
}
|
||||
mp.options.read_options(options, "mpv-youtube-queue")
|
||||
@ -242,7 +240,7 @@ end
|
||||
|
||||
-- Returns a list of URLs in the queue from index + 1 to the end
|
||||
function YouTubeQueue._get_urls(start_index)
|
||||
if start_index < 0 or start_index > #video_queue then return nil end
|
||||
if start_index < 0 or start_index + 1 >= #video_queue then return nil end
|
||||
local urls = {}
|
||||
for i = start_index + 1, #video_queue do
|
||||
table.insert(urls, video_queue[i].video_url)
|
||||
@ -265,14 +263,13 @@ end
|
||||
|
||||
-- Saves the remainder of the videos in the queue (all videos after the currently playing
|
||||
-- video) to the history database
|
||||
function YouTubeQueue.save_queue(idx)
|
||||
function YouTubeQueue.save_queue()
|
||||
if not options.use_history_db then return false end
|
||||
if idx == nil then idx = index end
|
||||
local url = options.backend_host .. ":" .. options.backend_port ..
|
||||
"/save_queue"
|
||||
local data = YouTubeQueue._convert_to_json("urls",
|
||||
YouTubeQueue._get_urls(idx))
|
||||
if data == nil or data == '{"urls": []}' then
|
||||
YouTubeQueue._get_urls(index))
|
||||
if data == nil then
|
||||
print_osd_message("Failed to save queue: No videos remaining in queue",
|
||||
MSG_DURATION, style.error)
|
||||
return false
|
||||
@ -291,21 +288,12 @@ function YouTubeQueue.save_queue(idx)
|
||||
playback_only = false,
|
||||
capture_stdout = true,
|
||||
args = command
|
||||
}, function(success, result, err)
|
||||
}, function(success, _, err)
|
||||
if not success then
|
||||
print_osd_message("Failed to save queue: " .. err, MSG_DURATION,
|
||||
style.error)
|
||||
return false
|
||||
end
|
||||
if debug then print("Status: " .. result.status) end
|
||||
if result.status == 0 then
|
||||
if idx > 1 then
|
||||
print_osd_message("Queue saved to history from index: " .. idx,
|
||||
MSG_DURATION)
|
||||
else
|
||||
print_osd_message("Queue saved to history.", MSG_DURATION)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@ -340,7 +328,6 @@ function YouTubeQueue.load_queue()
|
||||
for _, turl in ipairs(urls) do
|
||||
YouTubeQueue.add_to_queue(turl)
|
||||
end
|
||||
print_osd_message("Loaded queue from history.", MSG_DURATION)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@ -820,20 +807,7 @@ mp.add_key_binding(options.move_video, "move_video",
|
||||
YouTubeQueue.mark_and_move_video)
|
||||
mp.add_key_binding(options.remove_from_queue, "delete_video",
|
||||
YouTubeQueue.remove_from_queue)
|
||||
mp.add_key_binding(options.save_queue, "save_queue", function()
|
||||
if options.default_save_method == "unwatched" then
|
||||
YouTubeQueue.save_queue(index)
|
||||
else
|
||||
YouTubeQueue.save_queue(1)
|
||||
end
|
||||
end)
|
||||
mp.add_key_binding(options.save_queue_alt, "save_queue_alt", function()
|
||||
if options.default_save_method == "unwatched" then
|
||||
YouTubeQueue.save_queue(1)
|
||||
else
|
||||
YouTubeQueue.save_queue(index)
|
||||
end
|
||||
end)
|
||||
mp.add_key_binding(options.save_queue, "save_queue", YouTubeQueue.save_queue)
|
||||
mp.add_key_binding(options.load_queue, "load_queue", YouTubeQueue.load_queue)
|
||||
|
||||
mp.register_event("end-file", on_end_file)
|
||||
|
Loading…
Reference in New Issue
Block a user