Wednesday 8 October 2008

right-click, view movie's imdb page

I've been using this for a while now. If like me, you have a large proportion of your films legally backed up on your hard drive but dont deal with a media centre app, you want a nice quick method for looking up the plot synopsys, rating, or review on imdb.com. Well this is the script i use:

#! /usr/bin/python

import sys, os, os.path

myPath = sys.argv[1]
(dirName, fileName) = os.path.split(myPath)
(fileBaseName, fileExtension)=os.path.splitext(fileName)
t = fileBaseName.lower()
t = t.strip().replace("'", "")
t = t.strip().replace('cd1', '')
t = t.strip().replace('cd2', '')
t = t.strip().replace('CD1', '')
t = t.strip().replace('CD2', '')
t = t.strip().replace('.', ' ')
t = t.strip().replace('-', ' ')
t = t.strip().replace('_', ' ')
t = t.split('x264')
t = t[0].split('xvid')
t = t[0].split('divx')
t = t[0].split('unrated')
t = t[0].split('dvdr')
t = t[0].split('dvdrip') 
t = t[0].split(' cam ')
t = t[0].split(' ts ')
t = t[0].split(' scr ')
t = t[0].split('screener')
t = t[0].split('dvdscr')
t = t[0].split('r5')
t = t[0].split('limited')
t = t[0].split('internal')
t = t[0]
os.system('''firefox "google.com/search?btnI=1&q='''+ t + ''' imdb"''')

It's located at ~/scripts/imdb but you can put it anywhere of course. I create an entry on the right-click menu using nautilus-actions but if you don't use gnome you'll have to use an alternative method. This screencap should illustrate how I've set up nautilus-actions:


1 comment:

  1. I did abit of a revise.
    Here is my version..

    #! /usr/bin/python

    import sys, os, os.path

    name = os.path.basename(sys.argv[1]).lower()

    undesirables = ["'", 'cd1', 'CD1', 'CD2', '.', '-', '_', '[', ']',]

    for item in undesirables:
    name = name.replace(item, ' ')

    undesirables = ['x264', 'xvid', 'divx', 'unrated', 'dvdr', 'dvdrip', ' cam ', ' ts ', ' scr ', 'screener', 'dvdscr', 'r5', 'limited', 'internal',]

    for item in undesirables:
    name = name.split(item)[0]

    os.system('firefox "google.com/search?btnI=1&q= %s imdb"' %name.strip())

    ReplyDelete