Home > python > Check downloaded movies on imdb.com

Check downloaded movies on imdb.com

Recently, I downloaded a nice pack of horror movies. The pack contained more than a hundred movies :) I wanted to see their IMDB ratings to decide which ones to watch, but typing their titles in the browser would be too much work. Could it be automated?

Solution

Each movie was located in a subdirectory. Here is an extract:

...
Subspecies.1991.DVDRip.XviD-NoGrp
Terror.Train.1980.DVDRIP.XVID-NoGrp
The.Changeling.1980.DVDRip-KooKoo
The.Creature.Walks.Among.Us.1956.DVDRip-KooKoo
The.Hills.Have.Eyes.1977.DVDRip-KooKoo
The.Howling.Special.Edition.1981.XviD.6ch-AC3-FTL
The.Monster.Club.1980.DVDRip.DivX-UTOPiA
...

Fortunately, the directories were named in a consistent way: title of the movie (words separated with a dot), year, extra info. Thus, extracting titles was very easy. Idea: collect the titles in a list and open them in Firefox on imdb.com, each in a new tab.

First, I redirected the directory list in a file. It was easier to work with a text file than doing globbing:

ls >a.txt

And finally, here is the script:

#!/usr/bin/env python

import re
import urllib
import webbrowser

base = 'http://www.imdb.com/find?s=all'
firefox = webbrowser.get('firefox')

f1 = open('a.txt', 'r')

for line in f1:
    line = line.rstrip('\n')
    if line.startswith('#'):
        continue

    # else
    result = re.search(r'(.*)\.\d{4}\..*', line)
    if result:
        address = result.group(1).replace('.', ' ')
        url = "%s&q=%s" % ( base, urllib.quote(address) )
        print url
        firefox.open_new_tab(url)
        #webbrowser.open_new_tab(url)    # try this if the line above doesn't work

f1.close()

Achtung! Don’t try it with a huge list, otherwise your system will die :) Firefox won’t handle too many open tabs… Try to open around ten titles at a time. In the input file (a.txt) you can comment lines by adding a leading ‘#‘ sign, thus those lines will be discarded by the script.

About these ads
Categories: python Tags: , , , ,
  1. March 28, 2011 at 18:28 | #1

    You can find here a software that checks the rates of your movies automatically. http://www.bikod.com/genel/imdb-rate-checker-imdb-puan-sorgulama-programi.html

  2. March 29, 2011 at 13:28 | #3

    Sorry but not open source and doesn’t support Linux. But it’s still under construction. You can find new available versions from this link soon.

  1. No trackbacks yet.
You must be logged in to post a comment.
Follow

Get every new post delivered to your Inbox.

Join 63 other followers

%d bloggers like this: