mirror of
https://github.com/ksyasuda/mpv-youtube-queue.git
synced 2024-11-22 03:19:54 -08:00
Compare commits
6 Commits
bfb7988c70
...
a47da19922
Author | SHA1 | Date | |
---|---|---|---|
|
a47da19922 | ||
|
30ca33ed2d | ||
|
4e4489cf36 | ||
|
02ad7d708e | ||
|
1706bc75ec | ||
|
abd33346a1 |
38
README.md
38
README.md
@ -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
|
- 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,
|
- Select a video to play from the queue with an interactive menu,
|
||||||
or navigate through the queue with keyboard shortcuts
|
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 URL of the currently playing video in a new browser tab
|
||||||
- Open the channel page of the currently playing video
|
- Open the channel page of the currently playing video
|
||||||
- Download 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
|
## Installation
|
||||||
|
|
||||||
- Copy the `mpv-youtube-queue.lua` script to your `~~/scripts` directory
|
- 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
|
- 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
|
## License
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ add_to_queue=ctrl+a
|
|||||||
play_next_in_queue=ctrl+n
|
play_next_in_queue=ctrl+n
|
||||||
play_previous_in_queue=ctrl+p
|
play_previous_in_queue=ctrl+p
|
||||||
print_queue=ctrl+q
|
print_queue=ctrl+q
|
||||||
move_selection_up=ctrl+UP
|
move_cursor_up=ctrl+UP
|
||||||
move_selection_down=ctrl+DOWN
|
move_cursor_down=ctrl+DOWN
|
||||||
play_selected_video=ctrl+ENTER
|
play_selected_video=ctrl+ENTER
|
||||||
open_video_in_browser=ctrl+o
|
open_video_in_browser=ctrl+o
|
||||||
open_channel_in_browser=ctrl+O
|
open_channel_in_browser=ctrl+O
|
||||||
@ -11,11 +11,12 @@ print_current_video=ctrl+P
|
|||||||
browser=firefox
|
browser=firefox
|
||||||
clipboard_command=xclip -o
|
clipboard_command=xclip -o
|
||||||
display_limit=6
|
display_limit=6
|
||||||
cursor_icon=🠺
|
cursor_icon=➤
|
||||||
marked_icon=
|
marked_icon=⇅
|
||||||
font_size=24
|
font_size=24
|
||||||
font_name=JetBrains Mono
|
font_name=JetBrains Mono
|
||||||
download_quality=720p
|
download_quality=720p
|
||||||
download_directory=~/videos/YouTube
|
download_directory=~/videos/YouTube
|
||||||
|
download_format_str=%(uploader)s/%(title)s.%(ext)s
|
||||||
downloader=curl
|
downloader=curl
|
||||||
show_errors=no
|
show_errors=no
|
||||||
|
@ -28,8 +28,8 @@ local styleOff = mp.get_property("osd-ass-cc/1")
|
|||||||
local options = {
|
local options = {
|
||||||
add_to_queue = "ctrl+a",
|
add_to_queue = "ctrl+a",
|
||||||
download_current_video = "ctrl+d",
|
download_current_video = "ctrl+d",
|
||||||
move_selection_down = "ctrl+DOWN",
|
move_cursor_down = "ctrl+DOWN",
|
||||||
move_selection_up = "ctrl+UP",
|
move_cursor_up = "ctrl+UP",
|
||||||
move_video = "ctrl+m",
|
move_video = "ctrl+m",
|
||||||
open_channel_in_browser = "ctrl+O",
|
open_channel_in_browser = "ctrl+O",
|
||||||
open_video_in_browser = "ctrl+o",
|
open_video_in_browser = "ctrl+o",
|
||||||
@ -40,9 +40,10 @@ local options = {
|
|||||||
print_queue = "ctrl+q",
|
print_queue = "ctrl+q",
|
||||||
clipboard_command = "xclip -o",
|
clipboard_command = "xclip -o",
|
||||||
browser = "firefox",
|
browser = "firefox",
|
||||||
cursor_icon = "🠺",
|
cursor_icon = "➤",
|
||||||
marked_icon = "",
|
marked_icon = "⇅",
|
||||||
download_directory = "~/videos/YouTube",
|
download_directory = "~/videos/YouTube",
|
||||||
|
download_format_str = "%(uploader)s/%(title)s.%(ext)s",
|
||||||
downloader = "curl",
|
downloader = "curl",
|
||||||
download_quality = "720p",
|
download_quality = "720p",
|
||||||
font_name = "JetBrains Mono",
|
font_name = "JetBrains Mono",
|
||||||
@ -105,6 +106,8 @@ local function print_current_video()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function expanduser(path)
|
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
|
if path:sub(1, 1) == "~" then
|
||||||
local home = os.getenv("HOME")
|
local home = os.getenv("HOME")
|
||||||
if home then
|
if home then
|
||||||
@ -334,7 +337,7 @@ function YouTubeQueue.print_queue(duration)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function YouTubeQueue.move_selection_up()
|
function YouTubeQueue.move_cursor_up()
|
||||||
if selected_index > 1 then
|
if selected_index > 1 then
|
||||||
selected_index = selected_index - 1
|
selected_index = selected_index - 1
|
||||||
if selected_index < display_offset + 1 then
|
if selected_index < display_offset + 1 then
|
||||||
@ -344,7 +347,7 @@ function YouTubeQueue.move_selection_up()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function YouTubeQueue.move_selection_down()
|
function YouTubeQueue.move_cursor_down()
|
||||||
if selected_index < YouTubeQueue.size() then
|
if selected_index < YouTubeQueue.size() then
|
||||||
selected_index = selected_index + 1
|
selected_index = selected_index + 1
|
||||||
if selected_index > display_offset + display_limit then
|
if selected_index > display_offset + display_limit then
|
||||||
@ -457,12 +460,12 @@ function YouTubeQueue.download_current_video()
|
|||||||
local o = options
|
local o = options
|
||||||
local v = current_video
|
local v = current_video
|
||||||
local q = o.download_quality:sub(1, -2)
|
local q = o.download_quality:sub(1, -2)
|
||||||
|
local dl_dir = expanduser(o.download_directory)
|
||||||
local command = 'yt-dlp -f \'bestvideo[height<=' .. q ..
|
local command = 'yt-dlp -f \'bestvideo[height<=' .. q ..
|
||||||
']+bestaudio/best[height<=' .. q .. ']\' -o "' ..
|
']+bestaudio/best[height<=' .. q .. ']\' -o "' ..
|
||||||
expanduser(o.download_directory) .. '/' ..
|
dl_dir .. "/" .. options.download_format_str ..
|
||||||
v.channel_name .. '/' .. v.video_name ..
|
'" --downloader ' .. o.downloader .. ' ' ..
|
||||||
'.%(ext)s" ' .. '--downloader ' .. o.downloader ..
|
v.video_url
|
||||||
' ' .. v.video_url
|
|
||||||
|
|
||||||
-- Run the download command
|
-- Run the download command
|
||||||
local handle = io.popen(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",
|
mp.add_key_binding(options.play_previous_in_queue, "play_previous_video",
|
||||||
YouTubeQueue.play_previous_video)
|
YouTubeQueue.play_previous_video)
|
||||||
mp.add_key_binding(options.print_queue, "print_queue", YouTubeQueue.print_queue)
|
mp.add_key_binding(options.print_queue, "print_queue", YouTubeQueue.print_queue)
|
||||||
mp.add_key_binding(options.move_selection_up, "move_selection_up",
|
mp.add_key_binding(options.move_cursor_up, "move_cursor_up",
|
||||||
YouTubeQueue.move_selection_up)
|
YouTubeQueue.move_cursor_up)
|
||||||
mp.add_key_binding(options.move_selection_down, "move_selection_down",
|
mp.add_key_binding(options.move_cursor_down, "move_cursor_down",
|
||||||
YouTubeQueue.move_selection_down)
|
YouTubeQueue.move_cursor_down)
|
||||||
mp.add_key_binding(options.play_selected_video, "play_selected_video",
|
mp.add_key_binding(options.play_selected_video, "play_selected_video",
|
||||||
YouTubeQueue.play_selected_video)
|
YouTubeQueue.play_selected_video)
|
||||||
mp.add_key_binding(options.open_video_in_browser, "open_video_in_browser",
|
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)
|
open_channel_in_browser)
|
||||||
mp.add_key_binding(options.download_current_video, "download_current_video",
|
mp.add_key_binding(options.download_current_video, "download_current_video",
|
||||||
YouTubeQueue.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)
|
YouTubeQueue.mark_and_move_video)
|
||||||
|
|
||||||
mp.register_event("end-file", on_end_file)
|
mp.register_event("end-file", on_end_file)
|
||||||
|
Loading…
Reference in New Issue
Block a user