Fix step ep 01 02 10 11 for only < 9

This commit is contained in:
Lovi-0 2024-07-13 17:25:00 +02:00
parent 49a8826142
commit a485b3feb4
3 changed files with 12 additions and 12 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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