def findJustWatch(title, jw = None, jw_genres = None, imdb_id = None, tmdb_id = None):
    if jw == None:
        jw = JustWatch(country = 'US')
    if jw_genres is None:
        jw_genres = jw.get_genres()
    sel = 'n'
    jw_id = np.nan
    year = np.nan
    desc = None
    runtime = np.nan
    rt_score = np.nan
    gs = []
    streams = []
    jw_title = None
    res = jw.search_for_item(query = title)
    while sel != 'y' and 'total_results' in res and res['total_results'] > 0:
        for r in res['items']:
            if 'scoring' in r:
                provs = pd.DataFrame(r['scoring'])
                if (imdb_id != None and len(provs.value[provs.provider_type == 'imdb:id'].values) != 0):
                    if provs.value[provs.provider_type == 'imdb:id'].values != imdb_id:
                        next
                if (tmdb_id != None and len(provs.value[provs.provider_type == 'tmdb:id'].values) != 0):
                    if provs.value[provs.provider_type == 'tmdb:id'].values != tmdb_id:
                        next
                jw_title = unidecode(r['title']).replace(',', '')
                if jw_title is not None and title is not None:
                    if jw_title.lower() == title.lower():
                        sel = 'y'
                    elif title.lower() in jw_title.lower() or jw_title.lower() in title.lower():
                        sel = input(
                            "Matching '{}' with JustWatch '{}' ({})... OK? [y or n] ".format(title, jw_title, r['id'])
                        ).lower()
                if sel == 'y':
                    jw_id, year, desc, runtime, rt_score, streams = parseJustWatch(r)
                    break
                else:
                    print("Trying again...")
        break
    if sel != 'y':
        print("Unable to find match in JustWatch for '{}'".format(title))
        jw_id = tryFloat(input("What is the JustWatch ID?  "), get = True)
        if jw_id == '':
            jw_id = np.nan
        rt_score = tryFloat(input("What is the Rotten Tomatoes score?  "), get = True)
        if rt_score == '':
            rt_score = np.nan
        user_streams = input("On which services is it streaming? (separated by commas)  ")
        if user_streams != '':
            streams = [x.strip() for x in user_streams.split(',')]
        jw_title = None
    else:
        print("* MATCHED JustWatch")

    ## get genres
    if not np.isnan(jw_id):
        full_res = jw.get_title(title_id = int(jw_id))
        gs = parseGenres(full_res['genre_ids'], jw_genres) if 'genre_ids' in full_res.keys() else []

    return jw_id, year, desc, runtime, rt_score, gs, streams, jw_title
Example #2
0
        "'", '').replace('"', '').replace(' ', '').split(',')
    melhorGenero = Counter(melhorGenero)
    #print (melhorGenero.most_common()[0][0])
    return melhorGenero.most_common()[0][0]


#print (generosDos10MelhoresFilmesImdb())

#print (buscaFilmes())

#print(generoFilme(buscaFilmeImdb('avatar')))

#f = ia.search_movie('avatar')
#print(f[1])

genres = just_watch.get_genres()
#print(genres)

#showings_last_week = just_watch.get_upcoming_cinema(weeks_offset=6, nationwide_cinema_releases_only=False)
#print(showings_last_week)

#local_cinemas = just_watch.get_cinema_details()
#print(local_cinemas[0])

#results = just_watch.search_for_item(query='tropa de elite')
#print (results['items'][3]['title'])
#print (results['scoring'])


def buscaFilmeAvaliacao(string):
    resultado = just_watch.search_for_item(query=string)
        , 'rating' : []
        , 'netflix_rating' : []
        , 'genres' : []
        , 'netflix_instant' : []
        , 'streams' : []
        , 'year' : []
        , 'runtime' : []
        , 'overview' : []
        , 'tagline' : []
        , 'jw_id' : []
        , 'rt_score' : []
    })

## JustWatch genre list
jw = JustWatch(country = "US")
full_genres = jw.get_genres()

## accept new movies
keepgoing = False
add_movies = input("\nDo you want to add movies to the database? [y or n]  ")
if add_movies == 'y':
    keepgoing = True
while keepgoing:
    netflix_id = None ## no dependence on netflix IDs anymore
    netflix_rating = None ## not using netflix as rating basis anymore
    new_title = input("\nWhat is the name of the movie to add?  ")
    new_id = tryFloat(input("What is the MovieLens ID of the movie?  "), get = True)
    ## check if the movie is already in the DB
    if new_id != '' and len(movies_db[(movies_db.movielens_id == new_id)]):
        print('This movie seems to already exist in the DB. Skipping...')
        keepgoing = input("\nAdd another movie? [y or n]  ")
Example #4
0
 def test_get_genres(self):
     just_watch = JustWatch(country='US')
     genres = just_watch.get_genres()
     self.assertIsNotNone(genres)
     self.assertGreater(len(genres), 2)