mirror of
https://github.com/soimort/you-get.git
synced 2025-02-11 20:52:31 +03:00
[Pornhub]Add support
New extractor and test for pornhub.
This commit is contained in:
parent
0cabb980b6
commit
c41cad9524
@ -55,6 +55,7 @@ SITES = {
|
||||
'nicovideo' : 'nicovideo',
|
||||
'pinterest' : 'pinterest',
|
||||
'pixnet' : 'pixnet',
|
||||
'pornhub' : 'pornhub',
|
||||
'pptv' : 'pptv',
|
||||
'qianmo' : 'qianmo',
|
||||
'qq' : 'qq',
|
||||
|
@ -48,6 +48,7 @@ from .netease import *
|
||||
from .nicovideo import *
|
||||
from .pinterest import *
|
||||
from .pixnet import *
|
||||
from .pornhub import *
|
||||
from .pptv import *
|
||||
from .qianmo import *
|
||||
from .qq import *
|
||||
|
28
src/you_get/extractors/pornhub.py
Normal file
28
src/you_get/extractors/pornhub.py
Normal file
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__all__ = ['pornhub_download', 'pornhub_download_by_viewkey']
|
||||
|
||||
from ..common import *
|
||||
|
||||
def pornhub_download_by_viewkey(viewkey, output_dir='.', merge=True, info_only=False):
|
||||
"""Downloads a Pornhub video by its viewkey"""
|
||||
content = get_content('http://www.pornhub.com/embed/{}'.format(viewkey))
|
||||
url = match1(content, r'quality_\d+p":"([^"]+)').replace(r"\/", "/")
|
||||
if url.startswith('//'): url = 'http:' + url
|
||||
title = match1(content, r'<title>([^<]+)')
|
||||
_, ext, size = url_info(url)
|
||||
|
||||
print_info(site_info, title, ext, size)
|
||||
if not info_only:
|
||||
download_urls([url], title, ext, size, output_dir=output_dir, merge=merge)
|
||||
|
||||
def pornhub_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
||||
viewkey = match1(url, r'viewkey=([0-9a-z]+)')
|
||||
if viewkey is None:
|
||||
viewkey = match1(url, r'embed/([0-9a-z]+)')
|
||||
if viewkey:
|
||||
pornhub_download_by_viewkey(viewkey)
|
||||
|
||||
site_info = "Pornhub.com"
|
||||
download = pornhub_download
|
||||
download_playlist = playlist_not_supported('Pornhub')
|
@ -28,3 +28,6 @@ class YouGetTests(unittest.TestCase):
|
||||
youtube.download("http://www.youtube.com/watch?v=pzKerr0JIPA", info_only=True)
|
||||
youtube.download("http://youtu.be/pzKerr0JIPA", info_only=True)
|
||||
youtube.download("http://www.youtube.com/attribution_link?u=/watch?v%3DldAKIzq7bvs%26feature%3Dshare", info_only=True)
|
||||
|
||||
def test_pornhub(self):
|
||||
pornhub.download("http://www.pornhub.com/view_video.php?viewkey=ph56d67b6c6505e", info_only=True)
|
Loading…
Reference in New Issue
Block a user