mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-02 18:42:54 +01:00
[pornhub] Fix tags and categories extraction (closes #13720)
This commit is contained in:
parent
48fb963b2f
commit
d2d970d07e
@ -16,7 +16,6 @@ from .openload import PhantomJSwrapper
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
int_or_none,
|
int_or_none,
|
||||||
js_to_json,
|
|
||||||
orderedSet,
|
orderedSet,
|
||||||
remove_quotes,
|
remove_quotes,
|
||||||
str_to_int,
|
str_to_int,
|
||||||
@ -303,14 +302,17 @@ class PornHubIE(PornHubBaseIE):
|
|||||||
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')
|
||||||
|
|
||||||
page_params = self._parse_json(self._search_regex(
|
def _get_items(class_name):
|
||||||
r'page_params\.zoneDetails\[([\'"])[^\'"]+\1\]\s*=\s*(?P<data>{[^}]+})',
|
div = self._search_regex(
|
||||||
webpage, 'page parameters', group='data', default='{}'),
|
r'<div class="' + class_name + '">([\S\s]+?)</div>',
|
||||||
video_id, transform_source=js_to_json, fatal=False)
|
webpage, class_name, default=None)
|
||||||
tags = categories = None
|
if div:
|
||||||
if page_params:
|
return [a for a in re.findall(r'<a href=[^>]+>([^<]+)', div)]
|
||||||
tags = page_params.get('tags', '').split(',')
|
else:
|
||||||
categories = page_params.get('categories', '').split(',')
|
return None
|
||||||
|
|
||||||
|
categories = _get_items('categoriesWrapper')
|
||||||
|
tags = _get_items('tagsWrapper')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user