Skip to content

Commit

Permalink
log paths + cleanup
Browse files Browse the repository at this point in the history
log paths + cleanup
  • Loading branch information
sualfred committed Jun 19, 2018
1 parent 5935728 commit ca84926
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions 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
Expand All @@ -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
Expand Down

0 comments on commit ca84926

Please sign in to comment.