Catch additional errors in site downloaders

This commit is contained in:
Serene-Arc authored and Serene committed 2021-04-28 15:20:02 +10:00
1 parent 6a20548269
commit 7fcbf623a0
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ class Gfycat(GifDeliveryNetwork):
try: try:
out = json.loads(content.contents[0])['video']['contentUrl'] out = json.loads(content.contents[0])['video']['contentUrl']
except (IndexError, KeyError) as e: except (IndexError, KeyError, AttributeError) as e:
raise SiteDownloaderError(f'Failed to download Gfycat link {url}: {e}') raise SiteDownloaderError(f'Failed to download Gfycat link {url}: {e}')
except json.JSONDecodeError as e: except json.JSONDecodeError as e:
raise SiteDownloaderError(f'Did not receive valid JSON data: {e}') raise SiteDownloaderError(f'Did not receive valid JSON data: {e}')
+1 -1
View File
@@ -44,7 +44,7 @@ class Redgifs(GifDeliveryNetwork):
try: try:
out = json.loads(content.contents[0])['video']['contentUrl'] out = json.loads(content.contents[0])['video']['contentUrl']
except (IndexError, KeyError): except (IndexError, KeyError, AttributeError):
raise SiteDownloaderError('Failed to find JSON data in page') raise SiteDownloaderError('Failed to find JSON data in page')
except json.JSONDecodeError as e: except json.JSONDecodeError as e:
raise SiteDownloaderError(f'Received data was not valid JSON: {e}') raise SiteDownloaderError(f'Received data was not valid JSON: {e}')