mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-14 17:26:24 +00:00
[youporn] Modernize
This commit is contained in:
parent
bc2bdf5709
commit
f24e9833dc
@ -1,3 +1,6 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -17,24 +20,25 @@ from ..aes import (
|
|||||||
|
|
||||||
|
|
||||||
class YouPornIE(InfoExtractor):
|
class YouPornIE(InfoExtractor):
|
||||||
_VALID_URL = r'^(?:https?://)?(?:www\.)?(?P<url>youporn\.com/watch/(?P<videoid>[0-9]+)/(?P<title>[^/]+))'
|
_VALID_URL = r'^(?P<proto>https?://)(?:www\.)?(?P<url>youporn\.com/watch/(?P<videoid>[0-9]+)/(?P<title>[^/]+))'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
u'url': u'http://www.youporn.com/watch/505835/sex-ed-is-it-safe-to-masturbate-daily/',
|
'url': 'http://www.youporn.com/watch/505835/sex-ed-is-it-safe-to-masturbate-daily/',
|
||||||
u'file': u'505835.mp4',
|
'md5': '71ec5fcfddacf80f495efa8b6a8d9a89',
|
||||||
u'md5': u'71ec5fcfddacf80f495efa8b6a8d9a89',
|
'info_dict': {
|
||||||
u'info_dict': {
|
'id': '505835',
|
||||||
u"upload_date": u"20101221",
|
'ext': 'mp4',
|
||||||
u"description": u"Love & Sex Answers: http://bit.ly/DanAndJenn -- Is It Unhealthy To Masturbate Daily?",
|
'upload_date': '20101221',
|
||||||
u"uploader": u"Ask Dan And Jennifer",
|
'description': 'Love & Sex Answers: http://bit.ly/DanAndJenn -- Is It Unhealthy To Masturbate Daily?',
|
||||||
u"title": u"Sex Ed: Is It Safe To Masturbate Daily?",
|
'uploader': 'Ask Dan And Jennifer',
|
||||||
u"age_limit": 18,
|
'title': 'Sex Ed: Is It Safe To Masturbate Daily?',
|
||||||
|
'age_limit': 18,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
video_id = mobj.group('videoid')
|
video_id = mobj.group('videoid')
|
||||||
url = 'http://www.' + mobj.group('url')
|
url = mobj.group('proto') + 'www.' + mobj.group('url')
|
||||||
|
|
||||||
req = compat_urllib_request.Request(url)
|
req = compat_urllib_request.Request(url)
|
||||||
req.add_header('Cookie', 'age_verified=1')
|
req.add_header('Cookie', 'age_verified=1')
|
||||||
@ -42,7 +46,7 @@ class YouPornIE(InfoExtractor):
|
|||||||
age_limit = self._rta_search(webpage)
|
age_limit = self._rta_search(webpage)
|
||||||
|
|
||||||
# Get JSON parameters
|
# Get JSON parameters
|
||||||
json_params = self._search_regex(r'var currentVideo = new Video\((.*)\);', webpage, u'JSON parameters')
|
json_params = self._search_regex(r'var currentVideo = new Video\((.*)\);', webpage, 'JSON parameters')
|
||||||
try:
|
try:
|
||||||
params = json.loads(json_params)
|
params = json.loads(json_params)
|
||||||
except:
|
except:
|
||||||
@ -61,7 +65,7 @@ class YouPornIE(InfoExtractor):
|
|||||||
# Get all of the links from the page
|
# Get all of the links from the page
|
||||||
DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
|
DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
|
||||||
download_list_html = self._search_regex(DOWNLOAD_LIST_RE,
|
download_list_html = self._search_regex(DOWNLOAD_LIST_RE,
|
||||||
webpage, u'download list').strip()
|
webpage, 'download list').strip()
|
||||||
LINK_RE = r'<a href="([^"]+)">'
|
LINK_RE = r'<a href="([^"]+)">'
|
||||||
links = re.findall(LINK_RE, download_list_html)
|
links = re.findall(LINK_RE, download_list_html)
|
||||||
|
|
||||||
@ -86,7 +90,7 @@ class YouPornIE(InfoExtractor):
|
|||||||
resolution = format_parts[0]
|
resolution = format_parts[0]
|
||||||
height = int(resolution[:-len('p')])
|
height = int(resolution[:-len('p')])
|
||||||
bitrate = int(format_parts[1][:-len('k')])
|
bitrate = int(format_parts[1][:-len('k')])
|
||||||
format = u'-'.join(format_parts) + u'-' + dn
|
format = '-'.join(format_parts) + '-' + dn
|
||||||
|
|
||||||
formats.append({
|
formats.append({
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
|
Loading…
Reference in New Issue
Block a user