From ca84926377d9f1db54b6b97858c6ad3a9cd9573e Mon Sep 17 00:00:00 2001 From: Sebastian S Date: Tue, 19 Jun 2018 16:23:59 +0200 Subject: [PATCH] log paths + cleanup log paths + cleanup --- trailerdl/trailerdl.sh | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/trailerdl/trailerdl.sh b/trailerdl/trailerdl.sh index 0d7b71c..2996aaa 100644 --- a/trailerdl/trailerdl.sh +++ b/trailerdl/trailerdl.sh @@ -1,43 +1,54 @@ + #!/bin/bash + ################################# # Config # ################################# -#Search this paths +#Search this paths (required) PATHS=( "/mnt/omv1/omv1/filme" "/mnt/omv2/omv2/filme" "/mnt/omv3/omv3/filme" "/mnt/omv4/omv4/filme" ) -#Your TheMovieDB API +#Your TheMovieDB API (required) +#Please visit https://developers.themoviedb.org/3 for more information API= -#Language Code +#Language Code (required) +#Examples: de = German, en = English, etc. LANGUAGE=de +#Custom path to store the log files. Uncomment this line and change the path. By default the working directory is going to be used. +#LOGPATH="/home/myexampleuser" + ################################# #Functions downloadTrailer(){ - youtube-dl -f mp4 "https://www.youtube.com/watch?v=$ID" -o "$DIR/$FILENAME-trailer.%(ext)s" --restrict-filenames |& tee -a trailerdl.log + youtube-dl -f mp4 "https://www.youtube.com/watch?v=$ID" -o "$DIR/$FILENAME-trailer.%(ext)s" --restrict-filenames |& tee -a "$LOGPATH/trailerdl.log" } log(){ - echo "$1" |& tee -a trailerdl.log + echo "$1" |& tee -a "$LOGPATH/trailerdl.log" } missing(){ - echo "$1" |& tee -a trailerdl-missing.log &>/dev/null + echo "$1" |& tee -a "$LOGPATH/trailerdl-missing.log" &>/dev/null } ################################# #Delete old logs -rm trailerdl.log &>/dev/null -rm trailerdl-missing.log &>/dev/null +rm "$LOGPATH/trailerdl.log" &>/dev/null +rm "$LOGPATH/trailerdl-missing.log" &>/dev/null #Use manually provided language code (optional) if ! [ -z "$1" ]; then LANGUAGE="$1" fi +if [ -z "$LOGPATH" ]; then + LOGPATH=$(pwd) +fi + #Walk defined paths and search for movies without existing local trailer for i in "${PATHS[@]}" do @@ -63,19 +74,23 @@ do ID="${JSON[0]}" if ! [ -z "$ID" ]; then - #Start download + + #Start download log "YouTube: https://www.youtube.com/watch?v=$ID" downloadTrailer else + log "YouTube: n/a" missing "Error: Missing YouTube ID - $FILENAME - $DIR - TheMovideDB: https://www.themoviedb.org/movie/$TMDBID" fi else + log "TheMovieDB: n/a" missing "Error: Missing TheMovieDB ID - $FILENAME - $DIR" + fi fi