Page 2 of 2

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 3:40 pm
by jwbp100
Ah bum, could have predicted it was me being special.
I'll correct, retry and let you know.

Managed to find a few different builds of mencoder - one required X11 libraries, the other needed rosetta - went for the lesser of two evils to get an intel-native one.

You rock dude. :)

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 3:47 pm
by jwbp100
th3joker wrote: It's an error in your directory settings:

+ postproc_dest_folder='/Volumes/Downloads/Usebin/TV//Season /'

It has an extra / in it and an extra space after Season

+ postproc_dest_folder='/Volumes/Downloads/Usebin/TV/Season/'

Right, partially vindicated. (I think!)
That part of the debug is from the postproc_dest_folder="/Volumes/Downloads/Usebin/TV/$show_name/Season $season/" bit - at that point the regex has parsed the filename variables $show_name and $season as blank spaces, no?

My Stuffs Included below ...

Code: Select all

#!/bin/bash -x

# The script will post process TV and Movie files, it will join 
# multiple .avi files and create ISO image from VIDEO_TS folders.
# If it's a TV Show the files are renamed using tvrenamer.pl to my chosen naming convention.
# It then transcodes the files using Handbrake's preset for iPads.
# The preset can be altered to use any of the Handbrake current presets.
# AtomicParsley then tags the file for iTunes if it's a TV Show.
# The transcoded file is then moved to a folder of your choice.
# I have a 'watched folder action' on that folder and my Mac Desktop sees the new file and adds it to itunes.

# Some locations below are hardcoded in this script
# All of the settings in this script which may vary from machine to machine are preceeded with:
# "##### The line below contains a user defined location setting" 
# Search for the $ 'Dollar' signs and update the lines below them all to suit your system.


# There are 5 applications you need to install for this script to properly function
#
# 1) HandbrakeCLI (encodes the video for iPad)
#    Download from: http://handbrake.fr/downloads.php
#
#
# 2) Mencoder (used for joining 2 AVI's)
#    Download from: http://www.mplayerhq.hu/design7/dload.html#binaries
#    Mencoder is one of the files in the MPlayer download
#
#
# 3) mkisofs (Tags Movies and TV Shows with info and cover art)
#    Makes and ISO from your VIDEO_TS folders
#
#
# 4) tvrenamer.pl (Tags Movies with info and cover art)
#      Written by: Robert Meerman ([email protected], ICQ# 37099562)
#    Website: http://www.robmeerman.co.uk/coding/file_rename
#
#
# 5) Atomic Parsley (Tags Movies with info and cover art)
#    Add TV Show tagging information for iTunes using AtomicParsley: http://atomicparsley.sourceforge.net/
#     If you have the artwork for your TV Shows then this will also apply the image to the meta information for iTunes
#     there's a user definable parameter for the folder where you store these.
#


# Sample option 'Ignore Samples' in Sabnzbd | Config | Switches, must be set to 'Do not download'

##### User definable locations

##### Transcoded file destination
##### The line below contains a user defined location setting, change to where you want your transcoded files to go.
movie_dest_folder="/Volumes/Downloads/Usebin/Movies/"

##### Original file destination
##### The line below contains a user defined location setting, change to where you want your processed files to go.
unwatched_dest_folder="/Volumes/Downloads/Usebin/Movies/"

##### TV Show artwork location if you have it
##### Files must be formatted to match the Show Name and have a jpg extension eg: "The West Wing.jpg"
##### The line below contains a user defined location setting, this is the folder where you store your TV Show artwork
movieartwork="/Users/james/Pictures/Artwork/"    

##### Movie Preset transcoding options
##### The line below contains a user defined Handbrake preset.
##### Change the line 'movie_preset="iPad"' substitute "iPad" with another preset. 
##### Preset options are:
##### 'Apple= Universal, iPod, iPhone, iPad, AppleTV, QuickTime, Legacy, AppleTV Legacy, iPhone Legacy, iPod Legacy'
##### 'Basic= Normal, Classic'
##### 'High Profile= Animation, Constant Quality Rate, Film, Television'
##### 'Gaming Consoles= PSP, PS3, Xbox 360'
movie_preset="iPad"

