Importing IMDB ratings

Hello,

based on some examples in this board I created this script which will import your IMDB ratings. You need to activate a feed for your ratings in IMDB and add this to DT. The script will go through each imported feed item and:

  • Read out your rating and add a label
  • Add a tag like 10/10
  • Convert the rating to a */5 rating and save this as well
  • Fetch the whole page as web archive and store it locally
  • Preserve the creation date of the original feed item

That’s what IMDB gives you:

That’s what the script makes out of it:

I set Devonthink to these labels to get the stars:

set nameofDatabase to "Standard"
set pathtoFeed to "/Filmbewertungen/IMDB-Import"
set pathtoDestination to "/Filmbewertungen"

tell application id "com.devon-technologies.thinkpro2"
	
	if nameofDatabase is "" then
		set theDatabase to inbox -- the global inbox
	else
		set theDatabase to database named nameofDatabase
	end if
	
	set theTrash to the trash group of theDatabase
	
	set theFeed to get record at pathtoFeed in theDatabase
	
	set FeedEntries to the children of theFeed
	
	repeat with thisEntry in FeedEntries
		
		-- Use this block to get the Instapaper page
		--set theRawUrl to URL of thisEntry
		--set search_string to "http://"
		--set replacement_string to ""
		--set AppleScript's text item delimiters to search_string
		--set text_item_list to every text item of theRawUrl
		--set AppleScript's text item delimiters to replacement_string
		--set theRawUrl to text_item_list as string
		--set theurl to "http://www.instapaper.com/text?u=http%3A%2F%2F" & theRawUrl
		
		-- Or use this line to get the full page
		set theurl to the URL of thisEntry
		
		set thisText to rich text of thisEntry
		set rating to ""
		set newLabel to ""
		set newTags to ""
		set rating to last word of thisText
		
		if the pathtoDestination is "" then
			set theDestination to incoming group of theDatabase
		else
			set theDestination to create location pathtoDestination in theDatabase
		end if
		
		if rating is "1" then
			set newLabel to 6
			set newTags to "0/5;1/10"
		else if rating is "2" then
			set newLabel to 5
			set newTags to "1/5;2/10"
		else if rating is "3" then
			set newLabel to 4
			set newTags to "2/5;3/10"
		else if rating is "4" then
			set newLabel to 4
			set newTags to "2/5;4/10"
		else if rating is "5" then
			set newLabel to 3
			set newTags to "3/5;5/10"
		else if rating is "6" then
			set newLabel to 3
			set newTags to "3/5;6/10"
		else if rating is "7" then
			set newLabel to 2
			set newTags to "4/5;7/10"
		else if rating is "8" then
			set newLabel to 2
			set newTags to "4/5;8/10"
		else if rating is "9" then
			set newLabel to 1
			set newTags to "5/5;9/10"
		else if rating is "10" then
			set newLabel to 1
			set newTags to "5/5;10/10"
		else
			set theDestination to incoming group of theDatabase
		end if
		
		set createDate to creation date of thisEntry
		set newDoc to create web document from theurl in theDestination
		if newLabel is not "" then
			set label of newDoc to newLabel
			set the tags of newDoc to newTags
			set unread of newDoc to false
			
		end if
		set creation date of newDoc to createDate
		move record thisEntry to theTrash
	end repeat
	
end tell

I run the script daily to convert new items:

That’s indeed a unique usage of labels, thanks for the tip!

With the latest redesign of imdb this no longer works. They removed rss feeds.

https://getsatisfaction.com/imdb/topics/rss-feed-for-your-ratings

I guess you could still read read it from imdb pages with XPath.

Seems to be at:


//*[@id="title-overview-widget"]/div[2]/div[2]/div/div[1]/div[1]/div[1]/strong/span