fixed web archive returning private videos

This commit is contained in:
Emma Tebibyte 2023-11-03 17:33:44 -06:00
parent 209f38200a
commit bc80cdbbe6
Signed by: emma
GPG Key ID: 6D661C738815E7DD

12
yt
View File

@ -54,8 +54,8 @@ cache() { # cache the video title for faster retrieval
done
}
clone() { # clones a YouTube playlist in m3u format
yt-dlp --flat-playlist "$1" --print url > "$2.m3u"
clone() { # clones a YouTube playlist to a file
yt-dlp --flat-playlist "$1" --print url > "$2"
verify "$2.m3u"
for line in $(cat "$2.m3u")
@ -130,10 +130,12 @@ verify() { # replaces videos with archived versions if they are not available
printf "%s: %s: Video unavailable.\n" "$argv0" "$video" 1>&2
wayback_url="$(curl -s "$WBAPI$video" \
| jq .archived_snapshots.closest.url \
| tr -d '"' | sed 's/^http:/https:/g')"
| jq -r .archived_snapshots.closest.url \
| sed 's/^http:/https:/g')"
if [ "$wayback_url" = "null" ]; then
if [ "$wayback_url" = "null" ] \
&& test -n "$(yt-dlp -s "$wayback_url" 2>&1 | grep -e 'not archived')"
then
printf "%s: %s is not available on the Wayback Machine.\n" \
"$argv0" "$video" 1>&2
# replace the video link with a comment containing link