Skip to content

Instantly share code, notes, and snippets.

@jimmygle
Last active May 5, 2021 21:14
Show Gist options
  • Save jimmygle/d01e0d9be4c8b71349a1680bb1eb65c7 to your computer and use it in GitHub Desktop.
Save jimmygle/d01e0d9be4c8b71349a1680bb1eb65c7 to your computer and use it in GitHub Desktop.
Downloads youtube channel's most recent videos and renames files for JellyFin import.
# Download Newest Videos
youtube-dl \
--dateafter 20210323 \
--match-title 'Level1 News' \
--playlist-end 5 \
--write-all-thumbnails \
--all-subs \
--sub-format srt \
--download-archive ./.ytdl_downloaded \
--add-metadata \
--output '%(upload_date)s.%(title)s.%(id)s' \
--restrict-filenames \
https://www.youtube.com/c/Level1Techs/videos\?view\=0
# Rename thumbnail file (for recognition in JF) _ -> -thumb.jpg
find . -name "*_3.jpg" -exec sh -c 'rename "s/(.*)_3\.jpg/\$1\-thumb\.jpg/" "{}"' \;
# Delete extra thumbnail files
find . -regex ".*\_[0-4]\{1\}\.jpg" -exec rm {} + -or -regex ".*\_[0-4]\{1\}\.webp" -exec rm {} +
# Change file prefixes (for organizing in JF) from YYYYMMDD -> SYYYYEMMDD
find . -regex ".*/[0-9]\{8\}.*" -exec sh -c 'rename "s/.*\/([0-9]{4})([0-9]{4})/\.\/S\$1E\$2/" "{}"' \;
# Replace metadata description with chapter list
# WIP: exiftool -Description="`exiftool -s -S -ChapterList {}`" {}\;
# Move to NAS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment