mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 02:25:11 +00:00
Add agecheck and various improvements to YouPorn IE
This commit is contained in:
parent
64ce2aada8
commit
629fcdd135
1 changed files with 18 additions and 24 deletions
|
@ -3731,12 +3731,8 @@ def _real_extract(self, url):
|
||||||
|
|
||||||
class YouPornIE(InfoExtractor):
|
class YouPornIE(InfoExtractor):
|
||||||
"""Information extractor for youporn.com."""
|
"""Information extractor for youporn.com."""
|
||||||
|
|
||||||
_VALID_URL = r'^(?:https?://)?(?:\w+\.)?youporn\.com/watch/(?P<videoid>[0-9]+)/(?P<title>[^/]+)'
|
_VALID_URL = r'^(?:https?://)?(?:\w+\.)?youporn\.com/watch/(?P<videoid>[0-9]+)/(?P<title>[^/]+)'
|
||||||
|
|
||||||
def __init__(self, downloader=None):
|
|
||||||
InfoExtractor.__init__(self, downloader)
|
|
||||||
|
|
||||||
def _print_formats(self, formats):
|
def _print_formats(self, formats):
|
||||||
"""Print all available formats"""
|
"""Print all available formats"""
|
||||||
print(u'Available formats:')
|
print(u'Available formats:')
|
||||||
|
@ -3759,30 +3755,30 @@ def _real_extract(self, url):
|
||||||
|
|
||||||
video_id = mobj.group('videoid')
|
video_id = mobj.group('videoid')
|
||||||
|
|
||||||
webpage = self._download_webpage(url, video_id)
|
req = compat_urllib_request.Request(url)
|
||||||
|
req.add_header('Cookie', 'age_verified=1')
|
||||||
|
webpage = self._download_webpage(req, video_id)
|
||||||
|
|
||||||
# Get the video title
|
# Get the video title
|
||||||
VIDEO_TITLE_RE = r'videoTitleArea">(?P<title>.*)</h1>'
|
result = re.search(r'videoTitleArea">(?P<title>.*)</h1>', webpage)
|
||||||
result = re.search(VIDEO_TITLE_RE, webpage)
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self._downloader.trouble(u'ERROR: unable to extract video title')
|
raise ExtractorError(u'ERROR: unable to extract video title')
|
||||||
return
|
|
||||||
video_title = result.group('title').strip()
|
video_title = result.group('title').strip()
|
||||||
|
|
||||||
# Get the video date
|
# Get the video date
|
||||||
VIDEO_DATE_RE = r'Date:</b>(?P<date>.*)</li>'
|
result = re.search(r'Date:</b>(?P<date>.*)</li>', webpage)
|
||||||
result = re.search(VIDEO_DATE_RE, webpage)
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self._downloader.trouble(u'ERROR: unable to extract video date')
|
self._downloader.to_stderr(u'WARNING: unable to extract video date')
|
||||||
return
|
upload_date = None
|
||||||
|
else:
|
||||||
upload_date = result.group('date').strip()
|
upload_date = result.group('date').strip()
|
||||||
|
|
||||||
# Get the video uploader
|
# Get the video uploader
|
||||||
VIDEO_UPLOADER_RE = r'Submitted:</b>(?P<uploader>.*)</li>'
|
result = re.search(r'Submitted:</b>(?P<uploader>.*)</li>', webpage)
|
||||||
result = re.search(VIDEO_UPLOADER_RE, webpage)
|
|
||||||
if result is None:
|
if result is None:
|
||||||
self._downloader.trouble(u'ERROR: unable to extract uploader')
|
self._downloader.to_stderr(u'ERROR: unable to extract uploader')
|
||||||
return
|
video_uploader = None
|
||||||
|
else:
|
||||||
video_uploader = result.group('uploader').strip()
|
video_uploader = result.group('uploader').strip()
|
||||||
video_uploader = clean_html( video_uploader )
|
video_uploader = clean_html( video_uploader )
|
||||||
|
|
||||||
|
@ -3790,16 +3786,14 @@ def _real_extract(self, url):
|
||||||
DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
|
DOWNLOAD_LIST_RE = r'(?s)<ul class="downloadList">(?P<download_list>.*?)</ul>'
|
||||||
result = re.search(DOWNLOAD_LIST_RE, webpage)
|
result = re.search(DOWNLOAD_LIST_RE, webpage)
|
||||||
if result is None:
|
if result is None:
|
||||||
self._downloader.trouble(u'ERROR: unable to extract download list')
|
raise ExtractorError(u'Unable to extract download list')
|
||||||
return
|
|
||||||
download_list_html = result.group('download_list').strip()
|
download_list_html = result.group('download_list').strip()
|
||||||
|
|
||||||
# Get all of the links from the page
|
# Get all of the links from the page
|
||||||
LINK_RE = r'(?s)<a href="(?P<url>[^"]+)">'
|
LINK_RE = r'(?s)<a href="(?P<url>[^"]+)">'
|
||||||
links = re.findall(LINK_RE, download_list_html)
|
links = re.findall(LINK_RE, download_list_html)
|
||||||
if(len(links) == 0):
|
if(len(links) == 0):
|
||||||
self._downloader.trouble(u'ERROR: no known formats available for video')
|
raise ExtractorError(u'ERROR: no known formats available for video')
|
||||||
return
|
|
||||||
|
|
||||||
self._downloader.to_screen(u'[youporn] Links found: %d' % len(links))
|
self._downloader.to_screen(u'[youporn] Links found: %d' % len(links))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue