Jump to content

Movie torrent to reference to iTunes script


mlmorg
 Share

3 posts in this topic

Recommended Posts

Hey all,

I've been trying to do an automator/applescript program that will attach as a plugin to my downloaded torrents folder and am having some troubles.

 

What I want to do is once a movie torrent is downloaded and is transferred to my Movies folder on my external drive I want this applescript script to act on it:

 

on open ml_movie

set my_location to (path to desktop) as text

tell application "QuickTime Player"

launch

close every document

open ml_movie

set movie_name to name of document 1

set save_location to my_location & movie_name & ".mov"

save document 1 in save_location

close document 1

quit

end tell

set movie_reference to save_location

tell application "iTunes"

launch

add movie_reference to playlist "Library" of source "Library"

delay 3

quit

end tell

tell application "Finder"

delete file movie_reference

end tell

end open

 

That script basically takes the movie file and saves a copy of it as a reference file which it then adds to itunes. No problems there, the script works fine except for the fact that it adds the extension .mov when i would like to replace the .avi ext of the movie to the .mov extension of the new reference file but whatever no big deal.

 

The problem I'm having is with Automator. I have automator set up to "Find Finder Items" in my Movies folder that were "created Today" and are of the "movie type." If those things prove true, it acts on the file/files with the Applescript application above.

 

But, obviously it will try to act on that same file/files continuously for the entire day...until the "created Today" aspect is no longer applicable.

 

How can I change it so that it will do what it's doing but WILL NOT act on the same file more than once?

 

Thanks for any help,

Matt

 

Also could there be a problem where the automator will act on the movie file before it has been transferred over to the Movies folder completely? I have transmission set up so that while it's downloading, the file is on the main hard drive in a Downloading folder. But once it has completed, transmission moves the file to the Movies folder which is on an external drive. Will the automator script, since it will be a plug-in acting on the Movies folder, act on the movie file before it has finished transferring from the main drive to the external? or will automator know to wait until it has finished?

Link to comment
Share on other sites

OK, open up Automator and under the Finder menu, set up your process with "copy Finder items" and set the destination to wherever you want it to go.

 

After this, drag "Open Finder Items" and force it to open in iTunes with the drop down menu.

 

Of course by default, iTunes makes a copy, so I'm wondering why the third copy is needed. Also, iTunes tends to think that you're going to want it converted from avi.

Link to comment
Share on other sites

I don't quite understand you but I think the problem is you misunderstood me...

 

So i have torrents that download through Transmission. While they are downloading, the files are located in a Downloading folder on my main drive. When they finish downloading, Transmission sends them to my Movies folder which is on an external drive.

 

What I would like to do is make a script that notices newly created folders/files in my Movies folder and then acts upon them by finding the .avi file and then opening that with my script which I showed above that creates a reference and then imports the reference into itunes.

 

The problem I'm having is not in importing the files into itunes, my script takes care of that. The problem I'm having is finding a way in Automator to make it act on newly created files in a folder and then open them with my script ONLY ONCE.

 

I'm afraid that if I create a Folder Action plugin in Automator (that is acting on my Movies folder) and have it "Find Finder Files that have been created Today" and are of the "Movie Type," that Automator will continue to act on that file FOR THE ENTIRE DAY until the "created today" attribute is no longer relevant.

 

Another way I thought I could get around that was have Transmission move the downloaded files not to the Movies folder, but to a "Processing" Folder that has an Automator plugin acting upon that folder so that whenever a new file gets put into that folder it "Gets the Finder Items" "Moves the finder items to the Movies folder" on my external Then "looks into the folders contents" that it just moved and then "Filters files of the .avi file extension" and then acts on those files by "opening them with my script."

 

The problem with that is it didn't seem to work, When I moved a folder (with a movie inside the folder) into the Processing folder, it started to move the folder and contents to my external but stopped prematurely (the movie was 300MB large and it only moved 5MB of it). And then the rest of the automator script never ran. Don't know why that screwed up.

 

Hopefully this makes more sense. But basically I'm trying to make Automator open up newly created/downloaded movies (in a folder that has many movies) and act upon it with my script (above) ONLY ONCE and doesn't continue to act upon that movie file for the entire day.

 

Thanks, Matt

 

**edit**

 

I think I'm looking for something like this "Wait for Finder Items" action for Automator:

 

http://www.automatedworkflows.com/software...ons/finder.html

 

I want some sort of script that will act as a plug in for a folder and when a folder (with a movie file) gets moved to that folder, the script waits for the folder and its contents to finish moving...and then acts on JUST that movie file and no other file with the script I already created.

Link to comment
Share on other sites

 Share

×
×
  • Create New...