diff --git a/V6.py b/V6.py index cae681c..6cd6643 100755 --- a/V6.py +++ b/V6.py @@ -642,19 +642,23 @@ def fidelity(): pause = driver.find_element(By.CSS_SELECTOR, f'[class="c-action-toggle c-glyph f-toggle glyph-pause"]') pause.click() except Exception as e: - error(f"Error while clicking pause. Probably no cards. {e}") - return "no cards" + debug("No pause button.") + cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]') nb_cartes = len(cartes) + if nb_cartes == 0: + warning("No fidelity cards detected") + return "No cards." checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]') for i in range(nb_cartes): cartes[i].click() checked_txt = checked_list_all[i].get_attribute("innerHTML") ok = checked_txt.count("StatusCircleOuter checkmark") total = checked_txt.count("StatusCircleOuter") - if (ok != total): + if ok != total: elm = driver.find_elements(By.CLASS_NAME, 'clickable-link')[i] - if not "moviesandtv" in elm.get_attribute("innerHTML"): # not the film card + # legacy code. Should be removed + if "moviesandtv" not in elm.get_attribute("innerHTML"): # not the film card elm.click() driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1]) sub_fidelity() diff --git a/modules/Classes/Config.py b/modules/Classes/Config.py index 38a3e6c..6f5c3e3 100644 --- a/modules/Classes/Config.py +++ b/modules/Classes/Config.py @@ -22,7 +22,8 @@ class Config: proxy = json.load(inFile) with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile: config = json.load(inFile) - + with open("/app/MsRewards-reborn/user_data/version", "r") as inFile: + version = inFile.readline() """ setup standalone stuff """ @@ -34,7 +35,7 @@ class Config: self.version = args.update_version self.WebDriver = Driver() self.display = None - + self.version = version """ setup UserCredential """ @@ -52,11 +53,11 @@ class Config: self.discord.avatar_url = settings["avatarlink"] if ( - "discord" in config[args.config] - and config[args.config]["discord"] in discord - and "errorsL" in discord[config[args.config]["discord"]] - and discord[config[args.config]["discord"]]["errorsL"] != "" - ): + "discord" in config[args.config] + and config[args.config]["discord"] in discord + and "errorsL" in discord[config[args.config]["discord"]] + and discord[config[args.config]["discord"]]["errorsL"] != "" + ): self.discord.wh_link = discord[config[args.config]["discord"]]["errorsL"] self.discord.wh = Webhook.from_url(self.discord.wh_link, adapter=RequestsWebhookAdapter()) else: @@ -81,4 +82,10 @@ class Config: self.display = display def has_been_updated(self): - return self.version != "None" + with open('/app/MsRewards-Reborn/version', "r") as inFile: + if self.version != inFile.readline(): + self.version = inFile.readline() + with open('/app/MsRewards-Reborn/user_data/version', "w") as outFile: + outFile.write(self.version) + return True + return False diff --git a/user_data/version b/user_data/version new file mode 100644 index 0000000..bd52db8 --- /dev/null +++ b/user_data/version @@ -0,0 +1 @@ +0.0.0 \ No newline at end of file