mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-20 02:41:19 +02:00
Padding filenames with width 3
Pad the filenames with a width of 3 characters so that image viewers display files in the expected order.
This commit is contained in:
parent
8d25673180
commit
a4ac1c9720
@ -26,8 +26,9 @@ class Downloader(object):
|
|||||||
def _download(self, url, folder='', filename='', retried=False):
|
def _download(self, url, folder='', filename='', retried=False):
|
||||||
logger.info('Start downloading: {0} ...'.format(url))
|
logger.info('Start downloading: {0} ...'.format(url))
|
||||||
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)
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(folder, filename), "wb") as f:
|
with open(os.path.join(folder, base_filename.zfill(3) + extension), "wb") as f:
|
||||||
response = request('get', url, stream=True, timeout=self.timeout)
|
response = request('get', url, stream=True, timeout=self.timeout)
|
||||||
length = response.headers.get('content-length')
|
length = response.headers.get('content-length')
|
||||||
if length is None:
|
if length is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user