1
0
Fork 0
mirror of synced 2024-06-02 18:34:37 +12:00
bulk-downloader-for-reddit/bdfr/site_downloaders/pornhub.py

38 lines
1,009 B
Python
Raw Normal View History

2021-06-25 19:47:49 +12:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2021-06-25 19:47:49 +12:00
import logging
from typing import Optional
from praw.models import Submission
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
}
if video_attributes := super().get_video_attributes(self.post.url):
2022-12-03 18:11:17 +13:00
extension = video_attributes["ext"]
else:
raise SiteDownloaderError()
2021-07-27 15:39:49 +12:00
out = Resource(
self.post,
self.post.url,
super()._download_video(ytdl_options),
extension,
2021-07-27 15:39:49 +12:00
)
2021-06-25 19:47:49 +12:00
return [out]