October 18, 2017, 10:45:05 pm
News:
Pages: [1]
Print
Author Topic: Applescript to add shows to iTunes  (Read 8530 times)
bagster
Sr. Member
****
Posts: 270


View Profile
« on: September 21, 2007, 12:16:03 pm »

I wrote a small applescript to add shows to iTunes, and change the metadatas in the file so it will be cleaner in iTunes (I tag everything as a TV Show).
Just insert this in the script editor, save it to /Library/Scripts/Folder Actions Scripts, and add a folder action on a specific folder (I use Movies/OSD shows).
You need to download AtomicParsley and copy the binary somewhere in your path.
====================
-- Script to add shows from OSD to iTunes, v0.1
-- Yves Pelletier (pelletiy AT gmail DOT com), september 21 2007
--
-- Put AtomicParsley somewhere in your PATH, or hardcode the path in this script
-- Add a folder action with this script on the place you will move your shows
-- You can edit/add shows in the TRAP EXCEPTION section.
--
-- ************************* BIG WARNING ************************
-- With this version, don't use the same folder for the folder action and
-- the place where you record show.  AtomicparSley is called with a --overWrite,
-- so if you try it on a show that is in recording state, it will be corrupted
-- ************************* BIG WARNING ************************
--
-- TODO
-- 1) Find a clean way to wait for "in-progress" shows
-- 2) Auto-convert to H264 (ffmpeg) (to save space)
-- 3) Check the metadatas and don't modify them if they are not empty
-- 4) Listen these shows!

property atomize : 0
property showType : 10 -- --stik  (10 = TV show, 0 = movie)

on adding folder items to thisFolder after receiving theseFiles
   tell application "Finder"
      repeat with thisFile in theseFiles
         
         (* Ignore files containint -temp-, these are atomicparsley temp files *)
         set showfileName to name of (info for thisFile)
         if showfileName contains "temp" or showfileName contains "tmp" then
            display dialog "Ignoring temp file"
         else
            set showID to "" -- To allow show.mp4 without ID field
            set unixPATH to POSIX path of thisFile
            set showType to "TV Show"
            
            (* Get the show name *)
            set fileName to (name of thisFile as string)
            
            (* get the name of the recording.  First we remove .mp4 *)
            set ASTID to AppleScript's text item delimiters
            set AppleScript's text item delimiters to ".mp4"
            set newName to (text item 1 of fileName) as text
            set AppleScript's text item delimiters to "-"
            if newName contains "-" then
               set showName to (text item 1 of newName) as text
               set showID to (text item 2 of newName) as text
               set AppleScript's text item delimiters to ASTID
            else
               set showName to (text item 1 of newName) as text
               set AppleScript's text item delimiters to ASTID
            end if
            
            (* Now trap exceptions *)
            if showName is "candice" then
               set showName to "Candice Olson"
            else if showName is "bye" then
               set showName to "Bye bye maison"
            else if showName is "vie" then
               set showName to "Decore ta vie"
            end if
            
            display dialog "Adding Show: " & showName
            
            (* Get the show date *)
            set showDate to modification date of (info for thisFile)
            
            (* Atomize it *)
            set atomSH to "AtomicParsley \"" & unixPATH & "\" --stik \"" & showType & "\" --TVShowName \"" & showName & "\" --comment \"" & showDate & "\" --overWrite "
            -- display dialog atomSH
            try
               do shell script atomSH
            end try
            
            (* Add it to iTunes *)
            tell application "iTunes"
               copy (add thisFile) to newTrack
            end tell
         end if
      end repeat
   end tell
end adding folder items to
« Last Edit: September 21, 2007, 12:37:06 pm by bagster » Logged
FJ
Neuros Team
Administrator
Hero Member
*****
Posts: 745


View Profile
« Reply #1 on: October 21, 2007, 12:16:26 pm »

Bagster-

Did you send this to our team, this is a great app. I would personally take out the step to reencode using h.264 for playback compatibility issues (only the PSP and the iPod can play back h.264).
Logged

FJ
bagster
Sr. Member
****
Posts: 270


View Profile
« Reply #2 on: October 22, 2007, 08:28:59 am »

Yes, I sent it on the dev. forum and it was linked http://open.neurostechnology.com.
If anyone have suggestions for improvment, let me know.
Logged
Pages: [1]
Print
Jump to: