[windows] Verify name from themoviedb?

Come up with a useful post-processing script? Share it here!
Post Reply
moveright
Newbie
Newbie
Posts: 31
Joined: July 14th, 2011, 7:45 pm

[windows] Verify name from themoviedb?

Post by moveright »

Is there already an existing script that will:

1) read in the movie name from the folder name (presuming the folder is named 'movie name 2009 Xvid AC3 720p' etc)
2) check the movie name against themoviedb.org
3) rename the folder and file name accordingly

?

Does that sound like a complicated script? The reason I am asking is because I use an appleTv to stream my local content and apparently, the scrapers on the ATVflash media player (upgrade from firecore) refer to themoviedb.org for their info and it would be nice if I could prep the folder and file names so that they are clean and in compliance prior to moving them to my movie folder.

Thanks!

p.s. the reason I wanted to know if it sounds complicated is because I may venture to create one myself in none exist.
NoTolerance
Full Member
Full Member
Posts: 127
Joined: June 27th, 2012, 9:55 am

Re: [windows] Verify name from themoviedb?

Post by NoTolerance »

How would you handle movies that don't have a unique title? For example: http://www.themoviedb.org/search?query=wanderlust

I had toyed with this idea in one of my scripts. A better approach might be to do something similar to what I ultimately ended up doing:

Most scene releases contain an imdb link in the nfo file. You could parse the nfo file for the imdb URL and pull the info from there.

As far as difficulty? Seems pretty straightforward to me. Should be a fairly simple script to write.
sumofatguy
Newbie
Newbie
Posts: 8
Joined: February 23rd, 2009, 11:03 pm

Re: [windows] Verify name from themoviedb?

Post by sumofatguy »

you can do it in python using beautifulsoup
it gets the imdb link from the nfo, if there is no nfo it uses the folder name

I'm not much of a python coder, so I'm quite certain there are much better ways to do it. It was just that way that worked for me. It works for most of the movie naming schemes i've found

Code: Select all

import os, re
from BeautifulSoup import BeautifulSoup

def main (movie_dir):
# find proper movie name from IMDB link, otherwise use folder name
	link = ""
	for file in filter(lambda x: x.lower().endswith('.nfo'), os.listdir(movie_dir)):
		nfo = open(os.path.join(movie_dir, file), "r")
		link = re.findall(".*(http\:\/\/.*?imdb\.com\/title\/tt(?:\d+)\/).*", ''.join(nfo.readlines()))
		nfo.close()
		if len(link) > 0:
			print "Movie link:\t", link[0]
			url = urllib2.urlopen(link[0])
			source = url.read()
			soup = BeautifulSoup(''.join(source))
			movie_name = soup.html.head.title.string
# messy way of finding the correct movie name
	if len(link) == 0:
		print "ERROR:\t\tno IMDB info found, trying folder name instead"
		try:
			movie_name = os.path.basename(movie_dir).split(re.search("\d{4}", movie_dir).group())[0].replace(".", " ").title().strip()
		except:
			print "ERROR:\t\tunknown folder format... Aborting"
			sys.exit()
		if '720P' in movie_name:
			movie_name = movie_name.split(" 720P")[0]
			
	if '(' in movie_name:
		movie_name = movie_name.split(' (')[0]
# remove invalid characters
	valid_characters = "()- . %s%s" % (string.ascii_letters, string.digits)
	movie_name = ''.join(c for c in movie_name if c in valid_characters)
	print "Name:\t\t", movie_name

if __name__ == "__main__":
	if len(sys.argv) >= 3:
		main(sys.argv[1])
	else:
		main(sys.argv[1])
The whole script is here: http://pastebin.com/s4brCGnL. It movies the movie files to predetermined locations and properly renames the folders. If it's a 2cd release, it will move both files. for HD releases, it scans the file name for the release format (bluray, HDDVD etc), and if none are found it assumes a bluray rip (used to be used in XBMC, i'm not sure if it does anymore...). It also updates XBMC for you.

As I said, I'm not a python programmer, so there are probably much much better ways to do some of the things I did... Oh well it works. Sample output:

Code: Select all

File type:	         .mkv
File:		        Testmovie.2012.720p.BluRay.x264.DTS-HDC.mkv
Tag:		        BluRay
ERROR:		no IMDB info found, trying folder name instead
Name:		Testmovie
Making folder:	D:\Testmovie
Copying:	        Testmovie.2012.720p.BluRay.x264.DTS-HDC.mkv --> D:\Testmovie
Delete folder:	e:\_downloads\Testmovie 2012 720p BluRay x264 DTS HDC

Updating XBMC...
Testmovie : processed successfully
J03 8LACK
Full Member
Full Member
Posts: 120
Joined: April 2nd, 2009, 1:33 am

Re: [windows] Verify name from themoviedb?

Post by J03 8LACK »

Hey Guys,

If you already have CouchPotato setup you already have a script what will do as you wish.

In the Renaming Tab in CouchPotato you setup a rename tempfolder and if you setup a category to point to this after download it will check the name and rename and get info for you.

Also if you have files already downloaded and need them renamed just move them to the setup tempfolder and CouchPotato will rename them for you and put them back where you want them.

also take a look here. - http://forums.sabnzbd.org/viewtopic.php?f=1&t=10028
and also here - http://forums.sabnzbd.org/viewtopic.php ... 787#p64787

give it a try
J03
Post Reply