def imdb(self): """Get IMDb data for release, set self.imdb_id to override auto match from movie title + year""" from imdbpie import Imdb imdb = Imdb() if not self.movie_release: return False imdb_id = None if hasattr(self, "imdb_id"): imdb_id = self.imdb_id # Find IMDb match by title and check if year is a match if not imdb_id: for imdb_match in imdb.find_by_title(self.movie_title): if int(imdb_match.get("year")) == self.movie_year: imdb_id = imdb_match.get("imdb_id") break # No IMDb match could be found from title + year if not imdb_id: return False return imdb.find_movie_by_id(imdb_id)
def net_search(name): #input=movie name #output=movie id from imdb imdb = Imdb({'anonymize': False}) #~ movie = imdb.find_movie_by_id("tt0382932") #~ print movie.title if len(name) > 0: details = imdb.find_by_title(name) if len(details) > 0: #~ return imdb.find_movie_by_id(details[0]['imdb_id']) imdb_id = details[0]['imdb_id'] #~ print imdb_id movie = imdb.find_movie_by_id(imdb_id) return movie else: #~ return NULL return -1
def net_search(name): #input=movie name #output=movie id from imdb imdb = Imdb({'anonymize': False}) #~ movie = imdb.find_movie_by_id("tt0382932") #~ print movie.title if len(name)>0: details=imdb.find_by_title(name) if len(details)>0: #~ return imdb.find_movie_by_id(details[0]['imdb_id']) imdb_id=details[0]['imdb_id'] #~ print imdb_id movie=imdb.find_movie_by_id(imdb_id) return movie else: #~ return NULL return -1
audience_score = re.findall(pattern,movie_details) text = '"critics_score":"(.+?)"' pattern = re.compile(text) critics_score = re.findall(pattern,movie_details) c.execute("INSERT INTO Rottentomatoes_movie VALUES(name,year,mpaa_rating,release_date,audience_score,critics_score") conn.commit() print "Details from Rottentomatoes:\n" for row in c.execute('SELECT * FROM Rottentomatoes_movie ORDER audience_score'): print row conn.close() imdb = Imdb() imdb.find_by_title(movie) c.execute('''CREATE TABLE IF NOT EXISTS imdb_movie(name text,year int,mpaa_rating text,release_date text,genre text,runtime text,plot text,language text,director text,writer text,actors text,metascore real,imdb_rating real,imdb_votes int)''') text = '"Title":"(.+?)"' pattern = re.compile(text) name = re.findall(pattern,movie_details) text = '"Year":"(.+?)"' pattern = re.compile(text) year = re.findall(pattern,movie_details) text = '"Rated":"(.+?)"' pattern = re.compile(text) mpaa_rating = re.findall(pattern,movie_details) text = '"Released":"(.+?)"'
def details(movie,detailinfo): imdb = Imdb() movie_data=imdb.find_by_title(movie) json_data = json.loads(movie_data)[0] detail = json_data[detailinfo] return detail
print 'usage: imdb_downloader.py [movie name | top50 | top250]' sys.exit(1) if sys.argv[1] == "top50": print "Retrieving Top 50 movies" top50 = imdb.top_250()[0:50] for m in top50: movies_xml.getroot().append(get_movie(m['tconst'])) elif sys.argv[1] == "top250": print "Retrieving Top 250 movies" top50 = imdb.top_250() for m in top50: movies_xml.getroot().append(get_movie(m['tconst'])) else: movie = imdb.find_by_title(sys.argv[1])[0] if movie is None: print 'Not found.' sys.exit(1) movie_xml = get_movie(movie['imdb_id']) movies_xml.getroot().append(movie_xml) f = open('data/movies.xml', 'w') f.write(etree.tostring(movies_xml.getroot(), pretty_print=True)) f.close()