Compare commits

...

2 Commits

Author SHA1 Message Date
78701fb6f2
made verify cache the title of non-archived videos 2023-11-02 22:50:57 -06:00
7204835592
added README 2023-11-02 22:50:00 -06:00
2 changed files with 50 additions and 1 deletions

36
README Normal file
View File

@ -0,0 +1,36 @@
yt(1) is a helper script providing functions for use with mpv and yt-dlp for
viewing and interacting with YouTube videos.
Dependencies:
- curl(1)
- fzf(1)
- jq(1)
- mpv(1)
- yt-dlp(1)
Usage:
yt add | clone | music | pick | play | verify
add uri file
- Adds a video by URI to a playlist
cache uri...
- Caches a video title
clone uri file
- Clones a YouTube playlist to a file
music uri...
- Downloads a video as audio, splitting it by chapter
pick file...
- Opens fzf(1) to a list of videos in a file
play uri...
- Plays a video, caching its title first
verify file...
- Verifies that all the videos in a playlist are existent on YouTube, and if
they arent, attempts to replace the URI with one from the Wayback Machine. If
the video isnt available on the Wayback Machine, it comments the video link. It
then caches the title of the video.

15
yt
View File

@ -51,6 +51,17 @@ cache() { # cache the video title for faster retrieval
clone() { # clones a YouTube playlist in m3u format
yt-dlp --flat-playlist "$1" --print url > "$2.m3u"
verify "$2.m3u"
for line in $(cat "$2.m3u")
do
if test -n "$(printf '%s\n' "$line" \
| sed -n -e '/web\.archive\.org/p' -e '/^\#/p')"
then
continue
else
archive "$line"
fi
done
}
music() { # downloads a video, splitting by chapter and only saving the audio
@ -80,7 +91,7 @@ pick() { # Pick a video to play from a list of videos
test -n "$chosen" && mpv "$chosen"
}
play() { # play a playlist or video after caching its title
play() { # play a video after caching its title
while test -n "$1"; do
cache "$1"
mpv "$1"
@ -122,6 +133,8 @@ verify() { # replaces videos with archived versions if they are not available
printf '%s\n' "$content" >"$1"
cache "$wayback_url"
fi
else
cache "$video"
fi
done