From 0a87b343fb6af155ea89674cb772d8267bd40e59 Mon Sep 17 00:00:00 2001 From: TheFrenchGhosty Date: Tue, 21 May 2024 17:31:38 +0200 Subject: [PATCH] Release an experimental script that check which videos were deleted from YouTube (Closes #65) --- .../Check Availability.sh | 35 +++++++++++++++++++ scripts/z-Check Availability/README.md | 28 +++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 scripts/z-Check Availability/Check Availability.sh create mode 100644 scripts/z-Check Availability/README.md diff --git a/scripts/z-Check Availability/Check Availability.sh b/scripts/z-Check Availability/Check Availability.sh new file mode 100644 index 0000000..b11882b --- /dev/null +++ b/scripts/z-Check Availability/Check Availability.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# TheFrenchGhosty's Ultimate YouTube-DL Scripts Collection: The ultimate collection of scripts for YouTube-DL +# https://github.com/TheFrenchGhosty/TheFrenchGhostys-Ultimate-YouTube-DL-Scripts-Collection +# https://github.com/TheFrenchGhosty +# +# Version: EXPERIMENTAL +# + + +output_file="unavailable_videos.txt" + +# Function to extract YouTube video IDs from filenames +get_video_ids() { + find . -type f -name "*\[*\].mkv" | sed 's/.*\[//;s/\].mkv$//' +} + +# Check if a YouTube video is still available +is_video_available() { + video_id="$1" + if yt-dlp -e "https://www.youtube.com/watch?v=${video_id}" >/dev/null 2>&1; then + return 0 # Available + else + return 1 # Unavailable + fi +} + +# Main loop +for video_id in $(get_video_ids); do + if ! is_video_available "$video_id"; then + echo "$video_id" >> "$output_file" + fi +done + +echo "Unavailable YouTube video IDs have been saved to $output_file" diff --git a/scripts/z-Check Availability/README.md b/scripts/z-Check Availability/README.md new file mode 100644 index 0000000..cb5556b --- /dev/null +++ b/scripts/z-Check Availability/README.md @@ -0,0 +1,28 @@ +# Check Availability Script + +An experimental script that check if the downloaded videos are still available on YouTube. + +See the reasoning in: https://github.com/TheFrenchGhosty/TheFrenchGhostys-Ultimate-YouTube-DL-Scripts-Collection/issues/65 + +This scripts only supports YouTube, running it on a folder that contain videos from other source will just make those videos appear as not available on YouTube. + + +This script was made with ChatGPT 3 and fixed by hand. + +Prompt: "I have a lot of files named "file [youtube video ID].mkv". Make a bash script that recursively get those youtube videos ID and check if those videos are still available on youtube. If they aren't, output the ID to a text file." + + +# Usage + +Copy this script next to the download script and run it. + +The list of available videos will be outputed to `unavailable_videos.txt` next to the script. + + +# Warning + +This script is highly experimental and hasn't been as extensively tested as the other scripts. + +Nothing bad should happen, however, use it at your own risk. + +If you do run it and notice any bug with it, please open an issue.