2021-06-25 19:47:49 +12:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
|
|
import logging
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
from praw.models import Submission
|
|
|
|
|
2021-11-05 16:23:55 +13:00
|
|
|
from bdfr.exceptions import SiteDownloaderError
|
2021-06-25 19:47:49 +12:00
|
|
|
from bdfr.resource import Resource
|
|
|
|
from bdfr.site_authenticator import SiteAuthenticator
|
|
|
|
from bdfr.site_downloaders.youtube import Youtube
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class PornHub(Youtube):
|
|
|
|
def __init__(self, post: Submission):
|
|
|
|
super().__init__(post)
|
|
|
|
|
|
|
|
def find_resources(self, authenticator: Optional[SiteAuthenticator] = None) -> list[Resource]:
|
|
|
|
ytdl_options = {
|
2022-12-03 18:11:17 +13:00
|
|
|
"format": "best",
|
|
|
|
"nooverwrites": True,
|
2021-06-25 19:47:49 +12:00
|
|
|
}
|
2021-11-05 16:23:55 +13:00
|
|
|
if video_attributes := super().get_video_attributes(self.post.url):
|
2022-12-03 18:11:17 +13:00
|
|
|
extension = video_attributes["ext"]
|
2021-11-05 16:23:55 +13:00
|
|
|
else:
|
|
|
|
raise SiteDownloaderError()
|
|
|
|
|
2021-07-27 15:39:49 +12:00
|
|
|
out = Resource(
|
|
|
|
self.post,
|
|
|
|
self.post.url,
|
|
|
|
super()._download_video(ytdl_options),
|
2021-11-05 16:23:55 +13:00
|
|
|
extension,
|
2021-07-27 15:39:49 +12:00
|
|
|
)
|
2021-06-25 19:47:49 +12:00
|
|
|
return [out]
|