tempData["imdb_id"])["genres"] except: print("Couldn't get geners") tempData["progress"] = 0 #Add main video file if tempData["main_id"] == "" or uDP: tempData["main_id"] = getPointer( glob.glob(os.path.join(path, '*.mp4'))[0]) #Add trailer file, download if doesn't exist if tempData["trailer_id"] == "" or uDP: if (len(glob.glob(os.path.join(path, '*.trailer'))) == 0): print("No trailer found. Downloading.") url = imdb.get_title_videos( tempData["imdb_id"])['videos'][0]["encodings"][0]["play"] r = requests.get(url) open(os.path.join(path, tempData['title'] + ".trailer"), 'wb').write(r.content) tempData["trailer_id"] = getPointer( glob.glob(os.path.join(path, '*.trailer'))[0]) if tempData["tall"] == "" or uDP: #Add tall image, download if necessary if len(glob.glob(os.path.join(path, 'tall.*'))) == 0: print("No tall image found. Downloading.") url = movie['base']["image"]['url'] r = requests.get(url) open(os.path.join(path, "tall.jpg"), 'wb').write(r.content) tempData["tall"] = getPointer( glob.glob(os.path.join(path, 'tall.*'))[0]) if tempData["wide"] == "" or uDP:
genres = columns[1][:-1].split('|') movie_list.append(movie_id) movie_genres[movie_id] = genres imdb = Imdb() movie_count = 0 for movie_id in movie_list: try: title = imdb.get_title(movie_id) sql = ( '''INSERT INTO movie_movie VALUES (\'{}\',\'{}\',\'{}\',\'{}\',\'{}\',\'{}\',\'{}\',\'{}\',\'{}\')'''.format( movie_id, single_quote(str(title['base']['title'])), title['base']['year'], title['base']['runningTimeInMinutes'], movie_genres[movie_id], title['ratings']['rating'], single_quote(title['base']['image']['url']), single_quote(str(title['plot']['outline']['text'])), single_quote(str(imdb.get_title_videos(movie_id)['videos'][0]['encodings'][0]['play'])) )) execute_sql(sql) movie_count += 1 print("Insert movie: " + movie_id, movie_count) except Exception as e: print('Movie Insert Failure: ' + movie_id, e) continue print('\n')
imdb = Imdb() movie_count = 0 for movie_id in movie_list: try: title = imdb.get_title(movie_id) sql = ( '''INSERT INTO movie_movie VALUES (\'{}\',\'{}\',\'{}\',\'{}\',\'{}\',\'{}\',\'{}\',\'{}\',\'{}\')''' .format( movie_id, single_quote(str(title['base']['title'])), title['base']['year'], title['base']['runningTimeInMinutes'], movie_genres[movie_id], title['ratings']['rating'], single_quote(title['base']['image']['url']), single_quote(str(title['plot']['outline']['text'])), single_quote( str( imdb.get_title_videos(movie_id)['videos'][0] ['encodings'][0]['play'])))) execute_sql(sql) movie_count += 1 print("Insert movie: " + movie_id, movie_count) except Exception as e: print('Movie Insert Failure: ' + movie_id, e) continue actors = imdb.get_title_credits(movie_id) actor_length = len(actors['credits']['cast']) print('Add Actors: ', end='') for actor in actors['credits'][ 'cast'][:5 if actor_length > 5 else actor_length]: actor_id = actor['id'].split('/')[2] try: if actor_id not in actor_set: