def imdbGetMovie(imdb_id): cached = ImdbCache.objects.filter(imdb_id=get_imdb_movie_id(imdb_id)) if cached.__len__() > 0 and cached[0].is_full: return cPickle.loads(base64.b64decode(cached[0].content)) else: imdb = IMDb() m = imdb.get_movie(imdb_id) content = base64.b64encode(cPickle.dumps(m, 2)) c = ImdbCache(imdb_id=get_imdb_id(m), content=content, is_full=True) c.save() return m
def imdbGetMovie(imdb_id): cached = ImdbCache.objects.filter(imdb_id = get_imdb_movie_id(imdb_id)) if cached.__len__() > 0 and cached[0].is_full: return cPickle.loads(base64.b64decode(cached[0].content)) else: imdb = IMDb() m = imdb.get_movie(imdb_id) content = base64.b64encode(cPickle.dumps(m, 2)) c = ImdbCache(imdb_id = get_imdb_id(m), content = content, is_full = True) c.save() return m
def corrigir_titulo_serie(): print('corrigir_titulo_serie Iniciado') repetir = False for r in db.registros.find({ 'titulo': { '$exists': False }, 'imdb': { '$regex': '.* .*' } }).limit(1): # print(r) try: im = str(r['imdb']).strip()[2:r['imdb'].index(" ")] imdb = IMDb() print(int(im)) movie = imdb.get_movie(int(im)) movie.fetch() print(movie.__dict__['title']) print(movie.__dict__['year']) print('.*' + str(im) + '.*') db.registros.update_many( {'imdb': { '$regex': '.*' + str(im) + '.*' }}, { "$set": { "titulo": movie.__dict__['title'], "ano": movie.__dict__['year'] } }) print('Sem Título: ', im, movie.__dict__['title']) repetir = True except: im = str(r['imdb']).strip()[2:r['imdb'].index(" ")] db.registros.update_many( {'imdb': { '$regex': '.*' + str(im) + '.*' }}, {"$set": { "titulo": 'Título não encontrado', "ano": 0 }}) repetir = True print('Erro Sem Título: ', im) if repetir: corrigir_titulo_serie()
def corrigir_titulo_filme(): print('corrigir_titulo_filme: Iniciado') repetir = False for r in db.registros.find({ 'titulo': { '$exists': False }, 'imdb': { '$not': { '$regex': '.* .*' } } }).limit(20): # print(r) try: im = str(r['imdb']).strip()[2:] imdb = IMDb() print(int(im)) movie = imdb.get_movie(int(im)) movie.fetch() print(movie.__dict__['title']) print(movie.__dict__['year']) db.registros.update_one({"_id": r['_id']}, { "$set": { "titulo": movie.__dict__['title'], "ano": movie.__dict__['year'] } }) print('Sem Título: ', im, movie.__dict__['title']) repetir = True except: db.registros.update_one( {"_id": r['_id']}, {"$set": { "titulo": 'Título não encontrado', "ano": 0 }}) repetir = True print('Erro Sem Título: ', im) if repetir: corrigir_titulo_filme()
def _movies(self): movies_dat = os.path.join(self.dataset_path, 'movies.dat') with open(movies_dat) as f: for l in f: movie_id, title, tags = l.split("::") print("Loading movie `%s`" % title) matches = re.match(r'([^\(]+?)((\([^\(]+\)) (\([^\(]+\)))', title) if matches: title = "%s %s" % (matches.groups()[0], matches.groups()[-1]) released_date = title.split()[-1][1:-1] self.movies[movie_id] = { 'title': title, 'tags': tags.split("|"), 'released_date': released_date } try: movie = imdb.get_movie(title) for k, v in movie.items(): self.movies[movie_id][k] = v except: print("Error `%s`" % title)
print("Type the TV Show or Movie wanted: ") name = input('>') search = imdb.search_movie(name) count = 1 print("The top five searhed items are:") for index in search[0:5]: print(str(count) + ". " + index['title'] + " (" + str(index['year']) + ")") count += 1 print("Please select the one you want: [1-5]") selection = input('>') select_id = search[int(selection) - 1].getID() item = imdb.get_movie(select_id) #Add check for TVshow/movie and a way to get back to previous search imdb.update(item, 'episodes') item_basic_info = { "title": item['title'], "type": item['kind'], "year": item['year'], "nr_seasons": len(item['episodes']) } print("The selected item is: ") print(item_basic_info['title']) print(item_basic_info['year']) print(item_basic_info['type'])
movie = currentSheet.cell(x, movieTitle).value try: #(imdb.get_movie(mov[0].movieID)["genre"]) #Searches for the movie on OMDB <<<<<<< HEAD baseInfo = Imdb().search_for_title(movie) search = baseInfo[0]['imdb_id'] genre = Imdb().get_title_genres(search)["genres"] runtime = (Imdb().get_title(search))["base"]["runningTimeInMinutes"] #Updates cells with genre and runtime currentSheet.update_cell(x, gColumn, comma.join(genre)) currentSheet.update_cell(x, rColumn, str(runtime) + ' min') ======= baseInfo = imdb.search_movie(movie)[0].movieID search = imdb.get_movie(baseInfo) #Updates cells with genre and runtime currentSheet.update_cell(x, gColumn, ", ".join(search["genres"])) currentSheet.update_cell(x, rColumn, str(int(search["runtimes"][0])) + ' min') >>>>>>> testing except Exception as c: print (str(c) + " at row " + str(x)) #if it f***s up it owns up to it currentSheet.update_cell(x, gColumn, 'f****d up') currentSheet.update_cell(x, rColumn, '') #currentSheet.update_cell(x, tColumn, '') def time(gsheet, sheet): currentSheet = gsheet.worksheet(sheet) columnTitles = currentSheet.row_values(1)
#Film suchen filme_id = imdb.search_movie(filme) if filme_id == []: kategorie = "N/A" jahr = "N/A" besetzung = "N/A" bewertung = "N/A" laufzeit = "N/A" typ = "N/A" direktor = "N/A" beschreibung = "N/A" else: #ID bekommen filme_id = filme_id[0].movieID #Werte holen film = imdb.get_movie(filme_id) #Genre try: kategorie = str(film['genres']) except: kategorie = "N/A" #Jahr try: jahr = str(film['year']) except: jahr = "N/A" #Besetzung try: besetzung = str(film['cast']) except: besetzung = "N/A"
def search(title: str): # searches imdb for the first 3 most likely results and returns a list of processed info dictionaries search = imdb.search_movie(title)[:3] search_results = [imdb.get_movie(film.movieID) for film in search] fixed_results = [] # mtm fields genres = db.get_all('Genres') directors = db.get_all('Directors') actors = db.get_all('Actors') studios = db.get_all('Studios') # convert the dicts gotten from scraper into readable dicts we can use for film in search_results: info = { 'title': film.get('title'), 'alt_title': '', 'animated': True if 'Animation' in film.get('genres') else False, 'year': str(film.get('year')), 'genres': [g for g in film.get('genres') if g in genres], 'plot': film.get('plot outline') } # Countries we can only have one entry for this field and there can be more than one country in film.get, so we pick the first match if film.get('countries'): for country in film.get('countries'): if country in db.get_all('Countries'): info['country'] = country break if film.get('cast'): info['actors'] = [ a for a in actors if a in [c['name'] for c in film.get('cast')] ] if film.get('languages'): # might return None info['language'] = [ lang for lang in film.get('languages') if lang in db.get_all('Languages') ] # convert media types if 'Documentary' in film.get('genres'): info['media_type'] = 'Documentary' elif 'movie' == film.get('kind'): info['media_type'] = 'Movie' elif 'tv series' == film.get('kind'): info['media_type'] = 'TV Series' else: info['media_type'] = '' # directors if film.get('director'): # film.get('director') could return None for director in film.get('director'): if director['name'] in directors: info['director'] = director['name'] break if 'director' not in info.keys(): info[ 'director'] = '' # make sure it's at least a blank string because we need it to display to create window # studio if film.get('production companies'): for studio in film.get('production companies'): if studio['name'] in studios: info['studio'] = studio['name'] break fixed_results.append(info) return fixed_results