Created
January 17, 2018 22:04
-
-
Save cwill747/786aa48f0305c22f29a0f74326e5678b to your computer and use it in GitHub Desktop.
Downloads a Twitch Vod for Plex Tv Shows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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