Compare commits

...

6 Commits

Author SHA1 Message Date
ksyasuda
a47da19922 update readme 2023-08-06 02:23:12 -07:00
ksyasuda
30ca33ed2d add download_format_str option 2023-08-06 02:23:09 -07:00
ksyasuda
4e4489cf36 add download_format_str option and update icons
- change icons to unicode glyphs
- remove trailing slash from download directory if it exists
- allow configuring file output format during download
2023-08-06 02:22:44 -07:00
ksyasuda
02ad7d708e update icons 2023-08-06 02:16:08 -07:00
ksyasuda
1706bc75ec update default configuration 2023-08-06 01:15:29 -07:00
ksyasuda
abd33346a1 change option names 2023-08-06 01:15:13 -07:00
3 changed files with 60 additions and 20 deletions

View File

@ -11,6 +11,7 @@ navigate through the queue, and select a video to play.
- Fetch and display the video and channel names of the videos in the queue
- Select a video to play from the queue with an interactive menu,
or navigate through the queue with keyboard shortcuts
- Edit the order of videos in the queue
- Open the URL of the currently playing video in a new browser tab
- Open the channel page of the currently playing video
- Download the currently playing video
@ -33,8 +34,43 @@ This script requires the following software to be installed on the system
## Installation
- Copy the `mpv-youtube-queue.lua` script to your `~~/scripts` directory
(`~/.config/mpv` on Linux)
- Optionally copy the `mpv-youtube-queue.conf` to the `~~/script-opts` directory
to customize the script configuration
to customize the script configuration as described in the next section
## Configuration
### Default Keybindings
- `add_to_queue - ctrl+a`: Add a video in the clipboard to the queue
- `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_u - ctrl+UP`- Move the cursor up one row 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
playing video in the browser
- `open_video_in_browser - ctrl+o`: Open the currently playing video in the browser
- `play_next_in_queue - ctrl+n`: Play the next video in the queue
- `play_previous_in_queue - ctrl+p`: Play the previous video in the queue
- `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
### Default Option
- `clipboard_command - xclip -o`: The command to use to get the contents of the clipboard
- `browser - firefox`: The browser to use when opening a video or channel page
- `cursor_icon - ➤`: The icon to use for the cursor
- `marked_icon - ⇅`: The icon to use to mark a video as ready to be moved in
the queue
- `download_directory ~/videos/YouTube`: The directory to use when downloading
a video
- `downloader - curl`: The name of the program to use to download the video
- `download_quality 720p`: The maximum download quality
- `font_name - JetBrains Mono`: The name of the font to use
- `font_size - 14`: Size of the font
- `display_limit - 6`: The maximum amount of videos to show on the OSD at once
- `show_errors - no`: Show error messages on the OSD
## License

View File

@ -2,8 +2,8 @@ add_to_queue=ctrl+a
play_next_in_queue=ctrl+n
play_previous_in_queue=ctrl+p
print_queue=ctrl+q
move_selection_up=ctrl+UP
move_selection_down=ctrl+DOWN
move_cursor_up=ctrl+UP
move_cursor_down=ctrl+DOWN
play_selected_video=ctrl+ENTER
open_video_in_browser=ctrl+o
open_channel_in_browser=ctrl+O
@ -11,11 +11,12 @@ print_current_video=ctrl+P
browser=firefox
clipboard_command=xclip -o
display_limit=6
cursor_icon=🠺
marked_icon=󰆾
cursor_icon=
marked_icon=
font_size=24
font_name=JetBrains Mono
download_quality=720p
download_directory=~/videos/YouTube
download_format_str=%(uploader)s/%(title)s.%(ext)s
downloader=curl
show_errors=no

View File

@ -28,8 +28,8 @@ local styleOff = mp.get_property("osd-ass-cc/1")
local options = {
add_to_queue = "ctrl+a",
download_current_video = "ctrl+d",
move_selection_down = "ctrl+DOWN",
move_selection_up = "ctrl+UP",
move_cursor_down = "ctrl+DOWN",
move_cursor_up = "ctrl+UP",
move_video = "ctrl+m",
open_channel_in_browser = "ctrl+O",
open_video_in_browser = "ctrl+o",
@ -40,9 +40,10 @@ local options = {
print_queue = "ctrl+q",
clipboard_command = "xclip -o",
browser = "firefox",
cursor_icon = "🠺",
marked_icon = "󰆾",
cursor_icon = "",
marked_icon = "",
download_directory = "~/videos/YouTube",
download_format_str = "%(uploader)s/%(title)s.%(ext)s",
downloader = "curl",
download_quality = "720p",
font_name = "JetBrains Mono",
@ -105,6 +106,8 @@ local function print_current_video()
end
local function expanduser(path)
-- remove trailing slash if it exists
if string.sub(path, -1) == "/" then path = string.sub(path, 1, -2) end
if path:sub(1, 1) == "~" then
local home = os.getenv("HOME")
if home then
@ -334,7 +337,7 @@ function YouTubeQueue.print_queue(duration)
end
end
function YouTubeQueue.move_selection_up()
function YouTubeQueue.move_cursor_up()
if selected_index > 1 then
selected_index = selected_index - 1
if selected_index < display_offset + 1 then
@ -344,7 +347,7 @@ function YouTubeQueue.move_selection_up()
end
end
function YouTubeQueue.move_selection_down()
function YouTubeQueue.move_cursor_down()
if selected_index < YouTubeQueue.size() then
selected_index = selected_index + 1
if selected_index > display_offset + display_limit then
@ -457,12 +460,12 @@ function YouTubeQueue.download_current_video()
local o = options
local v = current_video
local q = o.download_quality:sub(1, -2)
local dl_dir = expanduser(o.download_directory)
local command = 'yt-dlp -f \'bestvideo[height<=' .. q ..
']+bestaudio/best[height<=' .. q .. ']\' -o "' ..
expanduser(o.download_directory) .. '/' ..
v.channel_name .. '/' .. v.video_name ..
'.%(ext)s" ' .. '--downloader ' .. o.downloader ..
' ' .. v.video_url
dl_dir .. "/" .. options.download_format_str ..
'" --downloader ' .. o.downloader .. ' ' ..
v.video_url
-- Run the download command
local handle = io.popen(command)
@ -526,10 +529,10 @@ mp.add_key_binding(options.play_next_in_queue, "play_next_in_queue",
mp.add_key_binding(options.play_previous_in_queue, "play_previous_video",
YouTubeQueue.play_previous_video)
mp.add_key_binding(options.print_queue, "print_queue", YouTubeQueue.print_queue)
mp.add_key_binding(options.move_selection_up, "move_selection_up",
YouTubeQueue.move_selection_up)
mp.add_key_binding(options.move_selection_down, "move_selection_down",
YouTubeQueue.move_selection_down)
mp.add_key_binding(options.move_cursor_up, "move_cursor_up",
YouTubeQueue.move_cursor_up)
mp.add_key_binding(options.move_cursor_down, "move_cursor_down",
YouTubeQueue.move_cursor_down)
mp.add_key_binding(options.play_selected_video, "play_selected_video",
YouTubeQueue.play_selected_video)
mp.add_key_binding(options.open_video_in_browser, "open_video_in_browser",
@ -540,7 +543,7 @@ mp.add_key_binding(options.open_channel_in_browser, "open_channel_in_browser",
open_channel_in_browser)
mp.add_key_binding(options.download_current_video, "download_current_video",
YouTubeQueue.download_current_video)
mp.add_key_binding(options.move_video, "move_selection",
mp.add_key_binding(options.move_video, "move_video",
YouTubeQueue.mark_and_move_video)
mp.register_event("end-file", on_end_file)