def clear_webcache(movie): cached_session = APP.setting("WEBCACHE") for provider_path in APP.setting("MOVIEDATA_PROVIDERS"): provider_module = import_module(provider_path) provider = provider_module.Provider() url = provider.get_url(movie) if cached_session.cache.has_url(url): cached_session.cache.delete_url(url) APP.output("Deleted url from webcache: %s" % url)
def clear_url(url): cached_session = APP.setting("WEBCACHE") if cached_session.cache.has_url(url): cached_session.cache.delete_url(url) APP.output("Deleted url from webcache: %s" % url) else: APP.debug("Found no match for %s in webcache." % url)
def clear_webcache(movie): for provider_path in APP.setting("MOVIEDATA_PROVIDERS"): provider_module = import_module(provider_path) provider = provider_module.Provider() APP.debug("Clearing movie name (%s) from webcache" % movie["title"]) clear_url(provider.get_url({"name": movie["title"].lower()})) # Make sure we clear URLs with year too clear_url( provider.get_url({ "name": movie["title"].lower(), "year": movie["year"], })) for search_phrase in movie["search_phrases"]: APP.debug("Clearing movie search phrase (%s) from webcache" % search_phrase) clear_url(provider.get_url({ "name": search_phrase, })) # Make sure we clear URLs with year too clear_url( provider.get_url({ "name": search_phrase, "year": movie["year"], }))
def _http_get(self, url, timeout=60, cache=True): base = self.session if not cache else APP.setting("WEBCACHE") response = base.get(url, timeout=timeout) # from pprint import pprint # print("REQUEST", url) # pprint(base.headers) # print("-" * 80) # print("RESPONSE", response.status_code, repr(response.text)) # pprint(response.headers) # print("=" * 80) return response.text
def clear_webcache(movie): for provider_path in APP.setting("MOVIEDATA_PROVIDERS"): provider_module = import_module(provider_path) provider = provider_module.Provider() APP.debug("Clearing movie name (%s) from webcache" % movie["title"]) clear_url(provider.get_url({ "name": movie["title"].lower() })) # Make sure we clear URLs with year too clear_url(provider.get_url({ "name": movie["title"].lower(), "year": movie["year"], })) for search_phrase in movie["search_phrases"]: APP.debug("Clearing movie search phrase (%s) from webcache" % search_phrase) clear_url(provider.get_url({ "name": search_phrase, })) # Make sure we clear URLs with year too clear_url(provider.get_url({ "name": search_phrase, "year": movie["year"], }))
def output(movie_data): provider_module = import_module(APP.setting("OUTPUT_PROVIDER")) provider = provider_module.Provider() APP.debug("Outputting data with %s" % provider_module.IDENTIFIER) provider.output(movie_data)
def _http_get(self, url, timeout=60, cache=True): base = requests if not cache else APP.setting("WEBCACHE") response = base.get(url, timeout=timeout) return get_unicode_from_response(response)
def output(movie_data, limit, filters): provider_module = import_module(APP.setting("OUTPUT_PROVIDER")) provider = provider_module.Provider() APP.debug("Outputting data with %s" % provider_module.IDENTIFIER) provider.output(movie_data, limit, filters)
def get_popular(): APP.debug("Fetching popular movies...") provider_module = import_module(APP.setting("POPULARITY_PROVIDER")) provider = provider_module.Provider() APP.debug("Fetching from %s" % provider_module.IDENTIFIER) return provider.get_popular()