##### TV Show transcoded file destination
##### The line below contains a user defined location setting, change to where you want your transcoded files to go.
tv_dest_folder="/Volumes/Downloads/Usebin/TV/"

##### TV Show transcoded file destination where no TV Show information was found
##### The line below contains a user defined location setting, change to where you want your transcoded files to go.
dest_false=" -  SE.m4v"

##### TV Show artwork location if you have it
##### Files must be formatted to match the Show Name and have a jpg extension eg: "The West Wing.jpg"
##### The line below contains a user defined location setting, this is the folder where you store your TV Show artwork
tvartwork="/Users/james/Pictures/Artwork/"    
    
##### TV Show Preset transcoding options
##### Change the line 'tv_preset="iPad"' substitute "iPad" with another preset. 
##### Preset options are:
##### 'Apple= Universal, iPod, iPhone, iPad, AppleTV, QuickTime, Legacy, AppleTV Legacy, iPhone Legacy, iPod Legacy'
##### 'Basic= Normal, Classic'
##### 'High Profile= Animation, Constant Quality Rate, Film, Television'
##### 'Gaming Consoles= PSP, PS3, Xbox 360'
##### The line below contains a user defined Handbrake preset.
tv_preset="iPad"

# SABnzbd output parameters
DIR=$1
NZB_FILE=$2
NAME=$3
NZB_ID=$4
CATEGORY=$5
GROUP=$6
STATUS=$7

# Fake SABnzbd parameters
# DIR="/media/Movies/0, New/Movie (2009)/"
# NZB_FILE="Movie (2009).nzb"
# NAME="Movie (2009)"
# NZB_ID=""
# CATEGORY="movies"
# GROUP="alt.binaries.teevee"
# STATUS="0"

####################
# Movie Processing #
####################


if [ $CATEGORY == "movies" ]; then
    echo "  - Processing as a Movie"
    echo
    
    # Stops error printing in loop if there are no video files in the folder
    shopt -s nullglob

#===============================================================================
# Find Movie Artwork if in folder
    cd "$DIR"
    find . -type f -maxdepth 1 -name '*.jpg' -exec mv '{}' "$movieartwork$NAME.jpg" \;

#===============================================================================
# If VIDEO_TS will be converted to ISO image
    cd "$DIR"
    # Finding VIDEO_TS folder and files
    if [[ -e $(find . \( ! -regex '.*/\..*' \) -type f -name "VIDEO_TS.IFO") ]]; then
        IFO=$(find . \( ! -regex '.*/\..*' \) -type f -name "VIDEO_TS.IFO")
        echo "folder/file: $IFO"
        VIDEOTS=$(echo $IFO|sed 's/[vV][iI][dD][eE][oO][_][tT][sS][.][iI][fF][oO].*//g')
        VIDEOTSROOT=$(echo $VIDEOTS|sed 's/[vV][iI][dD][eE][oO][_][tT][sS].*//g')
        echo
        echo "VIDEO_TS Found, converting to an ISO"
        mkisofs -input-charset iso8859-1 -dvd-video -o "$DIR/$NAME.iso" "$VIDEOTSROOT"  > /dev/null 2>&1
        echo
        echo "  - Conversion to ISO complete"
        echo
        rm -R "$VIDEOTSROOT"
        echo "  - Deleted VIDEO_TS folder"
        echo
        
    fi
    
#===============================================================================
# Move all video files into the main processing folder
    cd "$DIR"
    
    # Finding files larger than 300MB for processing and delete files smaller than 30MB
    find "$DIR" -size +307200k -exec mv {} "$DIR" \;
    find "$DIR" -size -30720k -type f -exec rm {} \;

#===============================================================================
# if there are 2 AVI's join them
    cd "$DIR"
    # Finding multiple .AVI files    
    for i in *{CD2,cd2}.avi; do
        echo "  - 2 AVI files where found Joining them together:"
        mencoder -forceidx -ovc copy -oac copy *{CD1,cd1}.avi *{CD2,cd2}.avi -o "$NAME.avi" > /dev/null 2>&1
        echo "  - Combine completed"
        mkdir "Unjoined AVIs"
        mv *{CD1,cd1}.avi "Unjoined AVIs/."
        mv *{CD2,cd2}.avi "Unjoined AVIs/."
        echo "  - Old AVIs moved into 'Unjoined AVIs' folder"
        echo
    done


    
