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 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 __init__(self, aCountry='DE', someProviders=["Netflix"]): self.country = aCountry self.api = JustWatch(aCountry) result = self.api.get_providers() self.providers = [ x for x in result if x['clear_name'] in someProviders ]
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 search_object(): basepath = path.dirname(__file__) filepath = path.abspath(path.join(basepath, "..", "..", "config_files", "config.json")) country = json.loads(open(filepath).read())["COUNTRY"] just_watch=JustWatch(country=country) return(just_watch.get_providers())
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 getJustWatch(title, jw_id, rt_score, streams, jw = None): if jw == None: jw = JustWatch(country = 'US') sel = 'n' ## JustWatch breaks if you bombard it too much, so use a VPN while True: try: res = jw.get_title(title_id = int(jw_id)) except Exception as e: if e.response.status_code == 500: print("No match found for this JustWatch ID {}.".format(jw_id)) return jw_id, rt_score, streams if e.response.status_code == 404: print("No match found for this JustWatch ID {}.".format(jw_id)) return jw_id, rt_score, streams print(e.response.status_code) print("JustWatch not reached. Try again...") print("** Rate Limit was likely exceeded. Please use VPN. **") nada = input("Press [enter] to continue once VPN is turned on.") continue else: print("* MATCHED JustWatch") break if 'error' in res: print("No match found for this JustWatch ID {}.".format(jw_id)) return jw_id, rt_score, streams jw_id, year, desc, runtime, rt_score, streams = parseJustWatch(res) return jw_id, rt_score, streams
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 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 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 __init__(self): # Libraries self.letterboxd = Letterboxd(LB_USERNAME, LB_PASSWORD) self.tmdb = TMDb(TMDB_API_KEY) self.justwatch = JustWatch(country=JUSTWATCH_COUNTRY) self.justwatch.locale = JUSTWATCH_LOCALE # Load cached watchlist films self.films = self.load()
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 getProviders(): with open("config/providers.json", "r") as f: providers = json.load(f) jw = JustWatch(country = "US") provider_details = jw.get_providers() for provider in provider_details: providers[str(provider['id'])] = provider with open("config/providers.json", "w") as f: json.dump(providers, f) return providers
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 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 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 main(wf): from justwatch import JustWatch parser = argparse.ArgumentParser() parser.add_argument('-s', '--search_keyword') parser.add_argument('-t', '--title_id') parser.add_argument('-i', '--input_locale') args = parser.parse_args() search_keyword = args.search_keyword title_id = args.title_id constants.LOCALE = args.input_locale just_watch = JustWatch(country=constants.LOCALE) providers = Providers(just_watch) t = thumbs() if search_keyword is not None: media_items = MediaItems(just_watch, sys.argv[len(sys.argv) - 1], providers).get_alfred_json_list() should_rerun = process_thumbnails_search(t, media_items) wf.logger.error("should_rerun = %s" % should_rerun) show_results_search(media_items, should_rerun) elif title_id is not None: title_id, content_type = parse_title_id(title_id) media_item = MediaItem( just_watch.get_title(title_id=title_id, content_type=content_type), providers) should_rerun = process_thumbnails_providers(t, media_item) show_results_providers(media_item, should_rerun) else: pass t.save_queue() if t.has_queue: if not is_running('generate_thumbnails'): run_in_background( 'generate_thumbnails', ['/usr/bin/python3', wf.workflowfile('thumbnails.py')])
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 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 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( "=====================================================================" )
def main(): # reconfigure based on flag or commandline prompt parser = argparse.ArgumentParser(description="Configuration Command Flags") parser.add_argument('-r', '--reconfigure', action='store_true', help='reset configuration file') args = parser.parse_args() if args.reconfigure: config.clear_config('config_files/config.json') # storing config info and creating unique url for watchlist config.main() configData = json.loads(open('config_files/config.json').read()) user = configData["USER"] country = configData["COUNTRY"] services = configData["SERVICES"] URL=f'https://letterboxd.com/{user}/watchlist' # main soup for basic watchlist info rawText = requests.get(URL) soup = BeautifulSoup(rawText.content, 'html.parser') pages = num_pages(soup) titles = unify_pages_list(URL, pages) # main api object just_watch=JustWatch(country=country) # load provider/id maps providerData = json.loads(open('config_files/providers/providerData.json').read()) idData = json.loads(open('config_files/providers/idData.json').read()) # TODO: scheme the streaming types maybe using this type field # empty dictionary for all the movies reference_dict = {service: {"id": providerData[service], "films": [], "type": ""} for service in services} #ACTUAL EXECUTION STEP LOL reference_films(titles, just_watch, reference_dict, idData) format_output(reference_dict)
def lambda_handler(event, context): intent_name = event['request']['intent']['name'] just_watch = JustWatch(country='US') print(event['request']) if intent_name == 'SearchTV': return handleTV(event, just_watch) elif intent_name == 'SearchMovie': return handleMovies(event, just_watch) elif intent_name == 'Cancel': cancelIntent() elif intent_name == 'Help': helpIntent() elif intent_name == 'Stop': stopIntent() elif intent_name == 'Launch': onLaunch()
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 {