Mac Help Forums


Reply
Thread Tools Display Modes

Help with iTunes related automation

 
Member
Join Date: Aug 2011
Posts: 19
 
      13th August 2011
Ok, I will try to be specific and explain as best I can what I am trying to do, but the bottom line is I am looking for help in doing it.

Basically, I want to be able to organize my movies in iTunes in a specific way that uses IMDb data.

Every movie in my iTunes has the last part of the corresponding IMDb URL in the comments section (ie. tt0154506). I need automator to find that information for each specific title and retrieve data from the /ratings page of each URL to be used in the following equation.
The data required is the Total Votes, the Overall Rating and My Rating.

(Total Votes/(Total Votes+3000)*(((Overall Rating*2.46)+My Rating)/3.46)+(3000/(Total Votes+3000))*6.9)*1000000 = X

I then want the the 'Sort Name' field of each title in iTunes to be replaced with 'X'

If this is even possible, and I have a feeling it probably isn't, I would love for someone to help in making a workflow.

Thanks
 
Reply With Quote
 
 
 
 
Senior Member
Kaveman's Avatar
Join Date: Nov 2010
Location: Westland, NZ
Posts: 1,355
 
      13th August 2011
This could be done with AppleScript, but its not trivial.

If you want mentoring you could PM me for more information.
 
Reply With Quote
 
Senior Member
Kaveman's Avatar
Join Date: Nov 2010
Location: Westland, NZ
Posts: 1,355
 
      20th August 2011
Ok, a news update.
Endlin3 and I have talked about this in PM and we are going to do this in steps here for everyone to follow along and ask questions. As a professional programmer I do this for money:-) so if you get something worthwhile from this thread I encourage you to donate both to this forum and myself.

When this thread error 500s we'll move to the AppleScript section.

Note: The scripts I post here will be focused on core functionality, if I were producing commercial code there would be all manner of error checking and handling. Not here, as that code would swamp the lessons. So all these scripts are supplied AS IS, with no warranty or guaranty, you use these AT YOUR OWN RISK!
 
Reply With Quote
 
Senior Member
Kaveman's Avatar
Join Date: Nov 2010
Location: Westland, NZ
Posts: 1,355
 
      20th August 2011
Lets start by checking those IMDb tags we've been putting in our comments.

Code:
tell application "iTunes"
	-- set holdURL to make new document with properties {URL:"http://www.imdb.com/find?s=all&q=sucker+punch"}
	set holdSelectedMovies to selection
	if holdSelectedMovies is not {} then
		set holdFrontOfSearch to "http://www.imdb.com/find?s=all&q="
		repeat with holdTrack in holdSelectedMovies
			set holdEndSearch to comment of holdTrack
			if holdEndSearch is not "" then
				set holdAllSearch to holdFrontOfSearch & holdEndSearch
				tell application "Safari"
					set holdURL to make new document with properties {URL:holdAllSearch}
				end tell
			end if
		end repeat
	end if
end tell
This gets the tag from the selected iTunes make a URL and open it in Safari.

Do we need instructions on how to make a Scripts folder in ~/Library/iTunes. Copy this into AppleScript Editor and save it into the Scripts folder?
 
Reply With Quote
 
Member
Join Date: Aug 2011
Posts: 19
 
      20th August 2011
Ok, so I made a folder in the /Library/iTunes folder and saved the script above to there, is it supposed to do anything at the moment? or is this just the beginning?
 
Reply With Quote
 
Senior Member
Kaveman's Avatar
Join Date: Nov 2010
Location: Westland, NZ
Posts: 1,355
 
      20th August 2011
If you have entered the IMDb number in the comments field, select the movie in iTunes, running this script will open the page in Safari.

Lets have a closer look:
1: Tell iTunes we want it to do things
2: put the current selection into the List holdSelectedMovies
3: if there are some selections proceed, check its not an empty list
4: Load the Front part the of the IMDb search URL
5: Repeat for each movie in the selection
6: Set the EndSearch to the comment field from the Movie in holdTrack
7: Check that there is a comment to proceed with
8: Join the Front part of the URL to the End bit from the comment field
9: Talk to Safari
10: Make a new Safari document with the URL, this will open a window and display it.
11 - End: End all the Ifs, Repeats, Tells
 
Reply With Quote
 
Senior Member
Kaveman's Avatar
Join Date: Nov 2010
Location: Westland, NZ
Posts: 1,355
 
      20th August 2011
This is just a first step. Its a test script. It's always good to know the data we're working with in the comments field is the correct IMDb search key. If this doesn't open the IMDb web page we have a problem.
 
Reply With Quote
 
Member
Join Date: Aug 2011
Posts: 19
 
      20th August 2011
I see, yeah, when I run it it opens the url of the IMDb page in safari, but it opens each one in a different window so if u select 19 like i did, you get 19 windows pop up. But, will that matter if this is just a test, as I take it when it's done you won't actually see the window it's taking data from, it'll just do it in the background right? Sort of like a 'click-a-button and it magically updates the info for all your movies'?
 
Reply With Quote
 
Senior Member
Kaveman's Avatar
Join Date: Nov 2010
Location: Westland, NZ
Posts: 1,355
 
      20th August 2011
Yes, this will be of more use 2 years from now, when you want to revisit the web page to read more about a movie. But a good starting place.

I'm not sure about scraping the actual web pages for 2 reasons, It is that it is violation of Amazons terms of use, and parsing Web pages is very fragile in AppleScript. So we'll use http://www.imdbapi.com/ to get the information you need.
 
Reply With Quote
 
Member
Join Date: Aug 2011
Posts: 19
 
      20th August 2011
Ok, but what do Amazon have to do with it? and that imdbapi looks ok, you seem to know what you're doing anyway
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automation and launchctl Jeff Gaines UK Macs 2 15th August 2011 09:38 AM
Equivalant of OLE automation on mac RAHUL Apps 1 17th June 2009 05:46 AM
Need Help on automation tool for Mac OS Ashwin Mac 0 20th February 2008 11:42 AM
MacScan automation Antagonostic Apps 4 21st August 2006 06:06 PM
OS X USB automation Sam Misc 0 24th June 2003 12:16 AM


All times are GMT +1. The time now is 12:29 PM.
Mac-Help.com is an independent website and is not affiliated with Apple Inc.


Welcome!
Welcome to the Mac Help Forums
 


Latest Threads
PDF Document
yura (16 Minutes Ago, 12:13 PM)

Difficulties with internet speed (nothing to do with connection)
sammethh (5 Hours Ago, 06:36 AM)

Deleting a homepage/website form my mac book pro
rgandajg (13 Hours Ago, 10:30 PM)

MacBook
basil422 (18 Hours Ago, 06:01 PM)

Outlook reminders not popping up
WonderBot (19 Hours Ago, 05:03 PM)

 


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51