Example #1
0
def search_movie(request):
    search_query = request.GET.get('search')
    search = tmdb.Search()
    response = search.movie(query=search_query)
    results = search.results
    return render(request, 'search.html', {
        'results': results,
        'query': search_query
    })
Example #2
0
 def match(title: str) -> List[MovieMatchCandidate]:
     results = tmdb.Search().movie(query=title)['results']
     matches = []
     for m in results:
         akas = tmdb.Movies(m["id"]).alternative_titles()['titles']
         akas = [a['title'] for a in akas]
         matches.append(TMDBApi._tmdb_to_movie_match_candidate(m, akas))
     logger.debug("IMDB matches {}".format(matches))
     return matches
Example #3
0
def search(request):
    form = MovieSearchForm(request.GET)
    if form.is_valid():
        movie_name = form.cleaned_data['movie']
        search = tmdb.Search()
        response = search.movie(query=movie_name, language='en-US', page=1, include_adult=False)
        return render(request, 'movie/search_result.html', response)
    else:
        raise Http404
Example #4
0
def find_tmdb_score(movies):
    voteTotal = 0
    for movie in movies:
        search = tmdb.Search()
        response = search.movie(query=movie)
        if search.results:
            chosenMovie = search.results[0]
            voteTotal = voteTotal + chosenMovie['vote_average']
    return voteTotal / len(movies)
Example #5
0
    def _retrieve_show_images_from_tmdb(show, img_type):
        types = {
            'poster': 'poster_path',
            'banner': None,
            'fanart': 'backdrop_path',
            'poster_thumb': 'poster_path',
            'banner_thumb': None
        }

        def _request(self, method, path, params=None, payload=None):
            url = self._get_complete_url(path)
            params = self._get_params(params)

            requests.packages.urllib3.disable_warnings()
            response = requests.request(
                method,
                url,
                params=params,
                data=json.dumps(payload) if payload else payload,
                verify=False)

            #response.raise_for_status()
            response.encoding = 'utf-8'
            return response.json()

        from tmdbsimple.base import TMDB
        TMDB._request = _request

        # get TMDB configuration info
        tmdb.API_KEY = sickrage.srCore.srConfig.TMDB_API_KEY
        response = tmdb.Configuration().info()
        base_url = response['images']['base_url']
        sizes = response['images']['poster_sizes']

        def size_str_to_int(x):
            return float("inf") if x == 'original' else int(x[1:])

        max_size = max(sizes, key=size_str_to_int)

        sickrage.srCore.srLogger.debug("Searching for any " + img_type +
                                       " images on TMDB for " + show.name)

        try:
            search = tmdb.Search()
            from sickrage.core.helpers.show_names import allPossibleShowNames
            for show_name in set(allPossibleShowNames(show)):
                for result in search.collection(
                        query=show_name)['results'] + search.tv(
                            query=show_name)['results']:
                    if types[img_type] and getattr(result, types[img_type]):
                        return "{0}{1}{2}".format(base_url, max_size,
                                                  result[types[img_type]])
        except:
            pass

        sickrage.srCore.srLogger.debug("Could not find any " + img_type +
                                       " images on TMDB for " + show.name)
Example #6
0
def search_tv(title):
    """
    Connects to API to search for a specific tv show by title.
    """
    search = tmdb.Search()

    response = search.tv(query=title)

    return search.results
Example #7
0
def searchTMDB(query, api_key):
    query = removeSpecialChars(query)
    tmdb.API_KEY = api_key
    while True:
        try:
            search = tmdb.Search()
            return search.movie(query=query)
        except exceptions.HTTPError as e:
            exceptionsTMDB(e)
def movieSearch(movieName):
    search = tmdb.Search()
    responses = search.movie(query=movieName)

    movie = tmdb.Movies(responses['results'][0]['id'])

    info = movie.info()

    return info
Example #9
0
def search(title):
    search = tmdb.Search()
    response = search.movie(query=title)
    record = []
    for info in search.results:
        record.append(info['title'])
        record.append(info['release_date'])
        record.append(info['popularity'])
    return record
Example #10
0
def search_movie():
	results = []
	response.title = T("Search Movie")
	form = SQLFORM.factory(Field("search", "string"))
	if form.validate():
		search = tmdb.Search()
		r = search.movie(query=form.vars.search, language="es")
		results = search.results
	return dict(share=False, form=form, results=results)
Example #11
0
def get_movie_search_results(query, page):
    key = f'tmdb_movie_search_{query}_page_{page}'
    results = cache.get(key, None)
    if results is None:
        results = tmdb.Search().movie(query=query,
                                      page=page,
                                      language=LANGUAGE)
        cache.set(key, results, CACHE_TIMEOUT)
    return results
