#! /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:
I did abit of a revise.
ReplyDeleteHere 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())