Skip to content

Instantly share code, notes, and snippets.

@cwill747
Created January 17, 2018 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwill747/786aa48f0305c22f29a0f74326e5678b to your computer and use it in GitHub Desktop.
Save cwill747/786aa48f0305c22f29a0f74326e5678b to your computer and use it in GitHub Desktop.
Downloads a Twitch Vod for Plex Tv Shows
#!/usr/bin/env bash
JSON="$(youtube-dl -j $1)"
UPLOADER=$(echo "${JSON}" | jq -c -r '.uploader')
UPLOAD_DATE=$(echo "${JSON}" | jq -cr '.upload_date')
TITLE=$(echo "${JSON}" | jq -cr '.title')
EXTENSION=$(echo "${JSON}" | jq -cr '.ext')
UPLOAD_YEAR=${UPLOAD_DATE:0:4}
BASE_FOLDER="${UPLOADER}/${UPLOAD_YEAR}"
VIDEO_COUNT=$(ls -l "${BASE_FOLDER}" | wc -l)
VIDEO_COUNT_PADDED=$(printf "%02d" "${VIDEO_COUNT}")
pushd "${BASE_FOLDER}"
youtube-dl --get-filename --restrict-filenames -o "${UPLOADER} - s${UPLOAD_YEAR}e${VIDEO_COUNT_PADDED} - ${TITLE}.${EXTENSION}" $1
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment