mirror of
https://github.com/ksyasuda/mpv-youtube-queue.git
synced 2024-10-28 04:44:11 -07:00
Merge branch 'master' of github.com:ksyasuda/mpv-youtube-queue
This commit is contained in:
commit
1bd0aa7c58
@ -18,3 +18,4 @@ font_name=JetBrains Mono
|
|||||||
download_quality=720p
|
download_quality=720p
|
||||||
download_directory=~/videos/YouTube
|
download_directory=~/videos/YouTube
|
||||||
downloader=curl
|
downloader=curl
|
||||||
|
show_errors=no
|
||||||
|
@ -47,7 +47,8 @@ local options = {
|
|||||||
download_quality = "720p",
|
download_quality = "720p",
|
||||||
font_name = "JetBrains Mono",
|
font_name = "JetBrains Mono",
|
||||||
font_size = 14,
|
font_size = 14,
|
||||||
display_limit = 6
|
display_limit = 6,
|
||||||
|
show_errors = false
|
||||||
}
|
}
|
||||||
|
|
||||||
mp.options.read_options(options, "mpv-youtube-queue")
|
mp.options.read_options(options, "mpv-youtube-queue")
|
||||||
@ -90,6 +91,7 @@ local display_offset = 0
|
|||||||
local function sleep(n) os.execute("sleep " .. tonumber(n)) end
|
local function sleep(n) os.execute("sleep " .. tonumber(n)) end
|
||||||
|
|
||||||
local function print_osd_message(message, duration, s)
|
local function print_osd_message(message, duration, s)
|
||||||
|
if s == style.error and not options.show_errors then return end
|
||||||
if s == nil then s = style.font .. "{" .. notransparent .. "}" end
|
if s == nil then s = style.font .. "{" .. notransparent .. "}" end
|
||||||
if duration == nil then duration = MSG_DURATION end
|
if duration == nil then duration = MSG_DURATION end
|
||||||
mp.osd_message(styleOn .. s .. message .. style.reset .. styleOff .. "\n",
|
mp.osd_message(styleOn .. s .. message .. style.reset .. styleOff .. "\n",
|
||||||
@ -383,6 +385,11 @@ function YouTubeQueue.play_next_in_queue()
|
|||||||
local current_index = YouTubeQueue.get_current_index()
|
local current_index = YouTubeQueue.get_current_index()
|
||||||
if YouTubeQueue.size() > 1 then
|
if YouTubeQueue.size() > 1 then
|
||||||
mp.set_property_number("playlist-pos", current_index - 1)
|
mp.set_property_number("playlist-pos", current_index - 1)
|
||||||
|
else
|
||||||
|
local state = mp.get_property("core-idle")
|
||||||
|
if state == "yes" then
|
||||||
|
mp.commandv("loadfile", next_video.video_url, "replace")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
print_current_video()
|
print_current_video()
|
||||||
selected_index = current_index
|
selected_index = current_index
|
||||||
@ -390,8 +397,7 @@ function YouTubeQueue.play_next_in_queue()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- add the video to the queue from the clipboard
|
-- add the video to the queue from the clipboard
|
||||||
function YouTubeQueue.add_to_queue(url, check_queue)
|
function YouTubeQueue.add_to_queue(url)
|
||||||
if check_queue == nil then check_queue = true end
|
|
||||||
if url == nil or url == "" then
|
if url == nil or url == "" then
|
||||||
url = YouTubeQueue.get_clipboard_content()
|
url = YouTubeQueue.get_clipboard_content()
|
||||||
if url == nil or url == "" then
|
if url == nil or url == "" then
|
||||||
@ -400,20 +406,17 @@ function YouTubeQueue.add_to_queue(url, check_queue)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if check_queue then
|
|
||||||
if YouTubeQueue.is_in_queue(url) then
|
if YouTubeQueue.is_in_queue(url) then
|
||||||
print_osd_message("Video already in queue.", MSG_DURATION,
|
print_osd_message("Video already in queue.", MSG_DURATION, style.error)
|
||||||
style.error)
|
|
||||||
return
|
return
|
||||||
-- elseif not is_valid_ytdlp_url(url) then
|
-- elseif not is_valid_ytdlp_url(url) then
|
||||||
-- mp.osd_message("Invalid URL.")
|
-- mp.osd_message("Invalid URL.")
|
||||||
-- return
|
-- return
|
||||||
end
|
end
|
||||||
end
|
|
||||||
local channel_url, channel_name, video_name = get_video_info(url)
|
local channel_url, channel_name, video_name = get_video_info(url)
|
||||||
if (channel_url == nil or channel_name == nil or video_name == nil) or
|
if (channel_url == nil or channel_name == nil or video_name == nil) or
|
||||||
(channel_url == "" or channel_name == "" or video_name == "") then
|
(channel_url == "" or channel_name == "" or video_name == "") then
|
||||||
-- print_osd_message("Error getting video info.", MSG_DURATION, style.error)
|
print_osd_message("Error getting video info.", MSG_DURATION, style.error)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -507,7 +510,7 @@ local function on_playback_restart()
|
|||||||
YouTubeQueue.update_current_index()
|
YouTubeQueue.update_current_index()
|
||||||
else
|
else
|
||||||
local url = mp.get_property("path")
|
local url = mp.get_property("path")
|
||||||
YouTubeQueue.add_to_queue(url, false)
|
YouTubeQueue.add_to_queue(url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user