Skip to content

Commit

Permalink
[29] #954 Fix anidb_popular
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Jul 15, 2022
1 parent c52c2a5 commit b6373d9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.1-develop28
1.17.1-develop29
2 changes: 1 addition & 1 deletion modules/anidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _request(self, url, data=None):

def _popular(self):
response = self._request(urls["popular"])
return util.get_int_list(response.xpath("//td[@class='name anime']/a/@href"), "AniDB ID")
return util.get_int_list(response.xpath("//td[@class='thumb anime']/a/@href"), "AniDB ID")

def _relations(self, anidb_id):
response = self._request(f"{urls['anime']}/{anidb_id}{urls['relation']}")
Expand Down
1 change: 1 addition & 0 deletions modules/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ def __init__(self, config, metadata, name, data, library=None, overlay=None, ext
try:
results = self.config.TMDb.search_people(tmdb_person)
if results:
valid_names.append(tmdb_person)
valid_names.append(results[0].name)
if results[0].biography:
self.summaries["tmdb_person"] = results[0].biography
Expand Down
12 changes: 6 additions & 6 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def hooks(attr):
if "trakt" in self.data: self.data["trakt"] = self.data.pop("trakt")
if "mal" in self.data: self.data["mal"] = self.data.pop("mal")

def check_for_attribute(data, attribute, parent=None, test_list=None, default=None, do_print=True, default_is_none=False, req_default=False, var_type="str", throw=False, save=True):
def check_for_attribute(data, attribute, parent=None, test_list=None, default=None, do_print=True, default_is_none=False, req_default=False, var_type="str", throw=False, save=True, int_min=0):
endline = ""
if parent is not None:
if data and parent in data:
Expand Down Expand Up @@ -232,7 +232,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, default=No
if isinstance(data[attribute], bool): return data[attribute]
else: message = f"{text} must be either true or false"
elif var_type == "int":
if isinstance(data[attribute], int) and data[attribute] >= 0: return data[attribute]
if isinstance(data[attribute], int) and data[attribute] >= int_min: return data[attribute]
else: message = f"{text} must an integer >= 0"
elif var_type == "path":
if os.path.exists(os.path.abspath(data[attribute])): return data[attribute]
Expand Down Expand Up @@ -288,7 +288,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, default=No

self.general = {
"cache": check_for_attribute(self.data, "cache", parent="settings", var_type="bool", default=True),
"cache_expiration": check_for_attribute(self.data, "cache_expiration", parent="settings", var_type="int", default=60),
"cache_expiration": check_for_attribute(self.data, "cache_expiration", parent="settings", var_type="int", default=60, int_min=1),
"asset_directory": check_for_attribute(self.data, "asset_directory", parent="settings", var_type="list_path", default_is_none=True),
"asset_folders": check_for_attribute(self.data, "asset_folders", parent="settings", var_type="bool", default=True),
"asset_depth": check_for_attribute(self.data, "asset_depth", parent="settings", var_type="int", default=0),
Expand Down Expand Up @@ -391,7 +391,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, default=No
self.TMDb = TMDb(self, {
"apikey": check_for_attribute(self.data, "apikey", parent="tmdb", throw=True),
"language": check_for_attribute(self.data, "language", parent="tmdb", default="en"),
"expiration": check_for_attribute(self.data, "cache_expiration", parent="tmdb", var_type="int", default=60)
"expiration": check_for_attribute(self.data, "cache_expiration", parent="tmdb", var_type="int", default=60, int_min=1)
})
region = check_for_attribute(self.data, "region", parent="tmdb", test_list=self.TMDb.iso_3166_1, default_is_none=True)
self.TMDb.region = str(region).upper() if region else region
Expand All @@ -407,7 +407,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, default=No
try:
self.OMDb = OMDb(self, {
"apikey": check_for_attribute(self.data, "apikey", parent="omdb", throw=True),
"expiration": check_for_attribute(self.data, "cache_expiration", parent="omdb", var_type="int", default=60)
"expiration": check_for_attribute(self.data, "cache_expiration", parent="omdb", var_type="int", default=60, int_min=1)
})
except Failed as e:
logger.error(e)
Expand All @@ -423,7 +423,7 @@ def check_for_attribute(data, attribute, parent=None, test_list=None, default=No
try:
self.Mdblist.add_key(
check_for_attribute(self.data, "apikey", parent="mdblist", throw=True),
check_for_attribute(self.data, "cache_expiration", parent="mdblist", var_type="int", default=60)
check_for_attribute(self.data, "cache_expiration", parent="mdblist", var_type="int", default=60, int_min=1)
)
logger.info("Mdblist Connection Successful")
except Failed as e:
Expand Down
2 changes: 1 addition & 1 deletion modules/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def logger_input(prompt, timeout=60):
else: raise SystemError("Input Timeout not supported on this system")

def header(language="en-US,en;q=0.5"):
return {"Accept-Language": "eng" if language == "default" else language, "User-Agent": "Mozilla/5.0"}
return {"Accept-Language": "eng" if language == "default" else language, "User-Agent": "Mozilla/5.0 Firefox/102.0"}

def alarm_handler(signum, frame):
raise TimeoutExpired
Expand Down

0 comments on commit b6373d9

Please sign in to comment.