From bc80cdbbe6db02f17fbc227bb74b0564ee2174db Mon Sep 17 00:00:00 2001 From: emma Date: Fri, 3 Nov 2023 17:33:44 -0600 Subject: [PATCH] fixed web archive returning private videos --- yt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/yt b/yt index 82fccf2..5c2f0da 100755 --- a/yt +++ b/yt @@ -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