Skip to content

Commit

Permalink
Fixed youtube-dl logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sualfred committed Jun 19, 2018
1 parent ca84926 commit 4ef7c25
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions trailerdl/trailerdl.sh
@@ -1,4 +1,3 @@

#!/bin/bash

#################################
Expand All @@ -23,28 +22,39 @@ LANGUAGE=de

#Functions
downloadTrailer(){
youtube-dl -f mp4 "https://www.youtube.com/watch?v=$ID" -o "$DIR/$FILENAME-trailer.%(ext)s" --restrict-filenames |& tee -a "$LOGPATH/trailerdl.log"
DL=$(youtube-dl -f mp4 "https://www.youtube.com/watch?v=$ID" -o "$DIR/$FILENAME-trailer.%(ext)s" --restrict-filenames)
log "$DL"

if [ -z "$(echo "$DL" | grep "100.0%")" ]; then
missing ""
missing "Error: Downloading failed - $FILENAME - $DIR - TheMovideDB: https://www.themoviedb.org/movie/$TMDBID - YouTube: https://www.youtube.com/watch?v=$ID"
missing "------------------"
missing "$DL"
missing "------------------"
missing ""
fi
}

log(){
echo "$1" |& tee -a "$LOGPATH/trailerdl.log"
}

missing(){
echo "$1" |& tee -a "$LOGPATH/trailerdl-missing.log" &>/dev/null
echo "$1" |& tee -a "$LOGPATH/trailerdl-error.log" &>/dev/null
}

#################################

#Delete old logs
rm "$LOGPATH/trailerdl.log" &>/dev/null
rm "$LOGPATH/trailerdl-missing.log" &>/dev/null
rm "$LOGPATH/trailerdl-error.log" &>/dev/null

#Use manually provided language code (optional)
if ! [ -z "$1" ]; then
LANGUAGE="$1"
fi

#Use working directory for logs except a custom one is configured
if [ -z "$LOGPATH" ]; then
LOGPATH=$(pwd)
fi
Expand Down Expand Up @@ -87,10 +97,8 @@ do
fi

else

log "TheMovieDB: n/a"
missing "Error: Missing TheMovieDB ID - $FILENAME - $DIR"

fi

fi
Expand Down

0 comments on commit 4ef7c25

Please sign in to comment.