update transparency/font size and fix first video caling add to queue repeatedly on skip forward

This commit is contained in:
ksyasuda 2023-08-06 03:13:13 -07:00
parent a47da19922
commit b20776bce3
3 changed files with 9 additions and 14 deletions

View File

@ -45,7 +45,7 @@ This script requires the following software to be installed on the system
- `add_to_queue - ctrl+a`: Add a video in the clipboard to the queue - `add_to_queue - ctrl+a`: Add a video in the clipboard to the queue
- `download_current_video - ctrl+d`: Download the currently playing video - `download_current_video - ctrl+d`: Download the currently playing video
- `move_cursor_down - ctrl+DOWN`:N - Move the cursor down one row in the queue - `move_cursor_down - ctrl+DOWN`:N - Move the cursor down one row in the queue
- `move_cursor_u - ctrl+UP`- Move the cursor up one row in the queue - `move_cursor_up - ctrl+UP`- Move the cursor up one row in the queue
- `move_video - ctrl+m`: Mark/move the selected video in the queue - `move_video - ctrl+m`: Mark/move the selected video in the queue
- `open_channel_in_browser - ctrl+O`: Open the channel page for the currently - `open_channel_in_browser - ctrl+O`: Open the channel page for the currently
playing video in the browser playing video in the browser
@ -68,7 +68,7 @@ This script requires the following software to be installed on the system
- `downloader - curl`: The name of the program to use to download the video - `downloader - curl`: The name of the program to use to download the video
- `download_quality 720p`: The maximum download quality - `download_quality 720p`: The maximum download quality
- `font_name - JetBrains Mono`: The name of the font to use - `font_name - JetBrains Mono`: The name of the font to use
- `font_size - 14`: Size of the font - `font_size - 12`: Size of the font
- `display_limit - 6`: The maximum amount of videos to show on the OSD at once - `display_limit - 6`: The maximum amount of videos to show on the OSD at once
- `show_errors - no`: Show error messages on the OSD - `show_errors - no`: Show error messages on the OSD

View File

@ -13,7 +13,7 @@ clipboard_command=xclip -o
display_limit=6 display_limit=6
cursor_icon=➤ cursor_icon=➤
marked_icon=⇅ marked_icon=⇅
font_size=24 font_size=12
font_name=JetBrains Mono font_name=JetBrains Mono
download_quality=720p download_quality=720p
download_directory=~/videos/YouTube download_directory=~/videos/YouTube

View File

@ -47,7 +47,7 @@ local options = {
downloader = "curl", downloader = "curl",
download_quality = "720p", download_quality = "720p",
font_name = "JetBrains Mono", font_name = "JetBrains Mono",
font_size = 14, font_size = 12,
display_limit = 6, display_limit = 6,
show_errors = false show_errors = false
} }
@ -66,8 +66,8 @@ local colors = {
} }
local notransparent = "\\alpha&H00&" local notransparent = "\\alpha&H00&"
local semitransparent = "\\alpha&H4D&" local semitransparent = "\\alpha&H40&"
local transparent = "\\alpha&H73&" local sortoftransparent = "\\alpha&H59&"
local style = { local style = {
error = "{\\c&" .. colors.error .. "&" .. notransparent .. "}", error = "{\\c&" .. colors.error .. "&" .. notransparent .. "}",
@ -75,12 +75,12 @@ local style = {
hover_selected = "{\\c&" .. colors.hover_selected .. "&\\alpha&H33&}", hover_selected = "{\\c&" .. colors.hover_selected .. "&\\alpha&H33&}",
cursor = "{\\c&" .. colors.cursor .. "&" .. notransparent .. "}", cursor = "{\\c&" .. colors.cursor .. "&" .. notransparent .. "}",
marked = "{\\c&" .. colors.marked .. "&" .. notransparent .. "}", marked = "{\\c&" .. colors.marked .. "&" .. notransparent .. "}",
reset = "{\\c&" .. colors.text .. "&" .. transparent .. "}", reset = "{\\c&" .. colors.text .. "&" .. sortoftransparent .. "}",
header = "{\\fn" .. options.font_name .. "\\fs" .. options.font_size * 1.5 .. header = "{\\fn" .. options.font_name .. "\\fs" .. options.font_size * 1.5 ..
"\\u1\\b1\\c&" .. colors.header .. "&" .. notransparent .. "}", "\\u1\\b1\\c&" .. colors.header .. "&" .. notransparent .. "}",
hover = "{\\c&" .. colors.hover .. "&" .. semitransparent .. "}", hover = "{\\c&" .. colors.hover .. "&" .. semitransparent .. "}",
font = "{\\fn" .. options.font_name .. "\\fs" .. options.font_size .. "{" .. font = "{\\fn" .. options.font_name .. "\\fs" .. options.font_size .. "{" ..
transparent .. "}" sortoftransparent .. "}"
} }
local display_limit = options.display_limit local display_limit = options.display_limit
@ -409,11 +409,6 @@ function YouTubeQueue.add_to_queue(url)
return return
end end
end end
if not string.match(url, "^https://www.youtube.com") then
print_osd_message("URL is not a valid YouTube URL", MSG_DURATION,
style.error)
return
end
if YouTubeQueue.is_in_queue(url) then if YouTubeQueue.is_in_queue(url) then
print_osd_message("Video already in queue.", MSG_DURATION, style.error) print_osd_message("Video already in queue.", MSG_DURATION, style.error)
return return
@ -513,7 +508,7 @@ local function on_playback_restart()
local playlist_size = mp.get_property_number("playlist-count", 0) local playlist_size = mp.get_property_number("playlist-count", 0)
if playlist_size > 1 then if playlist_size > 1 then
YouTubeQueue.update_current_index() YouTubeQueue.update_current_index()
else elseif current_video == nil then
local url = mp.get_property("path") local url = mp.get_property("path")
YouTubeQueue.add_to_queue(url) YouTubeQueue.add_to_queue(url)
end end