Scripting Quicktime

I’m trying to create reference movies (as Quicktime .MOV documents) for all of the movies on my Media server, and the most obvious method is to use AppleScript and Quicktime Player. Why am I doing this? Because iTunes requires Quicktime Movies, I’ve mainly got AVIs, and I don’t want to (a) convert all of them, and (b) have iTunes manage them. I’d rather have the files in the right spot, and allow iTunes to manage the reference movies. Quicktime will often open files of varying types, even though iTunes will not. It’s then possible to save the file, and choose not to create a stand-alone movie. This will create a reference movie, which is much smaller than the original, but requires that the original remains in the same place in order to work. However, using AppleScript, the following will not work if AVIs are set to play in another player, like VLC:

1    tell application "Finder"
2    	set theMovies to selection
3    end tell
4    
5    repeat with theMovie in theMovies
6    	tell application "QuickTime Player"
7    		open theMovie
8    	end tell
9    end repeat

That is, the movie opens in it’s default application. To get it to work requires simply the following:

1    tell application "Finder"
2    	set theMovies to selection
3    end tell
4    
5    repeat with theMovie in theMovies
6    	tell application "QuickTime Player"
7    		open theMovie as alias
8    	end tell
9    end repeat

That little as alias causes Quicktime to open it, instead of VLC. How bizarre! The next problem is that by default, it puts the document(s) into a list. I often make the mistake of operating on a list, rather than each item individually. Especially when there’s only one item in the list. It’s like my eyes don’t see the curly brackets. So, we can save the movie, and by default it will save it as a reference movie. Next problem, how do we tell it where to save the movie? It will default to the root directory of the boot disk. Not really where I want to save this file, as I want to do multiple copies. But, what I can do is save the file, import it into iTunes, (ensuring that iTunes creates a copy of this file in it’s library) and then delete the file, or create the next one over the top. What I’m up to so far (and this doesn’t deal with names or anything yet):

 1    tell application "Finder"
 2    	set theMovies to selection
 3    end tell
 4    
 5    repeat with theMovie in theMovies
 6    
 7    	tell application "QuickTime Player"
 8    		set mov to first item of (open theMovie as alias)
 9    		save mov in (file "movie.mov")
10    		close mov
11    	end tell
12        
13    	tell application "iTunes"
14    		add alias "Macintosh HD:movie.mov"
15    	end tell
16        
17    end repeat

More later. Sleep time now.

Rounding Ratings

I like that iTunes displays half-star ratings, but I want my tracks rated 51-59 to display this way too. That doesn’t work, but if you use the following script, it will round the ratings of selected tracks to the nearest half-star:

1    tell application "iTunes"
2    	repeat with trk in selection
3    		set rating of trk to ((rating of trk) / 10 as integer) * 10
4    	end repeat
5    end tell

I hope Apple don’t include the functionality of odd-rated tracks to play different amounts, otherwise I’ll need to re-rate all of my music. Again.

Monkey! Remake

[BBC NEWS World Asia-Pacific Monkey magic casts spell in Asia]1 Hot on the heels of the news of the Dark Crystal remake, comes this, an announcement that a Japanese company is redoing Monkey!, the tale of a priest and his companions, Monkey, Pigsy and Sandy as they travel across China to India in search of the Buddha’s Scrolls. It’s one of my all-time favourite shows (I now have the complete set, including the dozen or so that were never shown on Australian TV). I’ve read the original book, or rather a translation, written by Wu-chèn Eng, and can sagely say (that was supposed to be safely, but I like the typo) that the original TV series was true to the story. I hope the new one is.