Skip to content

Instantly share code, notes, and snippets.

@hypevhs
Last active October 1, 2021 21:29
Show Gist options
  • Save hypevhs/9cb8c4b923565ffd1e0fa26e9ec5e71c to your computer and use it in GitHub Desktop.
Save hypevhs/9cb8c4b923565ffd1e0fa26e9ec5e71c to your computer and use it in GitHub Desktop.
yt-dlp check for exactly 1 of video, metadata, etc
# DEPRECATED
# in a directory filled with yt-dlp saved items,
# for every video ID, we want exactly ONE video, ONE metadata json, and ONE thumbnail.
# usually, it's the video that's missing. maybe move the rest to legacy/?
# for each video ID in this dir, print out the video IDs where one of the content types is missing.
find . -maxdepth 1 -type f -regextype grep -regex '.*\[[a-zA-Z0-9_-]\{11\}\]\..*' -printf '%f\n' | grep -Po '(?<= \[).{11}(?=\]\.)' | sort -u | while read f; do EXTS="$(for ff in *"${f}"*; do echo "${ff}"; done | perl -pe 's|(.*?)\.(((info\|live_chat)\.)?json\|mkv\|mp4\|vtt\|webp\|jpg)$|\2|')"; if [[ "$(echo "$EXTS" | grep -Eo '^(mkv|mp4)$' | wc -l)" != "1" || "$(echo "$EXTS" | grep -Eo '^(jpg|webp)$' | wc -l)" != "1" || "$(echo "$EXTS" | grep -Eo '^info\.json$' | wc -l)" != "1" ]]; then echo "$f"; fi; done
# inspect a single ID
echo "00vYncpl0pk" | while read f; do EXTS="$(for ff in *"${f}"*; do echo "${ff}"; done | perl -pe 's|(.*?)\.(((info\|live_chat)\.)?json\|mkv\|mp4\|vtt\|webp\|jpg)$|\2|')"; if [[ "$(echo "$EXTS" | grep -Eo '^(mkv|mp4)$' | wc -l)" != "1" || "$(echo "$EXTS" | grep -Eo '^(jpg|webp)$' | wc -l)" != "1" || "$(echo "$EXTS" | grep -Eo '^info\.json$' | wc -l)" != "1" ]]; then echo "$f"; fi; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment