def test_get(self): '''Test that we at least don't fail to get a response''' just_watch = JustWatch(country='US') try: just_watch.search_for_item(query='the matrix', page_size=1) except Exception as e: self.fail(f"test_get() failed with Exception: {e}") # noqa
def buscaPorGeneroDosMelhoresFilmes(): genero = generosDos10MelhoresFilmesImdb() for generos in just_watch.get_genres(): if genero.lower() == generos['technical_name']: g = generos['short_name'] jw = JustWatch(genres=[g]) resultado = jw.search_for_item(content_types=['movie']) filme = {'nome': [], 'popularidade': [], 'preco': []} aux = 0.0 for i in resultado['items']: res = popularidadeFilme(i['title']) if (aux <= res): var = buscaFilmeJW(i['title']) aux = res filme['nome'].append(i['title']) filme['popularidade'].append(var['tmdb_popularity']) filme['preco'].append(var['offers']) return filme #print (generosDos10MelhoresFilmesImdb()) #print(buscaPorGeneroDosMelhoresFilmes()) #print (buscaFilmeAvaliacao('tropa de elite')) #print (just_watch.get_genres())
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
def hello(): just_watch = JustWatch(country='ES') results = just_watch.search_for_item(query="Friends") item = results["items"][0] stream_platforms = [] purchase_platforms = [] platforms = getPlatforms(item["offers"], stream_platforms, purchase_platforms) # print "--------------------------------------------------" # print "- title: %s" % item["title"] # print "- original_title: %s" % item["original_title"] # print "- original_release_year: %s" % item["original_release_year"] # print "- tmdb_popularity: %s" % item["tmdb_popularity"] # print "- short_description: %s" % item["short_description"] # print "- stream_platforms: %s" % stream_platforms # print "- purchase_platforms: %s" % purchase_platforms # print "--------------------------------------------------" response = "" response += "*%s (%s)* \n" % (item["title"], item["original_release_year"]) response += "\n" response += "_%s_ \n" % item["short_description"] response += "\n" response += "Streaming platforms:\n" for url in stream_platforms: response += "- %s\n" % url response += "\n" response += "Purchase platforms:\n" for url in purchase_platforms: response += "- %s\n" % url return jsonify(item)
def getStreamables(movie): just_watch = JustWatch(country='SE') print(movie[1]) results = just_watch.search_for_item(query=movie[1], content_types=['movie']) try: items = results['items'] item = items[0] offers = item['offers'] except: print("Could not find any offers") return None streams = [] for x in offers: stream = {} if (x['monetization_type'] == 'flatrate' or x['monetization_type'] == 'free'): stream['providerID'] = x['provider_id'] url = x['urls'] stream['url'] = url['standard_web'] streams.append(stream) streams = removeDupes(streams) return streams
def test_locale_works_with_full_country_name(self): '''Test that full country name can be used to get locale ''' just_watch = JustWatch(country='Australia') self.assertEqual(just_watch.locale, 'en_AU') res = just_watch.search_for_item(query='the matrix', page_size=1) self.assertIsNotNone(res)
def test_locale_defaults_correctly(self): ''' Test that locale defaults to en_AU ''' just_watch = JustWatch(country='NotRealCountry') self.assertEqual(just_watch.locale, 'en_AU') res = just_watch.search_for_item(query='the matrix', page_size=1) self.assertIsNotNone(res)
def test_results_contains_query_item(self): '''Test that searching for something correctly returns correct results''' search_item = 'the matrix' just_watch = JustWatch(country='US') results = just_watch.search_for_item(query=search_item, page_size=1) first_result_title = results['items'][0]['title'].lower() self.assertEqual(search_item, first_result_title)
def netflix(title): just_watch = JustWatch(country='US') try: request = just_watch.search_for_item(query=title) offers = request["items"][0]["offers"] for e in offers: if e["monetization_type"] == "flatrate" and e["provider_id"] == 8: return True return False except Exception as e: return None
def do_GET(self): qs = parse_qs(urlparse(self.path).query) country = qs["country"] if country and len(country[0]) > 1: justwatch_country = country[0] else: justwatch_country = 'US' just_watch = JustWatch(country=justwatch_country) results = just_watch.search_for_item(providers=['mbi']) self.send_response(200) self.send_header('Content-type', 'application/json') self.end_headers() self.wfile.write(json.dumps(results).encode()) return
def getImageLinks(): jw = JustWatch(country='IN', genres=['act', 'scf', 'com']) results = jw.search_for_item()['items'][:5] resultsArr = [] for item in results: resultsArr.append({ 'title': item['title'], 'poster': base_url + item['poster'].split('{')[0] + poster_size }) return resultsArr
def findJustWatch(title): sel = 'n' jw_id = np.nan year = np.nan desc = None runtime = np.nan rt_score = np.nan gs = [] streams = [] jw_title = None jw = JustWatch(country = "US") res = jw.search_for_item(query = title) while sel != 'y' and res['total_results'] > 0: for r in res['items']: jw_title = unidecode(r['title']).replace(',', '') 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, gs, streams = parseJustWatch(r) break else: print("Trying again...") break if sel != 'y': print("Unable to find match in JustWatch for '{}'".format(title)) print("Streams won't be shown.") jw_id = input("Enter the JustWatch ID for the movie if it exists: ") if jw_id == '': jw_id = np.nan else: jw_id = float(jw_id) user_streams = input("Enter streams separated by commas if you want to include manually (ie. HBO, Amazon, Netflix, FXNow): ") if user_streams != '': streams = [x.strip() for x in user_streams.split(',')] print("Rotten Tomatoes score won't be shown.") user_score = input("Enter Rotten Tomatoes score if you want to include manually: ") if user_score == '': rt_score = np.nan else: rt_score = float(user_score) jw_title = None else: print("* MATCHED JustWatch") return jw_id, year, desc, runtime, rt_score, gs, streams, jw_title
def get_stream_data(query): stream_data = {} # Compatibility for Current Userge Users try: country = Config.WATCH_COUNTRY except Exception: country = "IN" # Cooking Data just_watch = JustWatch(country=country) results = just_watch.search_for_item(query=query) movie = results["items"][0] stream_data["title"] = movie["title"] stream_data["movie_thumb"] = ( "https://images.justwatch.com" + movie["poster"].replace("{profile}", "") + "s592" ) stream_data["release_year"] = movie["original_release_year"] try: print(movie["cinema_release_date"]) stream_data["release_date"] = movie["cinema_release_date"] except KeyError: try: stream_data["release_date"] = movie["localized_release_date"] except KeyError: stream_data["release_date"] = None stream_data["type"] = movie["object_type"] available_streams = {} for provider in movie["offers"]: provider_ = get_provider(provider["urls"]["standard_web"]) available_streams[provider_] = provider["urls"]["standard_web"] stream_data["providers"] = available_streams scoring = {} for scorer in movie["scoring"]: if scorer["provider_type"] == "tmdb:score": scoring["tmdb"] = scorer["value"] if scorer["provider_type"] == "imdb:score": scoring["imdb"] = scorer["value"] stream_data["score"] = scoring return stream_data
def justwatch_scrape(movie_dict): movie_dict_jw = {} save_info = [] rank = 0 movie_dict_jw = movie_dict # Loop through movies list, searching for each movie in the justwatch API, # then finding out if it's available to stream for free and where. # If it is, it's printed. Otherwise, it's ignored. just_watch = JustWatch(country="GB") for key, value in movie_dict_jw.items(): results = just_watch.search_for_item(query=key) rank += 1 for result in results["items"]: try: if result["title"] == key and result[ "original_release_year"] == int(value): length = len(result["offers"]) for i in range(length): if result["offers"][i]["provider_id"] == 8: save_info.append( streaming_details(rank, key, "Netflix")) break if result["offers"][i]["provider_id"] == 9: save_info.append( streaming_details(rank, key, "Amazon Prime Video")) break if result["offers"][i]["provider_id"] == 38: save_info.append( streaming_details(rank, key, "BBC iPlayer")) break if result["offers"][i]["provider_id"] == 103: save_info.append( streaming_details(rank, key, "All4")) break except (IndexError, KeyError): pass print("\nDone!\n") return save_info
def get_stream_data(query): stream_data = {} # Compatibility for Current Userge Users try: country = Config.WATCH_COUNTRY except Exception: country = "IN" # Cooking Data just_watch = JustWatch(country=country) results = just_watch.search_for_item(query=query) movie = results['items'][0] stream_data['title'] = movie['title'] stream_data['movie_thumb'] = ("https://images.justwatch.com" + movie['poster'].replace("{profile}", "") + "s592") stream_data['release_year'] = movie['original_release_year'] try: print(movie['cinema_release_date']) stream_data['release_date'] = movie['cinema_release_date'] except KeyError: try: stream_data['release_date'] = movie['localized_release_date'] except KeyError: stream_data['release_date'] = None stream_data['type'] = movie['object_type'] available_streams = {} for provider in movie['offers']: provider_ = get_provider(provider['urls']['standard_web']) available_streams[provider_] = provider['urls']['standard_web'] stream_data['providers'] = available_streams scoring = {} for scorer in movie['scoring']: if scorer['provider_type'] == "tmdb:score": scoring['tmdb'] = scorer['value'] if scorer['provider_type'] == "imdb:score": scoring['imdb'] = scorer['value'] stream_data['score'] = scoring return stream_data
def getFilmOffers(film): just_watch = JustWatch(country='ES') results = just_watch.search_for_item(query=film) if len(results['items']) > 0: filmOffers = results['items'][0]['offers'] filmTitle = results['items'][0]['title'] validOffers = [] providers = {} for offer in filmOffers: if offer['monetization_type'] == 'flatrate': validOffers.append(offer) for offer in validOffers: if offer['provider_id'] not in providers: providers[offer['provider_id']] = getProviderName(offer['provider_id']) if len(providers) > 0: return "<say-as interpret-as=\"interjection\">Aqui lo tengo!</say-as>. {} está disponible en {}".format(filmTitle,' '.join(list(providers.values()))) return "Lo siento, pero no he encontrado nada para {}. <say-as interpret-as=\"interjection\">Prueba con otra!</say-as>".format(film)
def getJustWatch(title, jw_id, rt_score, streams, gs): sel = 'n' jw = JustWatch(country = "US") ## JustWatch breaks if you bombard it too much, so use a VPN while True: try: res = jw.search_for_item(query = title) except: print("JustWatch not reached. Try again...") print("** Rate Limit was likely exceeded. Please use VPN. **") else: break while sel != 'y' and res['total_results'] > 0: for r in res['items']: if r['id'] == int(jw_id): sel = 'y' jw_id, year, desc, runtime, rt_score, gs, streams = parseJustWatch(r) break else: print("Trying again...") break if sel != 'y': print("Results didn't contain match for '{}' using ID ({}).".format(title, jw_id)) new_jw_id = input("Enter the JustWatch ID for the movie if it exists (or [return] to keep current value): ") if new_jw_id == '': jw_id = jw_id else: jw_id = float(new_jw_id) print("Current streams: {}".format(streams)) user_streams = input("Enter streams separated by commas if you want to include manually (or [return] to keep current): ") if user_streams != '': for s in [x.strip() for x in user_streams.split(',')]: if s not in streams: streams.append(s) print("Current Rotten Tomatoes score: {}".format(rt_score)) user_score = input("Enter Rotten Tomatoes score if you want to include manually (or [return] to keep current): ") if user_score == '': rt_score = rt_score else: rt_score = float(user_score) else: print("* MATCHED JustWatch") return jw_id, rt_score, streams, gs
def query(): w_from = request.form.get('From') w_to = request.form.get('To') w_query = request.form.get('Body') just_watch = JustWatch(country='ES') results = just_watch.search_for_item(query=w_query) item = results["items"][0] stream_platforms = [] purchase_platforms = [] platforms = getPlatforms(item["offers"], stream_platforms, purchase_platforms) # print "--------------------------------------------------" # print "- title: %s" % item["title"] # print "- original_title: %s" % item["original_title"] # print "- original_release_year: %s" % item["original_release_year"] # print "- tmdb_popularity: %s" % item["tmdb_popularity"] # print "- short_description: %s" % item["short_description"] # print "- stream_platforms: %s" % stream_platforms # print "- purchase_platforms: %s" % purchase_platforms # print "--------------------------------------------------" response = "" response += "*%s (%s)* \n" % (item["title"], item["original_release_year"]) response += "\n" response += "%s" % item["short_description"] response += "\n" response += "Streaming platforms:\n" for url in stream_platforms: response += "- %s\n" % url response += "\n" response += "Purchase platforms:\n" for url in purchase_platforms: response += "- %s\n" % url responseTwilio(w_to, w_from, response) return "Ok"
def siftJustWatch(title, jw=None): if jw == None: jw = JustWatch(country='US') sel = 'n' jw_title = None res = jw.search_for_item(query=title) for r in res['items']: if 'scoring' in r: jw_title = unidecode(r['title']).replace(',', '') print(r['id']) print(r['title']) print(r['original_release_year']) if 'short_description' in r.keys(): print(unidecode(r['short_description'])) sel = input("Matching '{}' with '{}' ({})... OK? [y or n] ".format( title, jw_title, r['id'])).lower() if sel == 'y': jw_id = r['id'] break if sel != 'y': print("Unable to find match in JustWatch for '{}'".format(title)) else: print("JustWatch ID is {}".format(int(jw_id)))
def get_movie(title, country, content_types=['movie'], monetization_types=['flatrate']): just_watch = JustWatch(country=country) provider_details = just_watch.get_providers() results = just_watch.search_for_item(query=title, content_types=content_types) if len(results['items']) == 0: return first_movie = results['items'][0] return { 'title': first_movie['title'], 'id': get_tmdb_id(first_movie), 'offers': get_offers(first_movie, country, provider_details, monetization_types) }
def find(name): log.debug("searching for '" + name + "'") # nfx, stn just_watch = JustWatch(country='US', providers=['nfx']) results = just_watch.search_for_item(query=name) log.debug("(results=" + str(len(results["items"])) + ")") for item in results["items"]: log.debug("### result: " + item["title"]) if item["title"].casefold() == name.casefold( ) and item["object_type"] != "show": log.info("yay, found it:: " + item["title"]) return True print( "=====================================================================" ) print(results["items"][0]) print( "=====================================================================" )
from justwatch import JustWatch just_watch = JustWatch(country='US') results = just_watch.search_for_item(query='the matrix') just_watch = JustWatch(genres=['act', 'scf', 'hrr']) results_by_genres = just_watch.search_for_item() just_watch = JustWatch() results_by_providers = just_watch.search_for_item(providers=['nfx', 'stn']) """ This sample demonstrates a simple skill built with the Amazon Alexa Skills Kit. The Intent Schema, Custom Slots, and Sample Utterances for this skill, as well as testing instructions are located at http://amzn.to/1LzFrj6 For additional samples, visit the Alexa Skills Kit Getting Started guide at http://amzn.to/1LGWsLG """ from __future__ import print_function # --------------- Helpers that build all of the responses ---------------------- def build_speechlet_response(title, output, reprompt_text, should_end_session): return {
from justwatch import JustWatch import json just_watch = JustWatch(country='US') results = just_watch.search_for_item(providers=['nfx']) for result in results: movie_id = result['id'] title = '' if 'title' in result: title = result['title'] short_description if 'short_description' in result: short_description = result['short_description'] original_release_year = result['original_release_year'] object_type = result['object_type'] original_title = result['original_title'] original_language = result['original_language'] max_season_number = result['max_season_number'] age_certification = result['age_certification']
377: "Disney+ Hotstar" } offerType = { "buy": "Buy", "rent": "Rent", "flatrate": "Stream", "free": "Free" } imdb_key = "b02ef8fd" imdb_url = "http://www.omdbapi.com/" imdb_headers = {"apikey": imdb_key} # print(results) # q = input("Enter the name of the title you want to search for:\n") q = str(input('Please enter what you want to search for:\n->')) movie_title = ' '.join(word[0].upper() + word[1:] for word in q.split()) results = jw.search_for_item(query=q) totalR = int(results['total_results']) print("Found {0} results:".format(totalR)) starline0 = "*" * 75 if totalR < 10: print("Showing all results:") time.sleep(1) print(starline0) print("{:<8s}{:<50s}{:<8s}{:<5s}".format("Index", "Title", "Type", "Release Year")) print(starline0) for i in range(totalR): itemTitle = results['items'][i]['title'] itemType = results['items'][i]['object_type'] itemYear = results['items'][i]['original_release_year'] print("{:<8d}{:<50s}{:<8s}{:<5d}".format(i + 1, itemTitle, itemType,
def result(): moodDict = { "Joy": 'act', "Sadness": 'cmy', "Anger": 'trl', "Fear": 'fnt', "Analytical": 'doc', "Confident": 'hrr', "Tentative": 'rma' } tweet = lastTenTweets() tweets = [] for i in range(len(tweet)): tweets.append(tweet[i]['text']) text = "" for i in range(len(tweets)): text += " " text += tweets[i] just_watch = JustWatch(country='US') resultsMovies = [] resultsTV = [] mood = tone_analyzer.tone(text, content_type="text/plain") max_mood = mood.get('document_tone').get('tones')[0].get('tone_name') selected = request.form.getlist('check') genre = moodDict[max_mood] for i in range(len(selected)): if selected[i] == 'Netflix': results_by_multiplea = just_watch.search_for_item( providers=['nfx'], genres=[genre], content_types=['movie']) movies = results_by_multiplea['items'] for x in range(len(movies)): resultsMovies.append(movies[x]) results_by_multiplef = just_watch.search_for_item( providers=['nfx'], genres=[genre], content_types=['show']) tv = results_by_multiplef['items'] for x in range(len(tv)): resultsTV.append(tv[x]) if selected[i] == 'Playstation Video': results_by_multipleb = just_watch.search_for_item( providers=['pls'], content_types=['movie'], genres=[genre]) movies = results_by_multipleb['items'] for x in range(len(movies)): resultsMovies.append(movies[x]) results_by_multiplef = just_watch.search_for_item( providers=['pls'], genres=[genre], content_types=['show']) tv = results_by_multiplef['items'] for x in range(len(tv)): resultsTV.append(tv[x]) if selected[i] == 'Itunes': results_by_multiplec = just_watch.search_for_item( providers=['itu'], content_types=['movie'], genres=[genre]) movies = results_by_multiplec['items'] for x in range(len(movies)): resultsMovies.append(movies[x]) results_by_multiplef = just_watch.search_for_item( providers=['itu'], genres=[genre], content_types=['show']) tv = results_by_multiplef['items'] for x in range(len(tv)): resultsTV.append(tv[x]) if selected[i] == 'Google Play': results_by_multipled = just_watch.search_for_item( providers=['ply'], content_types=['movie'], genres=[genre]) movies = results_by_multipled['items'] for x in range(len(movies)): resultsMovies.append(movies[x]) results_by_multiplef = just_watch.search_for_item( providers=['ply'], genres=[genre], content_types=['show']) tv = results_by_multiplef['items'] for x in range(len(tv)): resultsTV.append(tv[x]) results = [ resultsMovies[randint(0, len(resultsMovies) - 1)], resultsTV[randint(0, len(resultsTV) - 1)] ] return render_template('suggest.html', selected=results, mood=max_mood, tweets=text)
Guardians of the Galaxy (2014) Before Sunset (2004) The Best Years of Our Lives (1946) Paris, Texas (1984) Pirates of the Caribbean: The Curse of the Black Pearl (2003) Beauty and the Beast (1991) The Battle of Algiers (1966) Gangs of Wasseypur (2012) Dog Day Afternoon (1975)""" list_of_movies = list_of_movies.split('\n') provider = str(sys.argv[1]) out='' print ("Searching for: " + provider) for movie in list_of_movies: results_by_providers = just_watch.search_for_item(query=movie, providers=[provider], content_types=['movie']) out = 'n' if len(results_by_providers['items']) > 0: for result in results_by_providers['items']: if result['title'] == movie[:-7] and \ result['original_release_year'] == int(movie[-5:-1]): out = 'y' print(out)
def result(): if g.user is None: return redirect(url_for('login', next=request.url)) # created a mood dictionary that pairs all the possible main moods detected by the tone analyzer with a corresponding genre moodDict = { "Joy": 'act', "Sadness": 'cmy', "Anger": 'trl', "Fear": 'fnt', "Analytical": 'doc', "Confident": 'hrr', "Tentative": 'rma' } # concatinating all of the users tweets in variable text, which is then passed to the IBM Watson Tone Analyzer API tweet = lastTwentyTweets() tweets = [] for i in range(len(tweet)): tweets.append(tweet[i]['text']) text = "" for i in range(len(tweets)): text += " " text += tweets[i] just_watch = JustWatch(country='US') resultsMovies = [] resultsTV = [] mood = tone_analyzer.tone(text, content_type="text/plain") max_mood = mood.get('document_tone').get('tones')[0].get('tone_name') selected = request.form.getlist('check') # following if statement checks that the user picks at least one provider when requesting a suggestion if len(selected) == 0: return render_template('index.html', tweets=tweet, noneCheck=True) genre = moodDict[max_mood] # Here we implement our caching, before requesting movies / tvshows of the appropriate genre and correct provider # from the JustWatch API, the following code checks our SQL database to see if the relevant movies / tvshows are # already being present in the Database, if so the suggestion is made from this data cachedMovies = searchCachedMovies(selected, genre) cachedShows = searchCachedShows(selected, genre) if cachedMovies != (): if cachedShows != (): # to allow for some variation in the recommended movie / show a random index is used chosenMovie = cachedMovies[randint(0, len(cachedMovies) - 1)] chosenShow = cachedShows[randint(0, len(cachedShows) - 1)] return render_template('suggest.html', cachedMovie=chosenMovie, cachedShow=chosenShow, mood=max_mood, tweets=text) # below occurs if no relevant info found within the Database, the following code retrieves relevant movies and # tv shows depending on what providers the user selected, all of the results are stored within our database # using the storeMovie and storeShow helper function, additionally the linkMovieProvider and linkShowProvider # helper functions are used to ensure that the movies / tvshows are linked to the correct provider # (this is done to ensure DB accuracy) else: for i in range(len(selected)): # for loop goes through all the selected providers and retrieves / stores relevant data from them, # each if statement checks which provider the current index represents and then passes the relevent data # for retrieval and storage if selected[i] == 'Netflix': results_by_multiplea = just_watch.search_for_item( providers=['nfx'], genres=[genre], content_types=['movie']) movies = results_by_multiplea['items'] for x in range(len(movies)): storeMovie(movies[x]['title'], movies[x]['short_description'], genre) linkMovieProvider(movies[x]['title'], 'Netflix') resultsMovies.append(movies[x]) results_by_multiplef = just_watch.search_for_item( providers=['nfx'], genres=[genre], content_types=['show']) tv = results_by_multiplef['items'] for x in range(len(tv)): storeShow(tv[x]['title'], tv[x]['short_description'], genre) linkShowProvider(tv[x]['title'], 'Netflix') resultsTV.append(tv[x]) if selected[i] == 'Playstation Video': results_by_multipleb = just_watch.search_for_item( providers=['pls'], content_types=['movie'], genres=[genre]) movies = results_by_multipleb['items'] for x in range(len(movies)): storeMovie(movies[x]['title'], movies[x]['short_description'], genre) linkMovieProvider(movies[x]['title'], 'Playstation Video') resultsMovies.append(movies[x]) results_by_multiplef = just_watch.search_for_item( providers=['pls'], genres=[genre], content_types=['show']) tv = results_by_multiplef['items'] for x in range(len(tv)): storeShow(tv[x]['title'], tv[x]['short_description'], genre) linkShowProvider(tv[x]['title'], 'Playstation Video') resultsTV.append(tv[x]) if selected[i] == 'Itunes': results_by_multiplec = just_watch.search_for_item( providers=['itu'], content_types=['movie'], genres=[genre]) movies = results_by_multiplec['items'] for x in range(len(movies)): storeMovie(movies[x]['title'], movies[x]['short_description'], genre) linkMovieProvider(movies[x]['title'], 'Itunes') resultsMovies.append(movies[x]) results_by_multiplef = just_watch.search_for_item( providers=['itu'], genres=[genre], content_types=['show']) tv = results_by_multiplef['items'] for x in range(len(tv)): storeShow(tv[x]['title'], tv[x]['short_description'], genre) linkShowProvider(tv[x]['title'], 'Itunes') resultsTV.append(tv[x]) if selected[i] == 'Google Play': results_by_multipled = just_watch.search_for_item( providers=['ply'], content_types=['movie'], genres=[genre]) movies = results_by_multipled['items'] for x in range(len(movies)): storeMovie(movies[x]['title'], movies[x]['short_description'], genre) linkMovieProvider(movies[x]['title'], 'Google Play') resultsMovies.append(movies[x]) results_by_multiplef = just_watch.search_for_item( providers=['ply'], genres=[genre], content_types=['show']) tv = results_by_multiplef['items'] for x in range(len(tv)): storeShow(tv[x]['title'], tv[x]['short_description'], genre) linkShowProvider(tv[x]['title'], 'Google Play') resultsTV.append(tv[x]) # generate the movie / tvshow recommendation from all the data retrieved using a random index # this allows for some variation in the recommended result chosenMovie = resultsMovies[randint(0, len(resultsMovies) - 1)] chosenShow = resultsTV[randint(0, len(resultsTV) - 1)] results = [chosenMovie, chosenShow] return render_template('suggest.html', selected=results, mood=max_mood, tweets=text)
from justwatch import JustWatch from fuzzywuzzy import fuzz from fuzzywuzzy import process just_watch = JustWatch(country='Canada') movies = open("Unwatched.txt", "r") textFile = open("Results.txt", "w+") line = movies.readline() textFile.write("Movie Title,Stream,Rent,Buy\n") while line: textFile.write("%s" % line.rstrip()) results = just_watch.search_for_item(query=line) result = results.get("items") isResult = False stream = list() rent = list() buy = list() for x in range(len(result)): for y in result[x]: if y == 'title': searchTitle = ''.join(line.split()).lower() resultTitle = ''.join(result[x][y].split()).lower() if fuzz.ratio(searchTitle, resultTitle) >= 80: foundTitle = str(result[x][y]) ratio = str(fuzz.ratio(searchTitle, resultTitle)) isResult = True else: isResult = False
from justwatch import JustWatch import json just_watch = JustWatch(country='ES') provider_details = just_watch.get_providers() for provider in provider_details: results = just_watch.search_for_item(providers=[provider['short_name']]) print() print() print(provider['technical_name']) for item in results['items']: print(item['title']) # for item in results['items']: # print(item['title'])
with open(path + '/jw.csv', mode='w', newline='') as file: fieldnames = ['jwId', 'tmdbId', 'title', 'genres'] writer = csv.DictWriter(file, fieldnames=fieldnames) writer.writeheader() pageSize = 30 peliculas = [] first = just_watch.search_for_item( content_types=['movie'], release_year_from=1970, page=1, scoring_filter_types={"imdb:score": { "min_scoring_value": 5 }}, page_size=pageSize) for item in first['items']: peliculas.append(item['id']) total = first['total_results'] totalPages = math.ceil(total / pageSize) print('Página 1/' + str(totalPages)) count = 2 while count <= totalPages: