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 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)
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 {}
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)
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"])
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"])
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 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
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()
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)