Skip to content

Instantly share code, notes, and snippets.

@janpaul123
Created December 20, 2020 21:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janpaul123/a06a6a5fa4ebced271d4c9170e3fdd50 to your computer and use it in GitHub Desktop.
Save janpaul123/a06a6a5fa4ebced271d4c9170e3fdd50 to your computer and use it in GitHub Desktop.
Find all Youtube videos in my archive which have since been removed
#!/bin/bash
set -Eeuxo pipefail
# Install youtube-dl
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /tmp/youtube-dl
chmod a+rx /tmp/youtube-dl
# Create /tmp/print-missing-youtube.sh script.
echo '#!/bin/bash' > /tmp/print-missing-youtube.sh
chmod a+rx /tmp/print-missing-youtube.sh
# Generate the script that looks up each video without downloading it,
# and prints the original filename if it couldn't find it.
# Assumes that the filenames have the Youtube ID after a dash at the end,
# e.g. "Best Part of a Chess Game Often Goes Unseen-H3Ao7varYrc.mp4".
# Original videos were downloaded with something like:
# youtube-dl --write-info-json --write-description --write-thumbnail --write-annotations --all-subs -i -o "%(title)s-%(id)s.%(ext)s" <playlist-url>
ls /mnt/d/mirrorred/Non-Dropbox/youtube-liked/ | perl -pe 's|.*?-([a-zA-Z0-9_-]{11})\..*|\1|' | sort | uniq | sed '/^$/d' | perl -pe 's|(.*)|/tmp/youtube-dl --quiet --skip-download https://www.youtube.com/watch?v=\1 \|\| ls /mnt/d/mirrorred/Non-Dropbox/youtube-liked/ \| grep \1.m|' >> /tmp/print-missing-youtube.sh
# Run the script.
/tmp/print-missing-youtube.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment