mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-06-20 17:54:50 +00:00
Compare commits
No commits in common. "b6f24745bfb89ec0eaaa181a68203c2e81e58802" and "5f37f67d37b54bf9bd6fe7fa3083492d42f7a20a" have entirely different histories.
b6f24745bf
...
5f37f67d37
@ -24,7 +24,6 @@ from ..utils import (
|
|||||||
url_or_none,
|
url_or_none,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
)
|
)
|
||||||
from ..utils.traversal import find_elements, traverse_obj
|
|
||||||
|
|
||||||
|
|
||||||
class PornHubBaseIE(InfoExtractor):
|
class PornHubBaseIE(InfoExtractor):
|
||||||
@ -138,24 +137,23 @@ class PornHubIE(PornHubBaseIE):
|
|||||||
_EMBED_REGEX = [r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?pornhub(?:premium)?\.(?:com|net|org)/embed/[\da-z]+)']
|
_EMBED_REGEX = [r'<iframe[^>]+?src=["\'](?P<url>(?:https?:)?//(?:www\.)?pornhub(?:premium)?\.(?:com|net|org)/embed/[\da-z]+)']
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'http://www.pornhub.com/view_video.php?viewkey=648719015',
|
'url': 'http://www.pornhub.com/view_video.php?viewkey=648719015',
|
||||||
'md5': '4d4a4e9178b655776f86cf89ecaf0edf',
|
'md5': 'a6391306d050e4547f62b3f485dd9ba9',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '648719015',
|
'id': '648719015',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Seductive Indian beauty strips down and fingers her pink pussy',
|
'title': 'Seductive Indian beauty strips down and fingers her pink pussy',
|
||||||
'uploader': 'BABES-COM',
|
'uploader': 'Babes',
|
||||||
'uploader_id': '/users/babes-com',
|
|
||||||
'upload_date': '20130628',
|
'upload_date': '20130628',
|
||||||
'timestamp': 1372447216,
|
'timestamp': 1372447216,
|
||||||
'duration': 361,
|
'duration': 361,
|
||||||
'view_count': int,
|
'view_count': int,
|
||||||
'like_count': int,
|
'like_count': int,
|
||||||
|
'dislike_count': int,
|
||||||
'comment_count': int,
|
'comment_count': int,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
'tags': list,
|
'tags': list,
|
||||||
'categories': list,
|
'categories': list,
|
||||||
'cast': list,
|
'cast': list,
|
||||||
'thumbnail': r're:https?://.+',
|
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
# non-ASCII title
|
# non-ASCII title
|
||||||
@ -482,6 +480,13 @@ 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')
|
||||||
|
|
||||||
|
def extract_list(meta_key):
|
||||||
|
div = self._search_regex(
|
||||||
|
rf'(?s)<div[^>]+\bclass=["\'].*?\b{meta_key}Wrapper[^>]*>(.+?)</div>',
|
||||||
|
webpage, meta_key, default=None)
|
||||||
|
if div:
|
||||||
|
return [clean_html(x).strip() for x in re.findall(r'(?s)<a[^>]+\bhref=[^>]+>.+?</a>', div)]
|
||||||
|
|
||||||
info = self._search_json_ld(webpage, video_id, default={})
|
info = self._search_json_ld(webpage, video_id, default={})
|
||||||
# description provided in JSON-LD is irrelevant
|
# description provided in JSON-LD is irrelevant
|
||||||
info['description'] = None
|
info['description'] = None
|
||||||
@ -500,11 +505,9 @@ class PornHubIE(PornHubBaseIE):
|
|||||||
'comment_count': comment_count,
|
'comment_count': comment_count,
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
**traverse_obj(webpage, {
|
'tags': extract_list('tags'),
|
||||||
'tags': ({find_elements(attr='data-label', value='tag')}, ..., {clean_html}),
|
'categories': extract_list('categories'),
|
||||||
'categories': ({find_elements(attr='data-label', value='category')}, ..., {clean_html}),
|
'cast': extract_list('pornstars'),
|
||||||
'cast': ({find_elements(attr='data-label', value='pornstar')}, ..., {clean_html}),
|
|
||||||
}),
|
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
}, info)
|
}, info)
|
||||||
|
|
||||||
|
|||||||
@ -6,21 +6,20 @@ from ..networking.exceptions import HTTPError
|
|||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
clean_html,
|
clean_html,
|
||||||
extract_attributes,
|
|
||||||
int_or_none,
|
int_or_none,
|
||||||
join_nonempty,
|
join_nonempty,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
|
traverse_obj,
|
||||||
update_url,
|
update_url,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
)
|
)
|
||||||
from ..utils.traversal import traverse_obj
|
|
||||||
|
|
||||||
|
|
||||||
class TelecincoBaseIE(InfoExtractor):
|
class TelecincoBaseIE(InfoExtractor):
|
||||||
def _parse_content(self, content, url):
|
def _parse_content(self, content, url):
|
||||||
video_id = content['dataMediaId'][1]
|
video_id = content['dataMediaId']
|
||||||
config = self._download_json(
|
config = self._download_json(
|
||||||
content['dataConfig'][1], video_id, 'Downloading config JSON')
|
content['dataConfig'], video_id, 'Downloading config JSON')
|
||||||
services = config['services']
|
services = config['services']
|
||||||
caronte = self._download_json(services['caronte'], video_id)
|
caronte = self._download_json(services['caronte'], video_id)
|
||||||
if traverse_obj(caronte, ('dls', 0, 'drm', {bool})):
|
if traverse_obj(caronte, ('dls', 0, 'drm', {bool})):
|
||||||
@ -58,9 +57,9 @@ class TelecincoBaseIE(InfoExtractor):
|
|||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': traverse_obj(config, ('info', 'title', {str})),
|
'title': traverse_obj(config, ('info', 'title', {str})),
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'thumbnail': (traverse_obj(content, ('dataPoster', 1, {url_or_none}))
|
'thumbnail': (traverse_obj(content, ('dataPoster', {url_or_none}))
|
||||||
or traverse_obj(config, 'poster', 'imageUrl', expected_type=url_or_none)),
|
or traverse_obj(config, 'poster', 'imageUrl', expected_type=url_or_none)),
|
||||||
'duration': traverse_obj(content, ('dataDuration', 1, {int_or_none})),
|
'duration': traverse_obj(content, ('dataDuration', {int_or_none})),
|
||||||
'http_headers': headers,
|
'http_headers': headers,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,45 +137,30 @@ class TelecincoIE(TelecincoBaseIE):
|
|||||||
'url': 'http://www.cuatro.com/chesterinlove/a-carta/chester-chester_in_love-chester_edu_2_2331030022.html',
|
'url': 'http://www.cuatro.com/chesterinlove/a-carta/chester-chester_in_love-chester_edu_2_2331030022.html',
|
||||||
'only_matching': True,
|
'only_matching': True,
|
||||||
}]
|
}]
|
||||||
_ASTRO_ISLAND_RE = re.compile(r'<astro-island\b[^>]+>')
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, display_id, impersonate=True)
|
webpage = self._download_webpage(url, display_id, impersonate=True)
|
||||||
|
article = self._search_json(
|
||||||
|
r'window\.\$REACTBASE_STATE\.article(?:_multisite)?\s*=',
|
||||||
|
webpage, 'article', display_id)['article']
|
||||||
|
description = traverse_obj(article, ('leadParagraph', {clean_html}, filter))
|
||||||
|
|
||||||
props_list = traverse_obj(webpage, (
|
if article.get('editorialType') != 'VID':
|
||||||
{self._ASTRO_ISLAND_RE.findall}, ...,
|
|
||||||
{extract_attributes}, 'props', {json.loads}))
|
|
||||||
|
|
||||||
description = traverse_obj(props_list, (..., 'leadParagraph', 1, {clean_html}, any, filter))
|
|
||||||
main_content = traverse_obj(props_list, (..., ('content', ('articleData', 1, 'opening')), 1, {dict}, any))
|
|
||||||
|
|
||||||
if traverse_obj(props_list, (..., 'editorialType', 1, {str}, any)) != 'VID': # e.g. 'ART'
|
|
||||||
entries = []
|
entries = []
|
||||||
|
|
||||||
for p in traverse_obj(props_list, (..., 'articleData', 1, ('opening', ('body', 1, ...)), 1, {dict})):
|
for p in traverse_obj(article, ((('opening', all), 'body'), lambda _, v: v['content'])):
|
||||||
type_ = traverse_obj(p, ('type', 1, {str}))
|
content = p['content']
|
||||||
content = traverse_obj(p, ('content', 1, {str} if type_ == 'paragraph' else {dict}))
|
type_ = p.get('type')
|
||||||
if not content:
|
if type_ == 'paragraph' and isinstance(content, str):
|
||||||
continue
|
|
||||||
if type_ == 'paragraph':
|
|
||||||
description = join_nonempty(description, content, delim='')
|
description = join_nonempty(description, content, delim='')
|
||||||
elif type_ == 'video':
|
elif type_ == 'video' and isinstance(content, dict):
|
||||||
entries.append(self._parse_content(content, url))
|
entries.append(self._parse_content(content, url))
|
||||||
else:
|
|
||||||
self.report_warning(
|
|
||||||
f'Skipping unsupported content type "{type_}"', display_id, only_once=True)
|
|
||||||
|
|
||||||
return self.playlist_result(
|
return self.playlist_result(
|
||||||
entries,
|
entries, str_or_none(article.get('id')),
|
||||||
traverse_obj(props_list, (..., 'id', 1, {int}, {str_or_none}, any)) or display_id,
|
traverse_obj(article, ('title', {str})), clean_html(description))
|
||||||
traverse_obj(main_content, ('dataTitle', 1, {str})),
|
|
||||||
clean_html(description))
|
|
||||||
|
|
||||||
if not main_content:
|
info = self._parse_content(article['opening']['content'], url)
|
||||||
raise ExtractorError('Unable to extract main content from webpage')
|
|
||||||
|
|
||||||
info = self._parse_content(main_content, url)
|
|
||||||
info['description'] = description
|
info['description'] = description
|
||||||
|
|
||||||
return info
|
return info
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user