Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ONEPIECE_FOLDER="/home/hashworks/Share/Series/One Piece/";
- TO_REMOVE=".nfo .srr .sfv .nzb .jpg .png .jpeg";
- PUSHOVER_TITLE="Download finished";
- PUSHOVER_TOKEN="";
- PUSHOVER_USER="";
- PLEX_URL="localhost"
- PLEX_LIB_KEY=12
- ############################################################################################################################################
- #
- # Usage: onepiece "DOWNLOADFOLDER";
- #
- # Best as Post-Processing script of SabNZBd.
- #
- # Turns One Piece absolute ordering to "Staffel XX/One Piece - SXXEYYYAZZZ - Title.ext" and moves it to your OP-folder.
- #
- # Only usefull for downloads of Op-Tube One Piece Anime Episodes - testet with usenet downloads by had551.
- # When a new Season is approched, create a new empty folder in $ONEPIECE_FOLDER, f.e. "Staffel 18".
- # Remember: This will NOT be able to handle special episodes! Exclude them from download.
- #
- # ~ HashWorks [2014-02-17]
- #
- ############################################################################################################################################
- if [ -z "$1" ] ; then echo "ERROR: No download folder path given. Usage: ""$0"" \"DOWNLOADFOLDER\""; exit 1; fi;
- echo -e "Post-Processing ""$1""\n";
- cd "$ONEPIECE_FOLDER";
- STAFFEL=$(find -name 'Staffel *' | sort -V | tail -1 | grep -o '[0-9]\{1,2\}');
- if [ ! -z "${STAFFEL#*[!0-9]*}" ] ; then echo -e "Season number found: ""$STAFFEL""."; else echo "ERROR: Given season (""$STAFFEL"") isn't a number. Make sure your season folders match \"Staffel XY\"."; exit 2; fi;
- cd "$ONEPIECE_FOLDER"Staffel\ "$STAFFEL";
- if [ ${#STAFFEL} == 1 ]; then STAFFEL_ZERO="0$STAFFEL"; elif [ ${#STAFFEL} == 2 ]; then STAFFEL_ZERO="$STAFFEL"; fi;
- EPISODE=$(echo $(find . -regextype sed -regex "./One Piece - S""$STAFFEL_ZERO""E.*" | sort) | sed 's/.*S'"$STAFFEL_ZERO"'E\([0-9]\{1,3\}\)A.*/\1/');
- EPISODE=$(echo "$EPISODE + 1" | bc)
- if [ ${#EPISODE} == 1 ]; then EPISODE="00$EPISODE"; elif [ ${#EPISODE} == 2 ]; then EPISODE="0$EPISODE"; fi;
- echo -e "Episode number found: ""$EPISODE"".\n";
- cd "$1";
- for REM in $TO_REMOVE; do find "$1" -name "*$REM" -type f -exec rm -f {} \;; done;
- FILE=$(find . -regextype sed -regex "./One Piece - Ep\..*" | sort);
- if [ -z "$FILE" ] ; then echo "No one piece file found."; exit 3; else echo -e "File found: ""$FILE""\n"; fi;
- ABSOLUT=$(echo "$FILE" | sed 's/.*Ep\.\([0-9]\{1,4\}\) -.*/\1/');
- if [ ! -z "${ABSOLUT#*[!0-9]*}" ] ; then echo -e "Absolute number found: ""$ABSOLUT""."; else echo "ERROR: Given absolute (""$ABSOLUT"") isn't a number. Make sure you downloaded from op-tube."; exit 4; fi;
- TITEL=$(echo "$FILE" | sed 's/.*Ep\.'"$ABSOLUT"' - \(.*\).\[op-tube\].*/\1/');
- if [ -z "$TITEL" ] ; then echo "ERROR: No title found."; exit 5; else echo -e "Title found: ""$TITEL"""; fi;
- ENDUNG=$(echo "$FILE" | sed 's/.*\.\(.*\)/\1/');
- if [ -z "$ENDUNG" ] ; then echo "ERROR: No extension found."; exit 6; else echo -e "Extension found: ""$ENDUNG""\n"; fi;
- OUTPUT="One Piece - S""$STAFFEL_ZERO""E""$EPISODE""A""$ABSOLUT"" - ""$TITEL"".""$ENDUNG";
- echo -e "Moving ""$1""$FILE""\nto ""$ONEPIECE_FOLDER""Staffel\ ""$STAFFEL""/""$OUTPUT""";
- mv "$1"/One\ Piece\ -\ Ep."$ABSOLUT"*."$ENDUNG" "$ONEPIECE_FOLDER"Staffel\ "$STAFFEL"/"$OUTPUT";
- echo -e "Removing ""$1""\n";
- rm -R "$1";
- curl -d message="One Piece - S""$STAFFEL_ZERO""E""$EPISODE""A""$ABSOLUT"" - ""$TITEL" -d title="$PUSHOVER_TITLE" -d token="$PUSHOVER_TOKEN" -d user="$PUSHOVER_USER" 'https://api.pushover.net/1/messages.json' >/dev/null 2>&1
- curl "http://""$PLEX_URL"":32400/library/sections/""$PLEX_LIB_KEY""/refresh" >/dev/null 2>&1
- echo -e "Done! [""$OUTPUT""]";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement