Пример #1
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)
Пример #2
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"],
                }))
Пример #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 fetch_movie_data(self, movie):
        url = self.get_url(movie)
        APP.debug("Fetching url: %s" % url)
        data = self.parse_json(url)
        if not data or data["Response"] == "False":
            return {}

        return self.transform_data(data)
Пример #5
0
    def fetch_movie_data(self, movie):
        url = self.get_url(movie)
        APP.debug("Fetching url: %s" % url)
        data = self.parse_json(url, path="data.movies")
        for hit in data:
            if hit and "releaseDate" in hit and hit["releaseDate"]:
                return self.transform_data(hit)

        return {}
Пример #6
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)
Пример #7
0
    def fetch_movie_data(self, movie):
        url = self.get_url(movie)
        APP.debug("Fetching url: %s" % url)
        data = self.parse_json(url, path="0.data.0.hits")
        data = self.find_movie_matching_year(data, movie["year"])

        if not data:
            return {}

        return self.transform_data(data)
Пример #8
0
    def fetch_movie_data(self, movie):
        url = self.get_url(movie)
        APP.debug("Fetching url: %s" % url)
        data = self.parse_json(url, path="0.data.0.hits")
        data = self.find_movie_matching_year(data, movie["year"])

        if not data:
            return {}

        return self.transform_data(data)
Пример #9
0
def mail(recipient, subject, message):
    with APPLICATION.app_context():
        MAIL = Mail(APPLICATION)

        msg = Message(subject, recipients=[recipient])
        msg.body = message

        MAIL.send(msg)
Пример #10
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
Пример #11
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"],
            }))
Пример #12
0
def clear_cache(name):
    APP.debug("Clearing \"%s\" from movie db..." % name)
    movie = torrent_to_movie(name)
    record = APP.Movie.get_data(movie)

    if not record:
        APP.output("Could not find movie in db: %s" % name)
        return

    clear_webcache(record)

    APP.output("Deleted movie from database: %s" % record["title"])
    APP.Movie.remove("id", record["id"])
Пример #13
0
def clear_cache(name):
    APP.debug("Clearing \"%s\" from movie db..." % name)
    movie = torrent_to_movie(name)
    record = APP.Movie.get_data(movie)

    if not record:
        APP.output("Could not find movie in db: %s" % name)
        return

    clear_webcache(record)

    APP.output("Deleted movie from database: %s" % record["title"])
    APP.Movie.remove("id", record["id"])
Пример #14
0
def clear_cache(name):
    if platform.system() == 'Windows':
        name = name.decode("windows-1252")

    APP.debug("Clearing \"%s\" from movie db..." % name)
    movie = torrent_to_movie(name)
    clear_webcache(movie)

    record = APP.Movie.get_data(movie)

    if not record:
        APP.output("Could not find movie in db: %s" % name)
        return

    # Querying with and without year can give different URLs
    if not movie["year"] and record["year"]:
        movie["year"] = record["year"]
        clear_webcache(movie)

    APP.output("Deleted movie from database: %s" % record["title"])
    APP.Movie.remove("id", record["id"])
Пример #15
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)
Пример #16
0
def get_filenames(directory):
    APP.debug("Loading movies from: %s" % directory)
    files = os.listdir(directory)
    files = [(filename, os.path.isdir(os.path.join(directory, filename))) for filename in files]
    movies = [filename for filename, is_directory in files if is_proper_movie_file(filename, is_directory)]
    return movies
Пример #17
0
import sys

from backend import (admin, auth, channel, channels, message, search, user, users, standup)
from backend.utility.storage import box

from application import APPLICATION

for module in [admin, auth, channel, channels, message, search, user, users, standup]:
    APPLICATION.register_blueprint(module.endpoints)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        sys.exit("Usage: python3 server.py backend_port frontend_port")

    backend_port = int(sys.argv[1])

    box('url_base', 'http://localhost:' + str(backend_port))

    APPLICATION.run(port=backend_port)
Пример #18
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)
Пример #19
0
"""
FLask development server
"""
from application import APPLICATION

APPLICATION.run(host='0.0.0.0', port=8080, debug=True, threaded=True)
Пример #20
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()
Пример #21
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()
Пример #22
0
def get_filenames(directory):
    APP.debug("Loading movies from: %s" % directory)
    files = os.listdir(directory)
    files = [(filename, os.path.isdir(os.path.join(directory, filename))) for filename in files]
    movies = [filename for filename, is_directory in files if is_proper_movie_file(filename, is_directory)]
    return movies
Пример #23
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)