try fix issue 616: onedrive OSError input/output
This commit is contained in:
@@ -622,3 +622,6 @@ def file_modification_days(filename) -> int:
|
|||||||
if days < 0:
|
if days < 0:
|
||||||
return 9999
|
return 9999
|
||||||
return days
|
return days
|
||||||
|
|
||||||
|
def file_not_exist_or_empty(filepath) -> bool:
|
||||||
|
return not os.path.isfile(filepath) or os.path.getsize(filepath) == 0
|
||||||
|
|||||||
16
core.py
16
core.py
@@ -170,13 +170,13 @@ def trailer_download(trailer, leak_word, c_word, number, path, filepath):
|
|||||||
return
|
return
|
||||||
configProxy = config.getInstance().proxy()
|
configProxy = config.getInstance().proxy()
|
||||||
for i in range(configProxy.retry):
|
for i in range(configProxy.retry):
|
||||||
if os.path.getsize(path+'/' + number + leak_word + c_word + '-trailer.mp4') == 0:
|
if file_not_exist_or_empty(path+'/' + number + leak_word + c_word + '-trailer.mp4'):
|
||||||
print('[!]Video Download Failed! Trying again. [{}/3]', i + 1)
|
print('[!]Video Download Failed! Trying again. [{}/3]', i + 1)
|
||||||
download_file_with_filename(trailer, number + leak_word + c_word + '-trailer.mp4', path, filepath)
|
download_file_with_filename(trailer, number + leak_word + c_word + '-trailer.mp4', path, filepath)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if os.path.getsize(path + '/' + number + leak_word + c_word + '-trailer.mp4') == 0:
|
if file_not_exist_or_empty(path + '/' + number + leak_word + c_word + '-trailer.mp4'):
|
||||||
return
|
return
|
||||||
print('[+]Video Downloaded!', path + '/' + number + leak_word + c_word + '-trailer.mp4')
|
print('[+]Video Downloaded!', path + '/' + number + leak_word + c_word + '-trailer.mp4')
|
||||||
|
|
||||||
@@ -190,19 +190,19 @@ def extrafanart_download(data, path, filepath):
|
|||||||
for url in data:
|
for url in data:
|
||||||
jpg_filename = f'extrafanart-{j}.jpg'
|
jpg_filename = f'extrafanart-{j}.jpg'
|
||||||
jpg_fullpath = os.path.join(path, jpg_filename)
|
jpg_fullpath = os.path.join(path, jpg_filename)
|
||||||
if download_only_missing_images and os.path.isfile(jpg_fullpath) and os.path.getsize(jpg_fullpath):
|
if download_only_missing_images and not file_not_exist_or_empty(jpg_fullpath):
|
||||||
continue
|
continue
|
||||||
if download_file_with_filename(url, jpg_filename, path, filepath) == 'failed':
|
if download_file_with_filename(url, jpg_filename, path, filepath) == 'failed':
|
||||||
moveFailedFolder(filepath)
|
moveFailedFolder(filepath)
|
||||||
return
|
return
|
||||||
for i in range(configProxy.retry):
|
for i in range(configProxy.retry):
|
||||||
if os.path.getsize(jpg_fullpath) == 0:
|
if file_not_exist_or_empty(jpg_fullpath):
|
||||||
print('[!]Image Download Failed! Trying again. [{}/3]', i + 1)
|
print('[!]Image Download Failed! Trying again. [{}/3]', i + 1)
|
||||||
download_file_with_filename(url, jpg_filename, path, filepath)
|
download_file_with_filename(url, jpg_filename, path, filepath)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if os.path.getsize(jpg_fullpath) == 0:
|
if file_not_exist_or_empty(jpg_fullpath):
|
||||||
return
|
return
|
||||||
print('[+]Image Downloaded!', jpg_fullpath)
|
print('[+]Image Downloaded!', jpg_fullpath)
|
||||||
j += 1
|
j += 1
|
||||||
@@ -213,7 +213,7 @@ def extrafanart_download(data, path, filepath):
|
|||||||
def image_download(cover, number, leak_word, c_word, path, filepath):
|
def image_download(cover, number, leak_word, c_word, path, filepath):
|
||||||
filename = f"{number}{leak_word}{c_word}-fanart.jpg"
|
filename = f"{number}{leak_word}{c_word}-fanart.jpg"
|
||||||
full_filepath = os.path.join(path, filename)
|
full_filepath = os.path.join(path, filename)
|
||||||
if config.getInstance().download_only_missing_images() and os.path.isfile(full_filepath) and os.path.getsize(full_filepath):
|
if config.getInstance().download_only_missing_images() and not file_not_exist_or_empty(full_filepath):
|
||||||
return
|
return
|
||||||
if download_file_with_filename(cover, filename, path, filepath) == 'failed':
|
if download_file_with_filename(cover, filename, path, filepath) == 'failed':
|
||||||
moveFailedFolder(filepath)
|
moveFailedFolder(filepath)
|
||||||
@@ -221,13 +221,13 @@ def image_download(cover, number, leak_word, c_word, path, filepath):
|
|||||||
|
|
||||||
configProxy = config.getInstance().proxy()
|
configProxy = config.getInstance().proxy()
|
||||||
for i in range(configProxy.retry):
|
for i in range(configProxy.retry):
|
||||||
if os.path.getsize(full_filepath) == 0:
|
if file_not_exist_or_empty(full_filepath):
|
||||||
print('[!]Image Download Failed! Trying again. [{}/3]', i + 1)
|
print('[!]Image Download Failed! Trying again. [{}/3]', i + 1)
|
||||||
download_file_with_filename(cover, filename, path, filepath)
|
download_file_with_filename(cover, filename, path, filepath)
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if os.path.getsize(full_filepath) == 0:
|
if file_not_exist_or_empty(full_filepath):
|
||||||
return
|
return
|
||||||
print('[+]Image Downloaded!', full_filepath)
|
print('[+]Image Downloaded!', full_filepath)
|
||||||
shutil.copyfile(full_filepath, os.path.join(path, f"{number}{leak_word}{c_word}-thumb.jpg"))
|
shutil.copyfile(full_filepath, os.path.join(path, f"{number}{leak_word}{c_word}-thumb.jpg"))
|
||||||
|
|||||||
Reference in New Issue
Block a user