mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 09:01:43 +00:00
[pornhub] Improve and simplify (closes #19135)
This commit is contained in:
parent
d2d970d07e
commit
5dda1edef9
@ -302,17 +302,12 @@ def parse_js_value(inp):
|
|||||||
comment_count = self._extract_count(
|
comment_count = self._extract_count(
|
||||||
r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')
|
r'All Comments\s*<span>\(([\d,.]+)\)', webpage, 'comment')
|
||||||
|
|
||||||
def _get_items(class_name):
|
def extract_list(meta_key):
|
||||||
div = self._search_regex(
|
div = self._search_regex(
|
||||||
r'<div class="' + class_name + '">([\S\s]+?)</div>',
|
r'(?s)<div[^>]+\bclass=["\'].*?\b%sWrapper[^>]*>(.+?)</div>'
|
||||||
webpage, class_name, default=None)
|
% meta_key, webpage, meta_key, default=None)
|
||||||
if div:
|
if div:
|
||||||
return [a for a in re.findall(r'<a href=[^>]+>([^<]+)', div)]
|
return re.findall(r'<a[^>]+\bhref=[^>]+>([^<]+)', div)
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
categories = _get_items('categoriesWrapper')
|
|
||||||
tags = _get_items('tagsWrapper')
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
@ -327,8 +322,8 @@ def _get_items(class_name):
|
|||||||
'comment_count': comment_count,
|
'comment_count': comment_count,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
'tags': tags,
|
'tags': extract_list('tags'),
|
||||||
'categories': categories,
|
'categories': extract_list('categories'),
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user