def tmdb(video_type, title, year=None): search = tmdbsimple.Search() if video_type.startswith('tv'): content = search.tv(query=utility.encode(title), first_air_date_year=year, language=language, include_adult='true') if content['total_results'] == 0: content = search.tv(query=utility.encode(title), language=language, include_adult='true') if content['total_results'] == 0: if '(' in title: title = title[:title.find('(')] content = search.tv(query=utility.encode(title), first_air_date_year=year, language=language, include_adult='true') elif ':' in title: title = title.replace(':', '+') content = search.tv(query=utility.encode(title), first_air_date_year=year, language=language, include_adult='true') else: content = search.movie(query=utility.encode(title), year=year, language=language, include_adult='true') if content['total_results'] == 0: content = search.movie(query=utility.encode(title), language=language, include_adult='true') if content['total_results'] == 0: if '(' in title: title = title[:title.find('(')] content = search.movie(query=utility.encode(title), year=year, language=language, include_adult='true') elif ':' in title: title = title.replace(':', '+') content = search.movie(query=utility.encode(title), year=year, language=language, include_adult='true') if content['total_results'] == 0: content = search.movie(query=utility.encode(title), year=year, language=language, include_adult='true') return content
def search_movies(title, year=None): search = tmdb.Search() response = search.movie(query=title, year=year, language=LANGUAGE) return search.results