diff --git a/Src/Api/Template/Util/manage_ep.py b/Src/Api/Template/Util/manage_ep.py index 836b8b0..c3c7bcd 100644 --- a/Src/Api/Template/Util/manage_ep.py +++ b/Src/Api/Template/Util/manage_ep.py @@ -17,22 +17,21 @@ MAP_EPISODE = config_manager.get('DEFAULT', 'map_episode_name') def dynamic_format_number(n: int) -> str: """ - Formats a number by adding a leading zero. - The width of the resulting string is dynamic, calculated as the number of digits in the number plus one. + Formats a number by adding a leading zero if it is less than 9. + The width of the resulting string is dynamic, calculated as the number of digits in the number plus one + for numbers less than 9, otherwise the width remains the same. Parameters: - n (int): The number to format. Returns: - - str: The formatted number as a string with a leading zero. - - Examples: - >>> dynamic_format_number(1) - '01' - >>> dynamic_format_number(20) - '020' + - str: The formatted number as a string with a leading zero if the number is less than 9. """ - width = len(str(n)) + 1 + if n < 9: + width = len(str(n)) + 1 + else: + width = len(str(n)) + return str(n).zfill(width) diff --git a/Src/Lib/Downloader/MP4/downloader.py b/Src/Lib/Downloader/MP4/downloader.py index d91ec6f..74b0100 100644 --- a/Src/Lib/Downloader/MP4/downloader.py +++ b/Src/Lib/Downloader/MP4/downloader.py @@ -40,7 +40,7 @@ def MP4_downloader(url: str, path: str, referer: str = None): - referer (str): The referer header value to include in the HTTP request headers. """ - if "http" not in url or "https" not in url: + if "http" not in str(url).lower().strip() or "https" not in str(url).lower().strip(): logging.error(f"Invalid url: {url}") sys.exit(0) diff --git a/Src/Lib/Downloader/TOR/downloader.py b/Src/Lib/Downloader/TOR/downloader.py index ddc446f..e961347 100644 --- a/Src/Lib/Downloader/TOR/downloader.py +++ b/Src/Lib/Downloader/TOR/downloader.py @@ -43,7 +43,8 @@ class TOR_downloader: - username (str): Username for logging into qBittorrent. - password (str): Password for logging into qBittorrent. """ - self.qb = Client(f'http://{HOST}:{PORT}/') + try: self.qb = Client(f'http://{HOST}:{PORT}/') + except: logging.error("Start qbitorrent first.") self.username = USERNAME self.password = PASSWORD self.logged_in = False