Compare commits

26 Commits

Author SHA1 Message Date
757804b192 disable debug
Some checks failed
Luacheck / luacheck (push) Failing after 2m10s
2025-02-15 01:36:30 -08:00
33f10c84b9 clean up code 2025-02-15 01:15:55 -08:00
412634c943 update config file and readme 2025-02-14 20:21:19 -08:00
3f7a5fb183 add additional fields for history database
Some checks failed
Luacheck / luacheck (push) Failing after 2m27s
2025-02-13 18:53:00 -08:00
68875120c5 add documentation and update get_video_info
- change to json dump and use mpv native json reader
2025-02-13 01:50:48 -08:00
725ef8db36 fix: save_queue_alt function
All checks were successful
Luacheck / luacheck (push) Successful in 5s
2024-09-15 01:33:37 -07:00
f89f852201 minor update
All checks were successful
Luacheck / luacheck (push) Successful in 4s
- add message on screen when waiting for video info
- remove osd messages when printing queue
2024-09-10 01:46:55 -07:00
6abfe30d44 update readme
All checks were successful
Luacheck / luacheck (push) Successful in 5s
2024-09-09 23:40:15 -07:00
4fda62f588 update save_queue function and add alt command (#21)
- add option to save full or unwatched videos only
- fix when only 1 valid video
- fix error handling
- show messages on save/load
2024-09-09 23:38:43 -07:00
Kyle Yasuda
3bbbcae0b8 Feature: Add Support for mpv-youtube-queue-server (#20)
All checks were successful
Luacheck / luacheck (push) Successful in 3s
* Add history db

- Sends video data to backend server on configured port and inserts into
a mysql database

* add option to disable history db function

* Squash bugs

- update strip command to remove newline characters
- add history db function call to playback restart listener to catch
first video

* squash more bugs

- add debug
- fix history db for repeated calls and first play
- fix is file
- change print current video to use full file path if showing a file
- remove unused functions
- fix video title when selecting video from list

* disable history db by default

- change default config
- add back line to prevent from running when disabled

* appease the linter

* update readme

* add load-file even listener for adding to history db

* add save/load queue functions

* fix load_queue command

- fix parsing/conversion to table from json list

* update readme

* add new keybinding options

* add keybinding options

* disable debug and clean up code

- disable debug mode
- sanitize clipboard content
- clean up error handling
2024-09-09 00:15:41 -07:00
ksyasuda
0739b93e3a remove print statements in non logging functions
Some checks failed
Luacheck / luacheck (push) Has been cancelled
2024-08-28 18:40:12 -07:00
Kyle Yasuda
870f7473cf Fix reorder queue (#19)
Some checks are pending
Luacheck / luacheck (push) Waiting to run
* Fix reorder queue function for when from_index < to_index

* update default config

* Fix clipboard function and linting errors

* Update README.md with improved descriptions and installation instructions
2024-08-28 18:34:41 -07:00
Kyle Yasuda
84a860f596 fix display limit only showing up to half the set size (#18)
All checks were successful
Luacheck / luacheck (push) Successful in 5s
2023-08-13 19:14:11 -07:00
Kyle Yasuda
392b39c7fc Fix move video (#17)
* fix the move_video function and add some script-messages
* add gitignore
2023-08-13 18:02:55 -07:00
Kyle Yasuda
fa2014acd6 Dev (#16)
All checks were successful
Luacheck / luacheck (push) Successful in 4s
* convert get_video_info to use mp functions and add menu_timeout option
* add menu_timeout config option
* fix add_to_queue not returning when given invalid url or path
2023-08-09 23:14:00 -07:00
Kyle Yasuda
7b9a061118 add toggle_youtube_queue script-message (#15)
- add new script message to toggle queue instead of just printing
- move variable declarations to the top
2023-08-09 20:18:26 -07:00
ksyasuda
cfc4f94464 add hard space after cursor icon 2023-08-09 18:50:54 -07:00
Kyle Yasuda
554dfd3b67 fix leading spaces on items in print_queue function (#14) 2023-08-09 17:09:02 -07:00
Kyle Yasuda
f0d6143fd2 remove unused functions and clean up code (#13) 2023-08-09 02:04:24 -07:00
Kyle Yasuda
e35aeac422 cleanup/optimize code and squash some bugs (#12)
* cleanup/optimize code and squash some bugs

- change print_queue to use mp.assdraw
- change print_queue function to a toggle
- clean up duplicated code
- squash some bugs

* remove unused function

* make download async and update clipboard function to use mp command

- utilize mp.command_native and command_native_async
- download files in the background

* update default display_limit from 6 -> 10
2023-08-09 01:24:24 -07:00
ksyasuda
3a47cb0d0b update luacheck workflow 2023-08-09 01:21:40 -07:00
Kyle Yasuda
3814459024 update move cursor functions to allow holding down key (#11) 2023-08-08 02:21:24 -07:00
Kyle Yasuda
a1c2bfd9a7 fix is_file printing error message each time a url is passed (#10)
* fix is_file printing error message each time a url is passed

- remove print to osd on false result
- remove log messages
- change to check if not local file first when adding to queue

* appease the linter
2023-08-08 01:54:07 -07:00
ksyasuda
e88e7f7f1c update readme 2023-08-08 01:18:55 -07:00
ksyasuda
cdc797f55c update readme 2023-08-08 01:09:21 -07:00
Kyle Yasuda
b636e0534d change helper functions to use mpv utils (#9)
- use utils.file_info.is_file to check if the file exits and is a file
- use utils.split_path to split path into directory and filename components
2023-08-08 00:49:31 -07:00
5 changed files with 963 additions and 541 deletions

View File

@@ -1,7 +1,7 @@
name: Luacheck name: Luacheck
on: [push, pull_request] on: push
jobs: jobs:
sile: luacheck:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
test.sh
.git/*
.luarc.json

View File

@@ -2,7 +2,7 @@
<div align="center"> <div align="center">
A Lua script that implements the YouTube 'Add to Queue' functionality for mpv A Lua script that replicates and extends the YouTube "Add to Queue" feature for mpv
</div> </div>
@@ -10,35 +10,27 @@ A Lua script that implements the YouTube 'Add to Queue' functionality for mpv
## Features ## Features
- Add YouTube videos to a queue from the clipboard - **Interactive Queue Management:** A menu-driven interface for adding, removing, and rearranging videos in your queue
- Fetch and display the video and channel names of the videos in the queue - **yt-dlp Integration:** Gathers video info and allows downloading with any link supported by [yt-dlp](https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites.md "yd-dlp supported sites page")
- Select a video to play from the queue with an interactive menu, - **Internal Playlist Integration:** Seamlessly integrates with mpv's internal playlist for a unified playback experience
or navigate through the queue with keyboard shortcuts - **Customizable Keybindings:** Assign your preferred hotkeys to interact with the currently playing video and queue
- Edit the order of videos in the queue
- Open the URL or channel page of the currently playing video in a new browser tab
- Download the currently playing video
- Download a video in the queue
## Notes
- This script uses the Linux `xclip` utility to read from the clipboard.
If you're on macOS or Windows, you'll need to adjust the `clipboard_command`
config variable in [mpv-youtube-queue.conf](./mpv-youtube-queue.conf)
- When adding videos to the queue, the script fetches the video name using
`yt-dlp`. Ensure you have `yt-dlp` installed and in your PATH.
## Requirements ## Requirements
This script requires the following software to be installed on the system This script requires the following software to be installed on the system
- [xclip](https://github.com/astrand/xclip) - One of [xclip](https://github.com/astrand/xclip), [wl-clipboard](https://github.com/bugaevc/wl-clipboard), or any command-line utility that can paste from the system clipboard
- Windows users can utilize `Get-Clipboard` from powershell by setting the `clipboard_command` in `mpv-youtube-queue.conf` file to the following: `clipboard_command=powershell -command Get-Clipboard`
- [yt-dlp](https://github.com/yt-dlp/yt-dlp) - [yt-dlp](https://github.com/yt-dlp/yt-dlp)
## Installation ## Installation
- Copy the `mpv-youtube-queue.lua` script to your `~~/scripts` directory - Copy `mpv-youtube-queue.lua` script to your `~~/scripts` directory
(`~/.config/mpv` on Linux) - `~/.config/mpv/scripts` on Linux
- Optionally copy the `mpv-youtube-queue.conf` to the `~~/script-opts` directory - `%APPDATA%\mpv\scripts` on Windows
- Optionally copy `mpv-youtube-queue.conf` to the `~~/script-opts` directory
- `~/.config/mpv/script-opts` on Linux
- `%APPDATA%\mpv\script-opts` on Windows
to customize the script configuration as described in the next section to customize the script configuration as described in the next section
## Configuration ## Configuration
@@ -51,6 +43,8 @@ This script requires the following software to be installed on the system
in the queue in the queue
- `move_cursor_down - ctrl+j`: Move the cursor down one row in the queue - `move_cursor_down - ctrl+j`: Move the cursor down one row in the queue
- `move_cursor_up - ctrl+k`- Move the cursor up one row in the queue - `move_cursor_up - ctrl+k`- Move the cursor up one row in the queue
- `load_queue - ctrl+l` - Appends the videos from the most recent save point to 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
- `play_next_in_queue - ctrl+n`: Play the next video in the queue - `play_next_in_queue - ctrl+n`: Play the next video in the queue
- `open_video_in_browser - ctrl+o`: Open the currently playing video in the browser - `open_video_in_browser - ctrl+o`: Open the currently playing video in the browser
@@ -60,31 +54,39 @@ 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 - `print_current_video - ctrl+P`: Print the name and channel of the currently
playing video to the OSD playing video to the OSD
- `print_queue - ctrl+q`: Print the contents of the queue 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`
- `remove_from_queue - ctrl+x`: Remove the currently selected video from the - `remove_from_queue - ctrl+x`: Remove the currently selected video from the
queue queue
- `play_selected_video - ctrl+ENTER`: Play the currently selected video in - `play_selected_video - ctrl+ENTER`: Play the currently selected video in
the queue the queue
### Default Option ### 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 - `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 - `clipboard_command - xclip -o`: The command to use to get the contents of the clipboard
- `cursor_icon - ➤`: The icon to use for the cursor - `cursor_icon - ➤`: The icon to use for the cursor
- `display_limit - 6`: The maximum amount of videos to show on the OSD at once - `display_limit - 10`: The maximum amount of videos to show on the OSD at once
- `download_directory - ~/videos/YouTube`: The directory to use when - `download_directory - ~/videos/YouTube`: The directory to use when downloading a video
downloading a video
- `download_quality 720p`: The maximum download quality - `download_quality 720p`: The maximum download quality
- `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
- `font_name - JetBrains Mono`: The name of the font to use - `font_name - JetBrains Mono`: The name of the font to use
- `font_size - 12`: Size of the font - `font_size - 12`: Size of the font
- `marked_icon - ⇅`: The icon to use to mark a video as ready to be moved in - `marked_icon - ⇅`: The icon to use to mark a video as ready to be moved in the queue
the queue - `menu_timeout - 5`: The number of seconds until the menu times out
- `show_errors - yes`: Show error messages on the OSD - `show_errors - yes`: Show error messages on the OSD
- `ytdlp_file_format - mp4`: The preferred file format for downloaded videos - `ytdlp_file_format - mp4`: The preferred file format for downloaded videos
- `ytdlp_output_template - %(uploader)s/%(title)s.%(ext)s`: The [yt-dlp output - `ytdlp_output_template - %(uploader)s/%(title)s.%(ext)s`: The [yt-dlp output template string](https://github.com/yt-dlp/yt-dlp#output-template)
template string](https://github.com/yt-dlp/yt-dlp#output-template) - Full path with the default `download_directory` is: `~/videos/YouTube/<uploader>/<title>.<ext>`
- Full path with the default `download_directory` - `use_history_db - no`: Enable watch history tracking and remote video queuing through integration with [mpv-youtube-queue-server](https://gitea.suda.codes/sudacode/mpv-youtube-queue-server)
is: `~/videos/YouTube/<uploader>/<title>.<ext>` - `backend_host`: ip or hostname of the backend server
- `backend_port`: port to connect to for the backend server
## License ## License

View File

@@ -1,8 +1,10 @@
add_to_queue=ctrl+a add_to_queue=ctrl+a
default_save_method=unwatched
download_current_video=ctrl+d download_current_video=ctrl+d
download_selected_video=ctrl+D download_selected_video=ctrl+D
move_cursor_down=ctrl+j move_cursor_down=ctrl+j
move_cursor_up=ctrl+k move_cursor_up=ctrl+k
load_queue=ctrl+l
move_video=ctrl+m move_video=ctrl+m
play_next_in_queue=ctrl+n play_next_in_queue=ctrl+n
open_video_in_browser=ctrl+o open_video_in_browser=ctrl+o
@@ -10,18 +12,24 @@ open_channel_in_browser=ctrl+O
play_previous_in_queue=ctrl+p play_previous_in_queue=ctrl+p
print_current_video=ctrl+P print_current_video=ctrl+P
print_queue=ctrl+q print_queue=ctrl+q
save_queue=ctrl+s
save_full_alt=ctrl+S
remove_from_queue=ctrl+x remove_from_queue=ctrl+x
play_selected_video=ctrl+ENTER play_selected_video=ctrl+ENTER
browser=firefox browser=firefox
clipboard_command=xclip -o clipboard_command=xclip -o
cursor_icon=➤ cursor_icon=➤
display_limit=6 display_limit=10
download_directory=~/videos/YouTube download_directory=~/videos/YouTube
download_quality=720p download_quality=720p
downloader=curl downloader=curl
font_name=JetBrainsMono font_name=JetBrainsMono
font_size=12 font_size=12
marked_icon=⇅ marked_icon=⇅
menu_timeout=5
show_errors=yes show_errors=yes
ytdlp_file_format=mp4 ytdlp_file_format=mp4
ytdlp_output_template=%(uploader)s/%(title)s.%(ext)s ytdlp_output_template=%(uploader)s/%(title)s.%(ext)s
use_history_db=no
backend_host=http://localhost
backend_port=42069

File diff suppressed because it is too large Load Diff