Fix a crash when downloading a disabled pornhub video

This commit is contained in:
Serene-Arc
2021-11-05 13:23:55 +10:00
parent d25f3fe008
commit 801784c46d
2 changed files with 21 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ from typing import Optional
from praw.models import Submission
from bdfr.exceptions import SiteDownloaderError
from bdfr.resource import Resource
from bdfr.site_authenticator import SiteAuthenticator
from bdfr.site_downloaders.youtube import Youtube
@@ -22,10 +23,15 @@ class PornHub(Youtube):
'format': 'best',
'nooverwrites': True,
}
if video_attributes := super().get_video_attributes(self.post.url):
extension = video_attributes['ext']
else:
raise SiteDownloaderError()
out = Resource(
self.post,
self.post.url,
super()._download_video(ytdl_options),
super().get_video_attributes(self.post.url)['ext'],
extension,
)
return [out]