Has anyone made any OS X scripts that convert downloaded movies/shows to iPhone format using HandBrake?
I'm not very good at scripting so I don't know where/how to start by making my own....
OS X + HandBrake + Convert to iPhone
-
- Jr. Member
- Posts: 59
- Joined: March 2nd, 2009, 10:58 am
- Contact:
Re: OS X + HandBrake + Convert to iPhone
Hi,
I'm not that good at scripting but I managed to do a script which convert my tv show files, tag them, and add them to iTunes.
My file are named like this : Serie - 1x01 - Title.avi
based on that here's the script:
I'm not that good at scripting but I managed to do a script which convert my tv show files, tag them, and add them to iTunes.
My file are named like this : Serie - 1x01 - Title.avi
based on that here's the script:
Code: Select all
dirname=$1
filename=$3
tag_filename_split=$filename
# I save the tagged file and delete them later in case anything goes wrong during the process.
dir_tag="path/to/save/tagged/files"
#I save the original file and delete them manually in case anything goes wrong during the process.
savepath="path/to/save/original/files"
#here's the conversion:
#You can change the conversion presets according to handbrake docs.
HandBrakeCLI -i "$dirname/$filename.avi" -o "$dirname/$filename.mp4"
mv -fv "$dirname/$filename.avi" "$savepath/"
#as all the informations to tag the file are present in the filename we need to extract them
tag_filename_split=`echo $tag_filename_split | awk '{
n = split ( $0, a, " - " )
for ( i = 1; i <= n; i++ ) {
printf("%s:", a[ i ] );
}
#the title of the show
show=`echo $tag_filename_split | awk -F: '{print $1}'`
#the season and episode of the episode
seasonepisode=`echo $tag_filename_split | awk -F: '{print $2}'`
#the season of the episode
season=`echo $seasonepisode | awk -Fx '{print $1}'`
#the number of the episode
episode=`echo $seasonepisode | awk -Fx '{print $2}'`
#the title of the episode
title=`echo $tag_filename_split | awk -F: '{print $3}'`
}'`
#here's I tag the file converted file using AtomicParsley:
AtomicParsley "$dirname/$filename.mp4" --genre "TV Shows" --stik "TV Show" --title "$title" --TVShowName "$show" --TVEpisode "$season$episode" --TVEpisodeNum "$episode" --TVSeason "$season" --output "$dir_tag/$filename.mp4"
# I delete the not tagged mp4 file
rm -fv "$dirname/$filename.mp4"
#Then I add the tagged file to iTunes using AppleScript:
osascript << EOT
tell application "iTunes"
set posix_path to "$dir_tag/$filename.mp4"
set mac_path to posix_path as POSIX file
add mac_path to library playlist 1
end tell
EOT
# I delete the tagged file as iTunes copies the file to the proper library folder.
rm -fv "$dir_tag/$filename.mp4"
-
- Jr. Member
- Posts: 59
- Joined: March 2nd, 2009, 10:58 am
- Contact:
Re: OS X + HandBrake + Convert to iPhone
Does the script work for you? I keep getting an error:engine9 wrote: Hi,
I'm not that good at scripting but I managed to do a script which convert my tv show files, tag them, and add them to iTunes.
My file are named like this : Serie - 1x01 - Title.avi
based on that here's the script:
Code: Select all
dirname=$1 filename=$3 tag_filename_split=$filename # I save the tagged file and delete them later in case anything goes wrong during the process. dir_tag="path/to/save/tagged/files" #I save the original file and delete them manually in case anything goes wrong during the process. savepath="path/to/save/original/files" #here's the conversion: #You can change the conversion presets according to handbrake docs. HandBrakeCLI -i "$dirname/$filename.avi" -o "$dirname/$filename.mp4" mv -fv "$dirname/$filename.avi" "$savepath/" #as all the informations to tag the file are present in the filename we need to extract them tag_filename_split=`echo $tag_filename_split | awk '{ n = split ( $0, a, " - " ) for ( i = 1; i <= n; i++ ) { printf("%s:", a[ i ] ); } #the title of the show show=`echo $tag_filename_split | awk -F: '{print $1}'` #the season and episode of the episode seasonepisode=`echo $tag_filename_split | awk -F: '{print $2}'` #the season of the episode season=`echo $seasonepisode | awk -Fx '{print $1}'` #the number of the episode episode=`echo $seasonepisode | awk -Fx '{print $2}'` #the title of the episode title=`echo $tag_filename_split | awk -F: '{print $3}'` }'` #here's I tag the file converted file using AtomicParsley: AtomicParsley "$dirname/$filename.mp4" --genre "TV Shows" --stik "TV Show" --title "$title" --TVShowName "$show" --TVEpisode "$season$episode" --TVEpisodeNum "$episode" --TVSeason "$season" --output "$dir_tag/$filename.mp4" # I delete the not tagged mp4 file rm -fv "$dirname/$filename.mp4" #Then I add the tagged file to iTunes using AppleScript: osascript << EOT tell application "iTunes" set posix_path to "$dir_tag/$filename.mp4" set mac_path to posix_path as POSIX file add mac_path to library playlist 1 end tell EOT # I delete the tagged file as iTunes copies the file to the proper library folder. rm -fv "$dir_tag/$filename.mp4"
Code: Select all
168:180: execution error: iTunes got an error: Can’t make some data into the expected type. (-1700)
-
- Jr. Member
- Posts: 59
- Joined: March 2nd, 2009, 10:58 am
- Contact:
Re: OS X + HandBrake + Convert to iPhone
I think I fixed it. I was missing a "/" on the set posix_path to "$DIR/${i%.*}.mp4" line.
-
- Full Member
- Posts: 146
- Joined: January 21st, 2010, 5:36 pm
Re: OS X + HandBrake + Convert to iPhone
Can this code be updated so that it converts either AVI or MKV?imthenachoman wrote: I think I fixed it. I was missing a "/" on the set posix_path to "$DIR/${i%.*}.mp4" line.
Thanks
-
- Jr. Member
- Posts: 59
- Joined: March 2nd, 2009, 10:58 am
- Contact:
Re: OS X + HandBrake + Convert to iPhone
http://forums.sabnzbd.org/http://forums ... 175#p25175
I updated it a while ago. Should work with avi and mkv. Converts to iPhone and adds season, episode information in iTunes. Let me know what you think...
I updated it a while ago. Should work with avi and mkv. Converts to iPhone and adds season, episode information in iTunes. Let me know what you think...
-
- Jr. Member
- Posts: 59
- Joined: March 2nd, 2009, 10:58 am
- Contact:
Re: OS X + HandBrake + Convert to iPhone
Locked per request, see: http://forums.sabnzbd.org/index.php?topic=3562.0