This commit is contained in:
ricterz 2024-12-11 23:57:01 +08:00
parent b841747761
commit eae42c8eb5
2 changed files with 3 additions and 4 deletions

View File

@ -64,8 +64,7 @@ class Downloader(Singleton):
filename = filename if filename else os.path.basename(urlparse(url).path) filename = filename if filename else os.path.basename(urlparse(url).path)
base_filename, extension = os.path.splitext(filename) base_filename, extension = os.path.splitext(filename)
digits = int(math.log10(length)) + 1 filename = base_filename.zfill(length) + extension
filename = base_filename.zfill(digits) + extension
save_file_path = os.path.join(self.folder, filename) save_file_path = os.path.join(self.folder, filename)
@ -153,8 +152,9 @@ class Downloader(Singleton):
# Assuming we want to continue with rest of process. # Assuming we want to continue with rest of process.
return True return True
digit_length = len(str(len(queue)))
coroutines = [ coroutines = [
self._semaphore_download(url, filename=os.path.basename(urlparse(url).path), length=len(queue)) self._semaphore_download(url, filename=os.path.basename(urlparse(url).path), length=digit_length)
for url in queue for url in queue
] ]

View File

@ -135,7 +135,6 @@ def doujinshi_parser(id_, counter=0):
logger.warning(f'Error: {e}, ignored') logger.warning(f'Error: {e}, ignored')
return None return None
# print(response)
html = BeautifulSoup(response, 'html.parser') html = BeautifulSoup(response, 'html.parser')
doujinshi_info = html.find('div', attrs={'id': 'info'}) doujinshi_info = html.find('div', attrs={'id': 'info'})