Allow more flexible formats; download to temporary file and then copy to final destination (for downloading to slow NASes); check that the output directory exists.
This commit is contained in:
parent
5474e037c8
commit
ba70cacc6d
@ -1,12 +1,27 @@
|
|||||||
#/bin/bash
|
#/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# sudo pip install --upgrade youtube-dl && sudo pip3 install --upgrade youtube-dl
|
||||||
|
#
|
||||||
|
# If you get youtube-dl permissions errors like
|
||||||
|
# "ImportError: cannot import name 'main'", run
|
||||||
|
# sudo find /usr/local -type d -exec chmod a+rx {} + && sudo find /usr/local -type f -exec chmod a+r {} + && sudo find /usr/local/bin -type f -exec chmod a+rx {} +
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
TMP_DIR=/tmp/dailyshow
|
||||||
DOWNLOAD_DIR=/media/nas/video/series
|
DOWNLOAD_DIR=/media/nas/video/series
|
||||||
#YOUTUBE_DL="/usr/bin/youtube-dl"
|
#YOUTUBE_DL="/usr/bin/youtube-dl"
|
||||||
YOUTUBE_DL="/usr/local/bin/youtube-dl"
|
YOUTUBE_DL="python3 /usr/local/bin/youtube-dl"
|
||||||
#KEEP_DAYS=40
|
#KEEP_DAYS=40
|
||||||
KEEP_DAYS=100
|
KEEP_DAYS=100
|
||||||
ARGS=-qwc
|
ARGS=-qwc
|
||||||
|
|
||||||
|
if [ ! -d ${DOWNLOAD_DIR} ]; then
|
||||||
|
echo "Error: directory not found: ${DOWNLOAD_DIR}"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
OPTIND=1 # Reset is necessary if getopts was used previously
|
OPTIND=1 # Reset is necessary if getopts was used previously
|
||||||
while getopts ":u:d" opt; do
|
while getopts ":u:d" opt; do
|
||||||
case "${opt}" in
|
case "${opt}" in
|
||||||
@ -44,11 +59,13 @@ function download_show {
|
|||||||
url="$1"
|
url="$1"
|
||||||
show="$2"
|
show="$2"
|
||||||
|
|
||||||
|
mkdir -p "${TMP_DIR}/${show}"
|
||||||
mkdir -p "${DOWNLOAD_DIR}/${show}"
|
mkdir -p "${DOWNLOAD_DIR}/${show}"
|
||||||
|
|
||||||
# Get a chosen video format for each site
|
# Get a chosen video format for each site
|
||||||
if [[ "${url}" =~ cc.com ]]; then
|
if [[ "${url}" =~ cc.com ]]; then
|
||||||
FORMAT=1028
|
FORMAT="1028/907/498/500"
|
||||||
|
FORMAT="best[width<=?640]"
|
||||||
elif [[ "${url}" =~ cbs.com ]]; then
|
elif [[ "${url}" =~ cbs.com ]]; then
|
||||||
FORMAT="rtmp-496-0"
|
FORMAT="rtmp-496-0"
|
||||||
fi
|
fi
|
||||||
@ -56,12 +73,13 @@ function download_show {
|
|||||||
# Try and download twice (resume if partially downloaded)
|
# Try and download twice (resume if partially downloaded)
|
||||||
for i in 1 2; do
|
for i in 1 2; do
|
||||||
${YOUTUBE_DL} ${ARGS} -f ${FORMAT} \
|
${YOUTUBE_DL} ${ARGS} -f ${FORMAT} \
|
||||||
-o "${DOWNLOAD_DIR}/${show}/%(upload_date)s/%(title)s-%(id)s.%(ext)s" \
|
-o "${TMP_DIR}/${show}/%(upload_date)s/%(title)s-%(id)s.%(ext)s" \
|
||||||
--download-archive "${DOWNLOAD_DIR}/${show}.archive" \
|
--download-archive "${DOWNLOAD_DIR}/${show}.archive" \
|
||||||
${url}
|
${url}
|
||||||
|
|
||||||
# Wait 10 minutes before trying again
|
# Wait 10 minutes before trying again
|
||||||
#sleep 600
|
#sleep 600
|
||||||
|
cp -nr "${TMP_DIR}/${show}"/* "${DOWNLOAD_DIR}/${show}"/
|
||||||
done
|
done
|
||||||
|
|
||||||
# Move files from ${DOWNLOAD_DIR}/The Daily Show/NA/ to ${DOWNLOAD_DIR}/The Daily Show/$date
|
# Move files from ${DOWNLOAD_DIR}/The Daily Show/NA/ to ${DOWNLOAD_DIR}/The Daily Show/$date
|
||||||
|
Loading…
Reference in New Issue
Block a user