#===============================================================================
# Transcode with Handbrake to preset
    cd "$DIR"
    # Finding media files to convert
    for i in *.mkv *.avi *.m4v *.mp4 *.wmv *.iso *.img; do
        
        # Setting the variables for Destination File
        movie_dest_file="${i%.*}"".m4v"
            
        # Convert the source video file to a preset M4V file using HandBrake
        HandBrakeCLI -i "$i" -o "$movie_dest_file" --preset="$movie_preset"     > /dev/null 2>&1
        echo
        echo "  - Conversion to m4v complete"
    done

#===============================================================================    
# Add Movie Show tagging information for iTunes using AtomicParsley: http://atomicparsley.sourceforge.net/
# If Artwork is available locally for the show then this tags the image
    if [[ -e $(find "$movieartwork" -maxdepth 1 -name "$NAME.jpg") ]]; then
    echo "  - Adding Artwork for movie from Artwork folder"
    AtomicParsley "$movie_dest_file" --genre "Movie" --stik "Movie" --artwork "$movieartwork$NAME.jpg" --overWrite > /dev/null 2>&1
    fi
    
    # Move converted file to Destination folder
    mv "$movie_dest_file" "$movie_dest_folder"
    echo
    echo "  - Converted m4v moved to folder for import iTunes"
    
    # Move Unconverted files to Movie Library 
    mv "$i" "$unwatched_dest_folder"
    echo
    echo "  - Original files moved to Movie Library"

    # Delete extraneous files and VIDEO_TS folder 
    rm -R "$DIR"
    echo
    echo "  - Original files moved to Movie Library"

    # Post Processing as a Movie complete
    echo
    echo "  - The Movie is in your iTunes library ready to sync to your iPad"    
fi

#################
# TV Processing #
#################

if [ $CATEGORY == "tv" ]; then
    echo 
    echo "  - Processing as a TV Show"
    echo 
    
    # Stops error printing in loop if there are no video files in the folder
    shopt -s nullglob
    
#===============================================================================
# TV Shows Transcoding and Tagging
    cd "$DIR"
    
    # Use tvrenamer.pl to scrape the TV Episode name 
    tvrenamer.pl --unattended --gap=" - " --separator=" - " --pad=2 --include_series > /dev/null 2>&1
    echo "  - Renaming the file with tvrenamer.pl"
    echo
    
    # Regex expression parse Tag information from the filename
    # This parses information from the Job Name for tagging and file naming
    regex="^(.*) - ([[:digit:]]+)x([[:digit:]]+).* - (.*)$"
    
    for i in *.mkv *.avi *.m4v *.mp4 *.wmv *.iso *.img; do
    NAME=${i%.*}

    if [[ $CATEGORY -eq "tv" && $NAME =~ $regex ]]; then
    show_name=${BASH_REMATCH[1]}
    season=${BASH_REMATCH[2]}
    episode=${BASH_REMATCH[3]}
    episode_name=${BASH_REMATCH[4]}
    fi
    
    # Setting the variables for Destination File and Folder
    tv_dest_file=$show_name" - "$season"x"$episode" - "$episode_name".m4v"

    #TV Show original file destination
    #The line below contains a user defined location setting, change to where you want your processed files to go.
    postproc_dest_folder="/Volumes/Downloads/Usebin/TV/$show_name/Season $season/"

    # If there is already an M4V file stop
    if [[ -e "$tv_dest_folder$tv_dest_file" ]]; then
        echo "  - An M4V with the same name already exisits,"
        echo "  - skipping $i"
        continue
    fi

    
    # Convert the source video file to a preset M4V file using HandBrake
    HandBrakeCLI -i "$i" -o "$tv_dest_file" --preset="$tv_preset" > /dev/null 2>&1    
    # Note the " > /dev/null 2>&1" at the end of the line directs output from HandBrakeCLI away from the script log
    echo "  - Transcoding the TV Show"
    
    # If HandBrake did not exit gracefully, continue with next iteration
    if [[ $? -ne 0 ]]; then
    continue
    fi
    
    
