def get_info_from_search(): search_data = tools.get_tmdb_search_data(tmdb_api_key, self.movie_title) if search_data is None or search_data['total_results'] == 0: return False movie_data = None movie_backup_data = None if self.movie_release_year is None: movie_data = search_data['results'][0] else: for result in search_data['results'][:5]: if movie_data is None: if str(self.movie_release_year ) == result['release_date'][:4]: movie_data = result elif result['release_date'][6:8] in ['09', '10', '11', '12'] \ and str(self.movie_release_year - 1) == result['release_date'][:4]: movie_data = result elif result['release_date'][6:8] in ['01', '02', '03', '04'] \ and str(self.movie_release_year + 1) == result['release_date'][:4]: movie_data = result elif movie_backup_data is None: if str(self.movie_release_year - 1) == result['release_date'][:4]: movie_backup_data = result elif str(self.movie_release_year + 1) == result['release_date'][:4]: movie_backup_data = result if movie_data is None and movie_backup_data is not None: print( 'None of the search results had a correct release year, picking the next best result' ) movie_data = movie_backup_data if movie_data is None: movie_data = search_data['results'][0] self.tmdb_id = movie_data['id'] self.movie_title = tools.get_clean_string(movie_data['title']) self.movie_original_title = tools.get_clean_string( movie_data['original_title']) self.movie_title_keywords = tools.get_keyword_list( movie_data['title']) self.movie_original_title_keywords = tools.get_keyword_list( movie_data['original_title']) if len(movie_data['release_date'][:4]) == 4: self.movie_release_year = int(movie_data['release_date'][:4]) else: self.movie_release_year = None return True
def get_info_from_search(): search_data = tools.get_tmdb_search_data(tmdb_api_key, self.movie_title) if search_data is None or search_data['total_results'] == 0: return False movie_data = None movie_backup_data = None if self.movie_release_year is None: movie_data = search_data['results'][0] else: for result in search_data['results'][:5]: if movie_data is None: if str(self.movie_release_year) == result['release_date'][:4]: movie_data = result elif result['release_date'][6:8] in ['09', '10', '11', '12'] \ and str(self.movie_release_year - 1) == result['release_date'][:4]: movie_data = result elif result['release_date'][6:8] in ['01', '02', '03', '04'] \ and str(self.movie_release_year + 1) == result['release_date'][:4]: movie_data = result elif movie_backup_data is None: if str(self.movie_release_year - 1) == result['release_date'][:4]: movie_backup_data = result elif str(self.movie_release_year + 1) == result['release_date'][:4]: movie_backup_data = result if movie_data is None and movie_backup_data is not None: print('None of the search results had a correct release year, picking the next best result') movie_data = movie_backup_data if movie_data is None: movie_data = search_data['results'][0] self.tmdb_id = movie_data['id'] self.movie_title = tools.get_clean_string(movie_data['title']) self.movie_original_title = tools.get_clean_string(movie_data['original_title']) self.movie_title_keywords = tools.get_keyword_list(movie_data['title']) self.movie_original_title_keywords = tools.get_keyword_list(movie_data['original_title']) if len(movie_data['release_date'][:4]) == 4: self.movie_release_year = int(movie_data['release_date'][:4]) else: self.movie_release_year = None return True
def get_info_from_details(): details_data = tools.get_tmdb_details_data(tmdb_api_key, tmdb_id) if details_data is not None: self.tmdb_id = details_data['id'] self.movie_title = details_data['title'] self.movie_original_title = details_data['original_title'] self.movie_title_keywords = tools.get_keyword_list(details_data['title']) self.movie_original_title_keywords = tools.get_keyword_list(details_data['original_title']) if len(details_data['release_date'][:4]) == 4: self.movie_release_year = int(details_data['release_date'][:4]) else: self.movie_release_year = None return True else: return False
def get_info_from_details(): details_data = tools.get_tmdb_details_data(tmdb_api_key, tmdb_id) if details_data is not None: self.tmdb_id = details_data['id'] self.movie_title = details_data['title'] self.movie_original_title = details_data['original_title'] self.movie_title_keywords = tools.get_keyword_list(details_data['title']) self.movie_original_title_keywords = tools.get_keyword_list(details_data['original_title']) if len(details_data['release_date'][:4]) == 4: self.movie_release_year = int(details_data['release_date'][:4]) else: self.movie_release_year = None return True else: return False
def process_similar_results(): self.banned_title_keywords = list() self.banned_years = list() for similar_movie in similar_movies: for word in tools.get_keyword_list(similar_movie['title']): if (word.lower() not in self.movie_title.lower() and word.lower() not in self.banned_title_keywords): if self.movie_original_title is not None: if word.lower( ) not in self.movie_original_title.lower(): self.banned_title_keywords.append(word) else: self.banned_title_keywords.append(word) try: if len(similar_movie['release_date'][:4]) == 4 \ and int(similar_movie['release_date'][:4]) not in ([self.movie_release_year] + self.banned_years) \ and similar_movie['release_date'][:4] not in self.movie_title: self.banned_years.append( int(similar_movie['release_date'][:4])) except KeyError as e: pass
def get_info_from_directory(): clean_name_tuple = tools.get_clean_string(self.name).split(' ') if any(clean_name_tuple[-1] == str(year) for year in range(1896, date.today().year + 2)): self.movie_release_year = int(clean_name_tuple[-1]) self.movie_title = ' '.join(clean_name_tuple[:-1]) self.movie_original_title = ' '.join(clean_name_tuple[:-1]) else: self.movie_release_year = None self.movie_title = ' '.join(clean_name_tuple) self.movie_original_title = ' '.join(clean_name_tuple) self.movie_title_keywords = tools.get_keyword_list(self.movie_title) self.movie_original_title_keywords = tools.get_keyword_list(self.movie_original_title) return True
def get_info_from_directory(): clean_name_tuple = tools.get_clean_string(self.name).split(' ') #print("clean title " + clean_name_tuple) if any(clean_name_tuple[-1] == str(year) for year in range(1896, date.today().year + 2)): self.movie_release_year = int(clean_name_tuple[-1]) self.movie_title = ' '.join(clean_name_tuple[:-1]) self.movie_original_title = ' '.join(clean_name_tuple[:-1]) else: self.movie_release_year = None self.movie_title = ' '.join(clean_name_tuple) self.movie_original_title = ' '.join(clean_name_tuple) self.movie_title_keywords = tools.get_keyword_list(self.movie_title) self.movie_original_title_keywords = tools.get_keyword_list(self.movie_original_title) return True
def process_similar_results(): self.banned_title_keywords = list() self.banned_years = list() for similar_movie in similar_movies: for word in tools.get_keyword_list(similar_movie['title']): if (word.lower() not in self.movie_title.lower() and word.lower() not in self.banned_title_keywords): if self.movie_original_title is not None: if word.lower() not in self.movie_original_title.lower(): self.banned_title_keywords.append(word) else: self.banned_title_keywords.append(word) if len(similar_movie['release_date'][:4]) == 4 \ and int(similar_movie['release_date'][:4]) not in ([self.movie_release_year] + self.banned_years): self.banned_years.append(int(similar_movie['release_date'][:4]))