Automate yt-dlp downloading, storing, checking for duplicates and watching videos using mpv, vlc, or an alternative with concise commands.
You will need the following dependencies installed on your system:
bashcoreutils- If you don't know what this means, you probably have it.yt-dlp(default) oryoutube-dl(for downloading videos)mpv(default),cvlc,vlcor alternative for viewing videos (for viewing videos)fzf(to be optional in the future; for interactive selection)
- Clone the repository:
cd ~/projects
git clone https://github.com/FrostyNick/y2.gitNote
ln needs to be used again (as shown later) if y2 is moved. Pick a place you don't plan to move it out of right away.
- Make the script executable:
chmod +x ./y2/y2.sh- Add it to path so it can be run anywhere. To see where your path(s) are: echo $PATH
# Check that /usr/local/bin is in $PATH otherwise below will not work.
sudo ln -s $HOME/projects/y2.sh /usr/local/bin/y2
# For example, if choosing ~/.local/bin instead if above is not found in $PATH:
sudo ln -s $HOME/projects/y2.sh $HOME/.local/bin/y2- Check that it runs.
y2 --help
See y2 --help for the latest help.
y2 [options] <media_url>- Download a video and save it in
filestore.
y2 https://youtu.be/pVI_smLgTY0- (
yt-dlponly maybe) Download a video like above with recommended added options and a max video height:
y2 0 720 https://youtu.be/pVI_smLgTY0The 0 above (without second argument) at the time of writing is replaced with:
-f bestvideo[height<=1080]+bestaudio/best[height<=1080] --embed-chapters --sponsorblock-mark all --embed-metadata --embed-thumbnail --add-metadata --embed-subs --sub-lang en
- Download a video with height no bigger than 500px (this is comparable to quality settings in YouTube video); adding some flags from
yt-dlpas well:
y2 500 --dateafter today-2weeks https://www.youtube.com/watch?v=xsDnEj2Hx4Q- Get video. This will work if it's in the filename.
y2 -g pVI_smLgTY0-hor--helpor empty: Get help.-g: Get downloaded video(s) usinggrepandfzf. Tested to work on YouTube videos.0: Apply extra flags to the filefetch (yt-dlp; might work withyoutube-dl).<int> != 0: Set a maximum video height size.--max <int>: Same as above.
Every other flag that is not recognized will be passed to filefetch.
You can customize the following settings in the start of the script:
filefetch: Set toyt-dlp(default) oryoutube-dl.fileview: Set tompv(default) or other media players.filestore: Default storage location for downloaded videos ($HOME/y2).filecache: Default cache location ($HOME/.cache/y2).
Warning
This may be moved to $HOME/.config in the future.
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the UNLICENSE License. See the UNLICENSE file for details.