#===============================================================================
# TV Show Artwork

    # Get artwork from epguides.com
    epguidesartwork=$(echo $show_name|sed 's/ *//g')
    wget http://epguides.com/$epguidesartwork/cast.jpg > /dev/null 2>&1
    echo "  - Retrieved Artwork from http://epguides.com"    
    
    # Add TV Show tagging information for iTunes using AtomicParsley: http://atomicparsley.sourceforge.net/
    # If Artwork is available locally for the show then this tags the show info and image
    if [[ -e $(find "$tvartwork" -maxdepth 1 -name "$show_name.jpg") ]]; then
    echo "  - Adding TV Show information and Artwork from Artwork folder"
    AtomicParsley "$tv_dest_file" --genre "TV Shows" --stik "TV Show" --TVShowName "$show_name" --TVEpisode "$episode_name" --TVEpisodeNum "$episode" --TVSeason "$season" --artwork "$tvartwork$show_name.jpg" --overWrite > /dev/null 2>&1

    # Add TV Show tagging information for iTunes using AtomicParsley: http://atomicparsley.sourceforge.net/
    # If Artwork is available from epguides.com then this tags the show info and image
    elif [[ -e $(find . -name "cast.jpg") ]]; then
    echo "  - Adding TV Show information and Artwork from epguides.com"
    AtomicParsley "$tv_dest_file" --genre "TV Shows" --stik "TV Show" --TVShowName "$show_name" --TVEpisode "$episode_name" --TVEpisodeNum "$episode" --TVSeason "$season" --artwork "cast.jpg" --overWrite > /dev/null 2>&1

    # Otherwise the tagging information minus the Artwork is added
    else
    echo "  - Adding TV Show information to the file for iTunes"
    AtomicParsley "$tv_dest_file" --genre "TV Shows" --stik "TV Show" --TVShowName "$show_name" --TVEpisode "$episode_name" --TVEpisodeNum "$episode" --TVSeason "$season" --overWrite > /dev/null 2>&1
    echo "  - Tag and rename completed"
    fi

    # Finding files and deleting any smaller than 30MB
    find "$DIR" -size -30720k -type f -exec rm {} \;
    echo
    echo "  - Deleted extraneous files"

    # Move the transcoded file to a folder which has folder actions set to input the file into iTunes
    mv "$tv_dest_file" "$tv_dest_folder"
    echo
    echo "  - Moved transcoded file to folder for Applescript to add into iTunes library"
    
    # Move the file to library for viewing in original format
    #mkdir -p "$postproc_dest_folder"; mv "$i" "$postproc_dest_folder$i"
    #echo
    #echo "  - Moved downloaded file to TV library for archive or viewing in original format"
    
    # Post Processing for TV Show complete
    echo
    echo "  - The TV Show is in your iTunes library ready to sync to your iPad."
    done
fi

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 4:11 pm
by th3joker
This is the sort string I used for TV:

%sn/Season %s/%sn - %sx%0e - %en.%ext

Is yours the same?

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 4:20 pm
by jwbp100
Not even close (!)
Retrying ...

Any particular string needed for mooovies?

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 4:56 pm
by th3joker
lol, well that just might cause it :-)

I used to have the string in the script for reference, I must have taken it out at some point during fiddling, my bad!!

I use this for Movies: %title (%y).%ext

Though it's not as important as the tagging on Movies doesn't require regex. In fact the tagging isn't as good for the Movies and I'd like to add the scraping function so that the final files have the nice images in iTunes too.

I use a watched folder to add the finished .m4v files into iTunes. Though that's only because my download system is Ubuntu. Randyharris has a nice Applescript section in his script to import it straight into iTunes.
Either way they get added anyway, but his method on an OSX system is by far the better way.

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 4:59 pm
by th3joker
I added the pattern sorting key into the script on the first page for reference.

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 5:28 pm
by th3joker
Did it work this time?

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 5:30 pm
by jwbp100
WooooT! etc.

