예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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"],
                }))
예제 #5
0
 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
예제 #6
0
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"],
            }))
예제 #7
0
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)
예제 #8
0
 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)
예제 #9
0
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)
예제 #10
0
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()
예제 #11
0
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()