Example #12
0
def search_movie(title):
    """
    Connects to API to search for a specific movie by title.
    """
    search = tmdb.Search()

    response = search.movie(query=title)

    return search.results
Example #13
0
class QueryHelper():
    '''
    Utility class that prints titles and IDs for a given title query
    '''
    search = tmdb.Search()
    def __init__(self, title):
        reponse = self.search.movie(query=title)
        for each in self.search.results:
            print(('\t '+str(each['title'])+' '+str(each['id'])))
Example #14
0
def get_cast_name_tmdb(series_name='two and half man'):
    """
    return cast name from tmdb
    series_name : name of tv series
    """
    tmdb.API_KEY = 'd8eb79cd5498fd8d375ac1589bfc78ee'
    search = tmdb.Search()
    response = search.tv(query=series_name)
    tv1 = tmdb.TV(id=response['results'][0]['id'])
    return [i['name'] for i in tv1.credits()['cast']]
Example #15
0
def MovieSearch(title):
    search = tmdb.Search()
    title = StripFileType(title)
    title = StripDate(title)
    response = search.movie(query=title)
    for r in response['results']:
        if r['title'] == title:
            return r['title'] + " (" + r['release_date'][:4] + ')'
    return response['results'][0]['title'] + " (" + response['results'][0][
        'release_date'][:4] + ')'
Example #16
0
 def get(self, request, *args, **kwargs):
     form = SearchForm(request.GET)
     if form.is_valid():
         data = form.cleaned_data
         search_dict = tmdb.Search().movie(query=data['search_input'])
         search_results = search_dict['results']
     return render(request, self.template_name, {
         'search': search_results,
         'data': data
     })
Example #17
0
def search_show():
	results = []
	response.title = T("Search TV show")
	form = SQLFORM.factory(Field("search", "string"), Field("language", "reference languages", default="es", requires=IS_IN_DB(db, db.languages.code), required=True))
	if form.validate():
		search = tmdb.Search()
		session.language_for_search = form.vars.language
		r = search.tv(query=form.vars.search, language=form.vars.language)
		results = search.results
	return dict(share=False, form=form, results=results)
Example #18
0
 def get_cast_name_tmdb(self, series_name='two and half man'):
     """
     tv series or title of movie
     returns list of cast
     """
     tmdb.API_KEY = 'd8eb79cd5498fd8d375ac1589bfc78ee'
     search = tmdb.Search()
     response = search.tv(query=series_name)
     tv1 = tmdb.TV(id=response['results'][0]['id'])
     return [i['name'] for i in tv1.credits()['cast']]
Example #19
0
def getMovieDataFromTMDB(title):
    search = tmdb.Search()
    response = search.movie(query=title)
    posterPathString = "https://image.tmdb.org/t/p/w300/"
    backdropPathString = "https://image.tmdb.org/t/p/w500/"

    returnDic = search.results[0]
    returnDic["poster_path"] = posterPathString + returnDic["poster_path"]
    print "Download datas from TMDB"
    return returnDic
Example #20
0
def search():
    l = tmdb.Search()
    while True:
        title = str(input('Show Name: '))
        m = l.tv(query=title)
        try:
            seasonInfo(l.results[0]['id'], l.results[0]['original_name'])
            break
        except IndexError as e:
            print('Title not found')
Example #21
0
def search_tv(data):
    search = tmdb.Search()
    response = search.tv(query=data)
    tvList = []
    totalPages = 2

    for s in search.results:
        tvList.append(s)

    return tvList
Example #22
0
 def search_api(cls, keyword):
     try:
         tmdb_search = tmdbsimple.Search().tv(query=keyword,
                                              language='ko',
                                              include_adult=True)
         return tmdb_search
     except Exception as exception:
         logger.error('Exception:%s', exception)
         logger.error(traceback.format_exc())
     return
Example #23
0
def add_score():
    username = request.form["username"].encode('utf-8')
    moviename = request.form["moviename"].encode('utf-8')
    if moviename:
        moviescore = float(request.form["moviescore"])
        search = tmdb.Search()
        response = search.movie(query=moviename.split("(")[0])
        if response['results']:
            set_data(username, moviename, moviescore)
    return render_template("redirect-user.html", data=username)
Example #24
0
    def search(self, query):
        for result in tmdb.Search().movie(query=query)['results']:
            poster_path = result['poster_path']

            yield TmdbMovie(
                release_date=self.parse_date(result.pop('release_date')),
                poster_url=self._get_poster_url(poster_path),
                mobile_poster_url=self._get_mobile_poster_url(poster_path),
                tmdb_id=result['id'],
                **result)
Example #25
0
def search_movie(data):
    search = tmdb.Search()
    response = search.movie(query=data)
    movieList = []
    totalPages = 2

    for s in search.results:
        movieList.append(s)

    return movieList