Just did a little dance, it worked!
Now, it seems a little like the tvrenamer perl script may not have done a great deal ...

Code: Select all

+ NZB_FILE='Undercover Boss US S02E12 WS PDTV XviD 2HD.nzb'
+ NAME='Undercover Boss US S02E12 WS PDTV XviD 2HD'
+ NZB_ID=
+ CATEGORY=tv
+ GROUP=alt.binaries.multimedia
+ STATUS=0
+ '[' tv == movies ']'
+ '[' tv == tv ']'
+ echo

+ echo '  - Processing as a TV Show'
  - Processing as a TV Show
+ echo

+ shopt -s nullglob
+ cd '/Volumes/Downloads/Usebin/TV/Undercover Boss Us/Season 2'
+ tvrenamer.pl --unattended '--gap= - ' '--separator= - ' --pad=2 --include_series
+ echo '  - Renaming the file with tvrenamer.pl'
  - Renaming the file with tvrenamer.pl
+ echo

+ regex='^(.*) - ([[:digit:]]+)x([[:digit:]]+).* - (.*)$'
+ for i in '*.mkv' '*.avi' '*.m4v' '*.mp4' '*.wmv' '*.iso' '*.img'
+ NAME='Undercover Boss Us - 2x12 - WS PDTV XviD 2HD'
+ [[ tv -eq tv ]]
+ [[ Undercover Boss Us - 2x12 - WS PDTV XviD 2HD =~ ^(.*) - ([[:digit:]]+)x([[:digit:]]+).* - (.*)$ ]]
+ show_name='Undercover Boss Us'
+ season=2
+ episode=12
+ episode_name='WS PDTV XviD 2HD'
+ tv_dest_file='Undercover Boss Us - 2x12 - WS PDTV XviD 2HD.m4v'
... in fact it appears that it wasn't renamed at all!

I've removed the > /dev/null 2>&1 from the tvrenamer.pl call and I'll see what goes on - could just be the series was a bit too obscure(?)

Have you had a look at this bad boy?
https://github.com/dbr/tvnamer
Does rather a nice job of renaming, and includes a few nicities like recursive file management - tidys up a TV downloads folder like Mr Muscle on heat!

Code: Select all

####################
# Processing file: Undercover Boss Us - 2x12 - WS PDTV XviD 2HD.m4v
# Detected series: Undercover Boss Us (season: 2, episode: 12)
####################
Old filename: Undercover Boss Us - 2x12 - WS PDTV XviD 2HD.m4v
New filename: Undercover Boss (US) - [02x12] - Norwegian Cruise Line.m4v

####################
# Done

Seems to do rather a nice job, may see if I can convince it to work with your beauty!

Thanks again for all your help mate, much appreciated.

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 5:41 pm
by th3joker
Undercover Boss doesn't show up in epguides.com

More specifically at the url http://epguides.com/undercoverbossus which is how it parses, it's basically a mismatch in the naming conventions which only very rarely happens to me.

Seems to happen when the names are a bit odd, it's funny that it happened here because normally with all the mainstream stuff there's never any problems.

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 5:51 pm
by th3joker
I looked at tvnamer and it works for that file when tvrenamer.pl didn't so I'll be switching it for your suggestion.

I just need to get it to return like this:
Undercover Boss (US) - 02x12 - Norwegian Cruise Line


As currently it returns like this:
Undercover Boss (US) - [02x12] - Norwegian Cruise Line

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 3rd, 2011, 6:29 pm
by th3joker
It takes a little more configuration and some changes.

I like it but it does complicate the script a little more.

