Add error catch for youtube and site downloaders

This commit is contained in:
Serene-Arc
2021-03-13 12:01:30 +10:00
committed by Ali Parlakci
parent 9417e0cc04
commit d977595bde
2 changed files with 12 additions and 5 deletions

View File

@@ -314,15 +314,18 @@ class RedditDownloader:
logger.error(f'Could not download submission {submission.name}: {e}')
return
content = downloader.find_resources(self.authenticator)
try:
content = downloader.find_resources(self.authenticator)
except errors.SiteDownloaderError:
logger.error(f'Site {downloader_class.__name__} failed to download submission {submission.id}')
return
for destination, res in self.file_name_formatter.format_resource_paths(content, self.download_directory):
if destination.exists():
logger.warning(f'File already exists: {destination}')
else:
res.download()
if res.hash.hexdigest() in self.master_hash_list and self.args.no_dupes:
logger.warning(
f'Resource from "{res.url}" and hash "{res.hash.hexdigest()}" downloaded elsewhere')
logger.warning(f'Resource from "{res.url}" and hash "{res.hash.hexdigest()}" downloaded elsewhere')
else:
# TODO: consider making a hard link/symlink here
destination.parent.mkdir(parents=True, exist_ok=True)