Add PornHub module

This commit is contained in:
Serene-Arc
2021-06-25 17:47:49 +10:00
parent 8b1a3d9abc
commit 1a52dfdcbc
4 changed files with 60 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ from bdfr.site_downloaders.fallback_downloaders.youtubedl_fallback import Youtub
from bdfr.site_downloaders.gallery import Gallery
from bdfr.site_downloaders.gfycat import Gfycat
from bdfr.site_downloaders.imgur import Imgur
from bdfr.site_downloaders.pornhub import PornHub
from bdfr.site_downloaders.redgifs import Redgifs
from bdfr.site_downloaders.self_post import SelfPost
from bdfr.site_downloaders.youtube import Youtube
@@ -43,6 +44,8 @@ class DownloadFactory:
return Youtube
elif re.match(r'i\.redd\.it.*', sanitised_url):
return Direct
elif re.match(r'pornhub\.com.*', sanitised_url):
return PornHub
elif YoutubeDlFallback.can_handle_link(sanitised_url):
return YoutubeDlFallback
else:

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env python3
# coding=utf-8
import logging
import tempfile
from pathlib import Path
from typing import Optional
import youtube_dl
from praw.models import Submission
from bdfr.exceptions import NotADownloadableLinkError, SiteDownloaderError
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 = {
'format': 'best',
'nooverwrites': True,
}
out = self._download_video(ytdl_options)
return [out]