However it would be easy to swap out the tvrenamer.pl for this if you know what you're doing.

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 4th, 2011, 3:38 am
by jwbp100
Ok, going to far so well (ish, when you're fumbling in the dark!).
tvnamer --config=/path/to/mytvnamerconfig.json created a config file for tvnamer to look at.

In your script tvnamer --config=/usr/bin/mytvnamerconfig.json "$DIR" replaced your tvrename.pl line.
But as you said you need to get the format right for the regex to recognise it. I've managed to change this (I think!) in the config script below.

Code: Select all

{
    "always_rename": false, 
    "batch": true, 
    "custom_filename_character_blacklist": "", 
    "episode_separator": "-", 
    "episode_single": "%d", 
    "filename_patterns": [
        "^\\[.+?\\][ ]? # group name\n        (?P<seriesname>.*?)[ ]?[-_][ ]?          # show name, padding, spaces?\n        (?P<episodenumberstart>\\d+)              # first episode number\n        ([-_]\\d+)*                               # optional repeating episodes\n        [-_](?P<episodenumberend>\\d+)            # last episode number\n        [^\\/]*$", 
        "^\\[.+?\\][ ]? # group name\n        (?P<seriesname>.*) # show name\n        [ ]?[-_][ ]?(?P<episodenumber>\\d+)\n        [^\\/]*$", 
        "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        [Ss](?P<seasonnumber>[0-9]+)             # s01\n        [\\.\\- ]?                                 # separator\n        [Ee](?P<episodenumberstart>[0-9]+)       # first e23\n        ([\\.\\- ]+                                # separator\n        [Ss](?P=seasonnumber)                    # s01\n        [\\.\\- ]?                                 # separator\n        [Ee][0-9]+)*                             # e24 etc (middle groups)\n        ([\\.\\- ]+                                # separator\n        [Ss](?P=seasonnumber)                    # last s01\n        [\\.\\- ]?                                 # separator\n        [Ee](?P<episodenumberend>[0-9]+))        # final episode number\n        [^\\/]*$", 
        "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        [Ss](?P<seasonnumber>[0-9]+)             # s01\n        [\\.\\- ]?                                 # separator\n        [Ee](?P<episodenumberstart>[0-9]+)       # first e23\n        ([\\.\\- ]?                                # separator\n        [Ee][0-9]+)*                             # e24e25 etc\n        [\\.\\- ]?[Ee](?P<episodenumberend>[0-9]+) # final episode num\n        [^\\/]*$", 
        "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        (?P<seasonnumber>[0-9]+)                 # first season number (1)\n        [xX](?P<episodenumberstart>[0-9]+)       # first episode (x23)\n        ([ \\._\\-]+                               # separator\n        (?P=seasonnumber)                        # more season numbers (1)\n        [xX][0-9]+)*                             # more episode numbers (x24)\n        ([ \\._\\-]+                               # separator\n        (?P=seasonnumber)                        # last season number (1)\n        [xX](?P<episodenumberend>[0-9]+))        # last episode number (x25)\n        [^\\/]*$", 
        "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        (?P<seasonnumber>[0-9]+)                 # 1\n        [xX](?P<episodenumberstart>[0-9]+)       # first x23\n        ([xX][0-9]+)*                            # x24x25 etc\n        [xX](?P<episodenumberend>[0-9]+)         # final episode num\n        [^\\/]*$", 
        "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        [Ss](?P<seasonnumber>[0-9]+)             # s01\n        [\\.\\- ]?                                 # separator\n        [Ee](?P<episodenumberstart>[0-9]+)       # first e23\n        (                                        # -24 etc\n             [\\-]\n             [Ee]?[0-9]+\n        )*\n             [\\-]                                # separator\n             [Ee]?(?P<episodenumberend>[0-9]+)   # final episode num\n        [\\.\\- ]                                  # must have a separator (prevents s01e01-720p from being 720 episodes)\n        [^\\/]*$", 
        "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        (?P<seasonnumber>[0-9]+)                 # 1\n        [xX](?P<episodenumberstart>[0-9]+)       # first x23\n        (                                        # -24 etc\n             [\\-][0-9]+\n        )*\n             [\\-]                                # separator\n             (?P<episodenumberend>[0-9]+)        # final episode num\n        ([\\.\\- ].*                               # must have a separator (prevents 1x01-720p from being 720 episodes)\n        |\n        $)", 
        "^(?P<seriesname>.+?)[ \\._\\-]          # show name and padding\n        \\[                                       # [\n            ?(?P<seasonnumber>[0-9]+)            # season\n        [xX]                                     # x\n            (?P<episodenumberstart>[0-9]+)       # episode\n            (- [0-9]+)*\n        -                                        # -\n            (?P<episodenumberend>[0-9]+)         # episode\n        \\]                                       # \\]\n        [^\\/]*$", 
        "^(?P<seriesname>.+?)[ \\._\\-]\n        [Ss](?P<seasonnumber>[0-9]{2})\n        [\\.\\- ]?\n        (?P<episodenumber>[0-9]{2})\n        [^0-9]*$", 
        "^((?P<seriesname>.+?)[ \\._\\-])?       # show name and padding\n        \\[?                                      # [ optional\n        (?P<seasonnumber>[0-9]+)                 # season\n        [xX]                                     # x\n        (?P<episodenumber>[0-9]+)                # episode\n        \\]?                                      # ] optional\n        [^\\/]*$", 
        "^((?P<seriesname>.+?)[ \\._\\-])?\n        \\[?\n        [Ss](?P<seasonnumber>[0-9]+)[\\.\\- ]?\n        [Ee]?(?P<episodenumber>[0-9]+)\n        \\]?\n        [^\\/]*$", 
        "\n        ^((?P<seriesname>.+?)[ \\._\\-])?          # show name\n        (?P<year>\\d{4})                          # year\n        [ \\._\\-]                                 # separator\n        (?P<month>\\d{2})                         # month\n        [ \\._\\-]                                 # separator\n        (?P<day>\\d{2})                           # day\n        [^\\/]*$", 
        "^(?P<seriesname>.+?)[ ]?[ \\._\\-][ ]?\n        [Ss](?P<seasonnumber>[0-9]+)[\\.\\- ]?\n        [Ee]?[ ]?(?P<episodenumber>[0-9]+)\n        [^\\/]*$", 
        "\n        (?P<seriesname>.+)                       # Showname\n        [ ]-[ ]                                  # -\n        [Ee]pisode[ ]\\d+                         # Episode 1234 (ignored)\n        [ ]\n        \\[                                       # [\n        [sS][ ]?(?P<seasonnumber>\\d+)            # s 12\n        ([ ]|[ ]-[ ]|-)                          # space, or -\n        ([eE]|[eE]p)[ ]?(?P<episodenumber>\\d+)   # e or ep 12\n        \\]                                       # ]\n        .*$                                      # rest of file\n        ", 
        "^(?P<seriesname>.+?)                  # Show name\n        [ \\._\\-]                                 # Padding\n        (?P<episodenumber>[0-9]+)                # 2\n        of                                       # of\n        [ \\._\\-]?                                # Padding\n        \\d+                                      # 6\n        ([\\._ -]|$|[^\\/]*$)                     # More padding, then anything\n        ", 
        "^(?P<seriesname>.+)[ \\._\\-]\n        (?P<seasonnumber>[0-9]{1})\n        (?P<episodenumber>[0-9]{2})\n        [\\._ -][^\\/]*$", 
        "^(?P<seriesname>.+)[ \\._\\-]\n        (?P<seasonnumber>[0-9]{2})\n        (?P<episodenumber>[0-9]{2,3})\n        [\\._ -][^\\/]*$", 
        "^(?P<seriesname>.+?)                  # Show name\n        [ \\._\\-]                                 # Padding\n        [Ee](?P<episodenumber>[0-9]+)            # E123\n        [\\._ -][^\\/]*$                          # More padding, then anything\n        "
    ], 
    "filename_with_date_and_episode": "%(seriesname)s - %(episode)s - %(episodename)s%(ext)s", 
    "filename_with_date_without_episode": "%(seriesname)s - %(episode)s%(ext)s", 
    "filename_with_episode": "%(seriesname)s - %(seasonno)dx%(episode)s - %(episodename)s%(ext)s", 
    "filename_with_episode_no_season": "%(seriesname)s - %(episode)s - %(episodename)s%(ext)s", 
    "filename_without_episode": "%(seriesname)s - %(seasonno)dx%(episode)s%(ext)s", 
    "filename_without_episode_no_season": "%(seriesname)s - %(episode)s%(ext)s", 
    "input_filename_replacements": [], 
    "language": "en", 
    "lowercase_filename": false, 
    "move_files_confirmation": true, 
    "move_files_destination": ".", 
    "move_files_enable": false, 
    "move_files_fullpath_replacements": [], 
    "multiep_join_name_with": ", ", 
    "normalize_unicode_filenames": false, 
    "output_filename_replacements": [], 
    "recursive": false, 
    "replace_invalid_characters_with": "_", 
    "search_all_languages": true, 
    "select_first": false, 
    "skip_file_on_error": true, 
    "valid_extensions": [], 
    "verbose": false, 
    "windows_safe_filenames": false
}
Seems to work so far.

Code: Select all

+ shopt -s nullglob
+ cd '/Volumes/Downloads/Usebin/TV/Shaun the Sheep/Season 3'
+ tvnamer --config=/usr/bin/mytvnamerconfig.json '/Volumes/Downloads/Usebin/TV/Shaun the Sheep/Season 3'
Loading config: /usr/bin/mytvnamerconfig.json
####################
# Starting tvnamer
# Found 1 episode
####################
# Processing file: Shaun the Sheep - 3x8 - HDTV XviD aAF.avi
# Detected series: Shaun the Sheep (season: 3, episode: 8)
####################
Old filename: Shaun the Sheep - 3x8 - HDTV XviD aAF.avi
New filename: Shaun the Sheep - 3x8 - Bagpipe Buddy.avi

####################
# Done
+ echo '  - Renaming the file with tvrenamer.pl'
  - Renaming the file with tvrenamer.pl
+ echo

+ regex='^(.*) - ([[:digit:]]+)x([[:digit:]]+).* - (.*)$'
+ for i in '*.mkv' '*.avi' '*.m4v' '*.mp4' '*.wmv' '*.iso' '*.img'
+ NAME='Shaun the Sheep - 3x8 - Bagpipe Buddy'
+ [[ tv -eq tv ]]
+ [[ Shaun the Sheep - 3x8 - Bagpipe Buddy =~ ^(.*) - ([[:digit:]]+)x([[:digit:]]+).* - (.*)$ ]]
+ show_name='Shaun the Sheep'
+ season=3
+ episode=8
+ episode_name='Bagpipe Buddy'
+ tv_dest_file='Shaun the Sheep - 3x8 - Bagpipe Buddy.m4v'
+ postproc_dest_folder='/Volumes/Downloads/Usebin/TV/Shaun the Sheep/Season 3/'
+ [[ -e /Volumes/Downloads/Usebin/TV/Shaun the Sheep - 3x8 - Bagpipe Buddy.m4v ]]
+ HandBrakeCLI -i 'Shaun the Sheep - 3x8 - Bagpipe Buddy.avi' -o 'Shaun the Sheep - 3x8 - Bagpipe Buddy.m4v' '' '-f mp4 -Y 480 -e x264 -b 2048 -a 1 -E faac -6 stereo -R 48 -B 160 -D 0.0 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v 1'
Invalid output format ( mp4 -Y 480 -e x264 -b 2048 -a 1 -E faac -6 stereo -R 48 -B 160 -D 0.0 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v 1). Possible choices are mp4, m4v and mkv
.+ echo '  - Transcoding the TV Show'
  - Transcoding the TV Show
I've broken Handbrake though by trying to insert customness instead of your presets however. Working on that one when I get home from work later. :)

PS, one thing I've changed is I've removed the padding (1 not 01) from SABnzbd's settings and the same in the tvnamer config for the episode and season numbers. Reckon this will break much?

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: January 4th, 2011, 7:21 am
by th3joker
Changing the padding should be fine but if you download something with season 10 or above it can cause problems.

Have a look at the Randyharris script it's very similar but Mac specific without the atomicparsley and artwork tagging.

His has a cool dual conversion option so you can have one Apple TV file and one iPhone file as an example.

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Automatically for iTunes

Posted: May 9th, 2011, 10:32 pm
by sonicman
Hey dude you still around?



sonicman

Re: Convert to iPad/iPod/iPhone/AppTV add Artwork & Tag Auto

Posted: December 28th, 2011, 1:01 pm
by ketaset
Any way to make this script work on SABNZBD+ for windows?