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

[pornhub] fixed category and tag parsing fixes #13720 #19111

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
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
18 changes: 8 additions & 10 deletions youtube_dl/extractor/pornhub.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,6 @@ def _extract_count(self, pattern, webpage, name):
return str_to_int(self._search_regex(
pattern, webpage, '%s count' % name, fatal=False))

@staticmethod
def _get_text(class_name, page):
div = re.findall(r'<div class="' + class_name + '">\s+[^\n]+\s+([^\n]+)', page)
if div:
return [a for a in re.findall(r'<a href=[^>]+>([^<]+)', div[0])]
else:
return []

def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url)
host = mobj.group('host') or 'pornhub.com'
Expand Down Expand Up @@ -310,8 +302,14 @@ def parse_js_value(inp):
comment_count = self._extract_count(
r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')

categories = self._get_text("categoriesWrapper", webpage)
tags = self._get_text("tagsWrapper", webpage)
def _get_text(class_name, page):
JChris246 marked this conversation as resolved.
Show resolved Hide resolved
div = re.search(
JChris246 marked this conversation as resolved.
Show resolved Hide resolved
r'<div class="' + class_name + '">\s+[^\n]+\s+([^\n]+)\s+[^\n]+\s+</div>', page)
JChris246 marked this conversation as resolved.
Show resolved Hide resolved
if div:
return [a for a in re.findall(r'<a href=[^>]+>([^<]+)', div.group(1))]
JChris246 marked this conversation as resolved.
Show resolved Hide resolved

categories = _get_text('categoriesWrapper', webpage)
tags = _get_text('tagsWrapper', webpage)

return {
'id': video_id,
Expand Down