Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[youporn] fix url metadata detection (width and bits) to allow best v… #20425

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions youtube_dl/extractor/youporn.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ class YouPornIE(InfoExtractor):
'params': {
'skip_download': True,
},
}, {
# Different URL (videoUrl) structure, has file extension in path
'url': 'https://www.youporn.com/watch/13922959/femdom-principal/',
'info_dict': {
'id': '13822959',
'display_id': 'femdom-principal',
'ext': 'mp4',
'format': '720p-4000k - 720p',
'height': 720,
'tbr': 4000
},
'params': {
'skip_download': True,
},
}]

def _real_extract(self, url):
Expand Down Expand Up @@ -119,8 +133,9 @@ def _real_extract(self, url):
# Video URL's path looks like this:
# /201012/17/505835/720p_1500k_505835/YouPorn%20-%20Sex%20Ed%20Is%20It%20Safe%20To%20Masturbate%20Daily.mp4
# /201012/17/505835/vl_240p_240k_505835/YouPorn%20-%20Sex%20Ed%20Is%20It%20Safe%20To%20Masturbate%20Daily.mp4
# /videos/201703/11/109285532/720P_4000K_109285532.mp4?rate=248k&burst=1400k&validfrom=1553107800&validto=1553122200&hash=NzBS4CUWB2RpgA9thDRS0Ouw5PM%3D
# We will benefit from it by extracting some metadata
mobj = re.search(r'(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+/', video_url)
mobj = re.search(r'(?P<height>\d{3,4})[pP]_(?P<bitrate>\d+)[kK]_\d+', video_url)
if mobj:
height = int(mobj.group('height'))
bitrate = int(mobj.group('bitrate'))
Expand All @@ -145,9 +160,8 @@ def _real_extract(self, url):
r'(?s)<div[^>]+class=["\']submitByLink["\'][^>]*>(.+?)</div>',
webpage, 'uploader', fatal=False)
upload_date = unified_strdate(self._html_search_regex(
[r'Date\s+[Aa]dded:\s*<span>([^<]+)',
r'(?s)<div[^>]+class=["\']videoInfo(?:Date|Time)["\'][^>]*>(.+?)</div>'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not remove old patterns.

webpage, 'upload date', fatal=False))
r'<div[^>]+class=["\']video-uploaded["\'][^>]*>[^<]+<span>([^<]+)</span></div>',
webpage, 'upload date', fatal=False))

age_limit = self._rta_search(webpage)

Expand All @@ -158,9 +172,7 @@ def _real_extract(self, url):
view_count = str_to_int(self._search_regex(
r'(?s)<div[^>]+class=(["\']).*?\bvideoInfoViews\b.*?\1[^>]*>.*?(?P<count>[\d,.]+)<',
webpage, 'view count', fatal=False, group='count'))
comment_count = str_to_int(self._search_regex(
r'>All [Cc]omments? \(([\d,.]+)\)',
webpage, 'comment count', fatal=False))
comment_count = len(re.findall(r'<div[^>]+class=([\"\']).*?videoComment\b.*?\1', webpage))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect.


def extract_tag_box(regex, title):
tag_box = self._search_regex(regex, webpage, title, default=None)
Expand Down