Example #26
0
def movie_search(title):
    tmdb.API_KEY = api_key
    search = tmdb.Search()
    response = search.movie(query=title)
    data = []
    for s in search.results:
        data.append(s['title'])
    data = pd.DataFrame(data, columns=['Name'])
    data = data.to_dict('record')
    return data
Example #27
0
def get_recommend(parameters):
    movie = Movie()
    search = tmdb.Search()
    response = search.movie(query=parameters['movie_name'])
    idd = response['results'][0]['id']
    recommendations = movie.recommendations(idd)
    ans = ''
    for recommendation in recommendations:
        ans += (recommendation.title + "\n")
    return ans
Example #28
0
def search(movie):
    """ 
    Takes a string containing a movie name and returns
    a list of matching titles from tmdb including the 
    name, release date, and tmdb id
    """
    search = tmdb.Search()
    response = search.movie(query=movie)
    for s in search.results:
        print(s['title'], s['release_date'], s['id'])
Example #29
0
def scrapeUsingId(start):
    tmdb.API_KEY = 'f0dfd6aa643d9c600f57991473f2eaf3'
    search = tmdb.Search()
    moviesData = []
    path = '/Users/Rishi/Desktop/Study/Fall2017/NLP/Project/Movie-Revenue-Prediction_Sentiment-Analysis/dataset2.csv'
    with open(path, 'rb') as csv_file:
        reader = list(csv.reader(csv_file))
        count = 0
        if start > len(reader):
            return
        for movieInfo in reader[start:start + 40]:
            movieId = movieInfo[1]
            movie_Info = tmdb.Movies(movieId)
            res = movie_Info.info()
            movieInfo.append(res['vote_count'])
            movieInfo.append(res['vote_average'])
            movieInfo.append(res['runtime'])
            movieInfo.append(res['budget'])
            movieInfo.append(res['revenue'])
            moviesData.append(movieInfo)
            count += 1
    #movieDetails = defaultdict()
    #movieDetails = []

    # if start>len(movieNames):
    # 	return
    # for name in movieNames[start:start+40]:

    # 	try:

    # 	except Exception:
    # 		print "lalalala"
    #movieDetails[name].append(result['genre_ids'])
        '''
		if str(result['title']) == str(name):
			if name not in movieDetails:
				movieDetails[name] = []
			movieDetails[name].append(int(result['id']))
			movieDetails[name].append(result['genre_ids'])

				# movie_id = int(result['id'])
				# movie = tmdb.Movies(movie_id)
				# res = movie.info()
				
				# print movie.title, movie.runtime, movie.budget, movie.revenue, movie.release_date, movie.popularity, movie.adult, movie.genres
				# print "\n"
		'''

    # for movie in movieDetails:
    # 	movie_id = movie[1]

    with open('dataset3.csv', 'a') as csv_file:
        writer = csv.writer(csv_file)
        for movie in moviesData:
            writer.writerow(movie)
Example #30
0
class Movie():
    """
    This class provides a way to store movie related information.
    Utilizes the tmdbsimple library, a wrapper for The Movie Database (TMDb) API v3    
    """
    # obtain configuration info from TMDb to generate poster URLs
    conf = tmdb.Configuration()
    reponse = conf.info()

    # object for querying the database
    search = tmdb.Search()

    # class variables
    YOUTUBE_BASE_URL = 'https://www.youtube.com/watch?v='
    POSTER_SECURE_BASE_URL = conf.images['secure_base_url']
    POSTER_SIZE = 'w342'

    def __init__(self, title):
        self.movie = tmdb.Movies(self.get_movie_id(title))
        self.title = self.get_movie_title(title)
        self.poster_image_url = self.POSTER_SECURE_BASE_URL + \
            self.POSTER_SIZE + self.get_poster_path()
        self.trailer_youtube_url = self.YOUTUBE_BASE_URL + self.get_youtube_key()

    def get_movie_id(self, title):
        '''
        Returns the movie ID for a given title query
        If title is an ID itself, function simply returns the ID
        '''
        if type(title) is int:
            return title
        else:
            reponse = self.search.movie(query=title)
            return self.search.results[0]['id']

    def get_movie_title(self,title):
        '''
        Returns the movie title from the database for a given title query
        If title is an ID itself, function returns title from info()
        '''
        if type(title) is int:
            response = self.movie.info()
            return self.movie.title
        else:
            return self.search.results[0]['title']

    def get_youtube_key(self):
        '''Returns the YouTube key for the movie trailer'''
        response = self.movie.videos()
        return self.movie.results[0]['key']

    def get_poster_path(self):
        '''Returns the poster path for the movie poster'''
        response = self.movie.images()
        return self.movie.posters[0]['file_path']