def imdbSearchMovie(title): cached = ImdbSearch.objects.filter(keyword=title).order_by('result_index') if cached.__len__() > 0: resultList = [] for c in cached: content = base64.b64decode(c.imdb_obj.content) resultList.append(cPickle.loads(content)) return resultList else: imdb = IMDb() resultList = imdb.search_movie(title)[:maxResults] i = 0 for result in resultList: result = imdbUpdate(result) c = ImdbSearch(keyword=title, result_index=i, imdb_obj=ImdbCache.objects.filter( imdb_id=get_imdb_id(result))[0]) c.save() i = i + 1 return resultList
def imdbSearchMovie(title): cached = ImdbSearch.objects.filter(keyword = title).order_by('result_index') if cached.__len__() > 0: resultList = [] for c in cached: content = base64.b64decode(c.imdb_obj.content) resultList.append(cPickle.loads(content)) return resultList else: imdb = IMDb() resultList = imdb.search_movie(title)[:maxResults] i = 0 for result in resultList: result = imdbUpdate(result) c = ImdbSearch( keyword = title, result_index = i, imdb_obj = ImdbCache.objects.filter(imdb_id = get_imdb_id(result))[0]) c.save() i = i + 1 return resultList
def imdb_results_for_tweet(cls, match, *imdb_args, **imdb_kwargs): imdb = ImdbHelper(*imdb_args, **imdb_kwargs) results = imdb.search_movie(match.get('title')) def _scrub(title): return re.sub(r'[^a-z]', '', title.lower()) def _match_result(r): title_matches = _scrub(match.get('title')) == _scrub( r.get('title')) if not title_matches: return False if match.get('year'): if not r.get('year') or int(match.get('year')) != int( r.get('year')): return False return True match_title = filter(_match_result, results) match_sorted = sorted( match_title, cmp=lambda x, y: cmp(x.get('year'), y.get('year')), reverse=True) return match_sorted
import imdb import csv import re # Used imdb API to export info of TV Show into a csv file with ShowTitle/Ep.Title/Ep.Rating/Votes/Ep.Summary etc.. imdb = imdb.IMDb() 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'],
#Grabs movie title 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)
# Python 3.9.4 # Cool way to search for the year a movie came out using the IMDbPY module. import imdb imdb = imdb.IMDb() # Searching the movie, not case-sensitive. search = imdb.search_movie("Drive") year = search[0]['year'] print(search[0]['title'] + " : " + str(year))
#Listen welche benötigt/ gefüllt werden kategorien = [] jahre = [] besetzungen = [] bewertungen = [] laufzeiten = [] beschreibungen = [] direktoren = [] typen = [] #IMDB Suche from imdb import IMDb for filme in bereinigt_liste: imdb = IMDb() #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
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