From ccaebc276597be28eec2bb7d1068e94630b7a363 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 20 Sep 2022 17:29:57 -0400 Subject: [PATCH] [37] fix variable error --- VERSION | 2 +- modules/anidb.py | 10 +++++----- modules/builder.py | 4 +++- modules/config.py | 6 +++++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/VERSION b/VERSION index c41f37f5..747ffdd1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.17.3-develop36 +1.17.3-develop37 diff --git a/modules/anidb.py b/modules/anidb.py index 564c800d..d0d0095b 100644 --- a/modules/anidb.py +++ b/modules/anidb.py @@ -97,13 +97,13 @@ class AniDB: return self.client is not None def login(self, username, password): - self.username = username - self.password = password - logger.secret(self.username) - logger.secret(self.password) - data = {"show": "main", "xuser": self.username, "xpass": self.password, "xdoautologin": "on"} + logger.secret(username) + logger.secret(password) + data = {"show": "main", "xuser": username, "xpass": password, "xdoautologin": "on"} if not self._request(urls["login"], data=data).xpath("//li[@class='sub-menu my']/@title"): raise Failed("AniDB Error: Login failed") + self.username = username + self.password = password def _request(self, url, params=None, data=None): logger.trace(f"URL: {url}") diff --git a/modules/builder.py b/modules/builder.py index 0d9bdf97..a8294eb9 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -208,15 +208,17 @@ class CollectionBuilder: methods["name"] = "name" if "template" in methods: + new_variables = {} if "variables" in methods: logger.debug("") logger.debug("Validating Method: variables") if not isinstance(self.data[methods["variables"]], dict): raise Failed(f"{self.Type} Error: variables must be a dictionary (key: value pairs)") logger.trace(self.data[methods["variables"]]) + new_variables = self.data[methods["variables"]] logger.debug("") name = self.data[methods["name"]] if "name" in methods else None - new_attributes = self.metadata.apply_template(name, self.mapping_name, self.data, self.data[methods["template"]], self.data[methods["variables"]]) + new_attributes = self.metadata.apply_template(name, self.mapping_name, self.data, self.data[methods["template"]], new_variables) for attr in new_attributes: if attr.lower() not in methods: self.data[attr] = new_attributes[attr] diff --git a/modules/config.py b/modules/config.py index 278074c4..7e8d2ecf 100644 --- a/modules/config.py +++ b/modules/config.py @@ -484,13 +484,17 @@ class ConfigFile: check_for_attribute(self.data, "version", parent="anidb", var_type="int", throw=True), check_for_attribute(self.data, "cache_expiration", parent="anidb", var_type="int", default=60, int_min=1) ) + except Failed as e: + logger.error(e) + logger.info(f"AniDB API Connection {'Successful' if self.AniDB.is_authorized else 'Failed'}") + try: self.AniDB.login( check_for_attribute(self.data, "username", parent="anidb", throw=True), check_for_attribute(self.data, "password", parent="anidb", throw=True) ) except Failed as e: logger.error(e) - logger.info(f"AniDB Connection {'Failed Continuing as Guest ' if self.MyAnimeList is None else 'Successful'}") + logger.info(f"AniDB Login {'Successful' if self.AniDB.username else 'Failed Continuing as Guest'}") logger.separator()