mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-21 02:44:14 +09:00
Compare commits
4 Commits
cf352f93ec
...
94decb60af
Author | SHA1 | Date | |
---|---|---|---|
![]() |
94decb60af | ||
![]() |
673277e510 | ||
![]() |
91b1569f68 | ||
![]() |
4ba9065654 |
@ -20,10 +20,9 @@ class AlphaPornoIE(InfoExtractor):
|
|||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Sensual striptease porn with Samantha Alexandra',
|
'title': 'Sensual striptease porn with Samantha Alexandra',
|
||||||
'thumbnail': r're:https?://.*\.jpg$',
|
'thumbnail': r're:https?://.*\.jpg$',
|
||||||
'timestamp': 1418694611,
|
'timestamp': 1418701811,
|
||||||
'upload_date': '20141216',
|
'upload_date': '20141216',
|
||||||
'duration': 387,
|
'duration': 387,
|
||||||
'filesize_approx': 54120000,
|
|
||||||
'tbr': 1145,
|
'tbr': 1145,
|
||||||
'categories': list,
|
'categories': list,
|
||||||
'age_limit': 18,
|
'age_limit': 18,
|
||||||
@ -36,42 +35,53 @@ class AlphaPornoIE(InfoExtractor):
|
|||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
|
|
||||||
video_id = self._search_regex(
|
video_id = self._search_regex(
|
||||||
r"video_id\s*:\s*'([^']+)'", webpage, 'video id', default=None)
|
[r"video_id\s*:\s*'([^']+)'", r"\['video_id'\]\s*=\s*(.+?);"], webpage, 'video id')
|
||||||
|
|
||||||
video_url = self._search_regex(
|
entries = self._parse_html5_media_entries('https://alphaporno.com', webpage, video_id)
|
||||||
r"video_url\s*:\s*'([^']+)'", webpage, 'video url')
|
info = {}
|
||||||
ext = self._html_search_meta(
|
if len(entries) > 0:
|
||||||
'encodingFormat', webpage, 'ext', default='.mp4')[1:]
|
info = entries[0]
|
||||||
|
for fmt in info['formats']:
|
||||||
|
fmt['tbr'] = int_or_none(self._search_regex(r"br=(\d+)", fmt['url'], 'bitrate', default=None))
|
||||||
|
else:
|
||||||
|
video_url = self._search_regex(
|
||||||
|
r"video_url\s*:\s*'([^']+)'", webpage, 'video url')
|
||||||
|
ext = self._html_search_meta(
|
||||||
|
'encodingFormat', webpage, 'ext', default='.mp4')[1:]
|
||||||
|
bitrate = int_or_none(self._html_search_meta(
|
||||||
|
'bitrate', webpage, 'bitrate', default=None))
|
||||||
|
info = {
|
||||||
|
'url': video_url,
|
||||||
|
'ext': ext,
|
||||||
|
'tbr': bitrate,
|
||||||
|
}
|
||||||
|
|
||||||
title = self._search_regex(
|
title = self._search_regex(
|
||||||
[r'<meta content="([^"]+)" itemprop="description">',
|
[r'<meta content="([^"]+)" itemprop="description">',
|
||||||
r'class="title" itemprop="name">([^<]+)<'],
|
r'class="title" itemprop="name">([^<]+)<',
|
||||||
|
r'<h1>(.*?)</h1>'],
|
||||||
webpage, 'title')
|
webpage, 'title')
|
||||||
thumbnail = self._html_search_meta('thumbnail', webpage, 'thumbnail')
|
thumbnail = self._html_search_meta(['og:image', 'thumbnail'], webpage, 'thumbnail')
|
||||||
timestamp = parse_iso8601(self._html_search_meta(
|
timestamp = parse_iso8601(self._og_search_property('video:release_date', webpage, 'upload date', fatal=False),
|
||||||
'uploadDate', webpage, 'upload date'))
|
delimiter=' ') or parse_iso8601(self._html_search_meta('uploadDate', webpage, 'upload date'))
|
||||||
duration = parse_duration(self._html_search_meta(
|
duration = parse_duration(self._html_search_meta(
|
||||||
'duration', webpage, 'duration'))
|
['duration', 'og:video:duration'], webpage, 'duration'))
|
||||||
filesize_approx = parse_filesize(self._html_search_meta(
|
filesize_approx = parse_filesize(self._html_search_meta(
|
||||||
'contentSize', webpage, 'file size'))
|
'contentSize', webpage, 'file size', default=None))
|
||||||
bitrate = int_or_none(self._html_search_meta(
|
|
||||||
'bitrate', webpage, 'bitrate'))
|
|
||||||
categories = self._html_search_meta(
|
categories = self._html_search_meta(
|
||||||
'keywords', webpage, 'categories', default='').split(',')
|
'keywords', webpage, 'categories', default='').split(',')
|
||||||
|
|
||||||
age_limit = self._rta_search(webpage)
|
age_limit = self._rta_search(webpage)
|
||||||
|
|
||||||
return {
|
info.update({
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'url': video_url,
|
|
||||||
'ext': ext,
|
|
||||||
'title': title,
|
'title': title,
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': thumbnail,
|
||||||
'timestamp': timestamp,
|
'timestamp': timestamp,
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
'filesize_approx': filesize_approx,
|
'filesize_approx': filesize_approx,
|
||||||
'tbr': bitrate,
|
|
||||||
'categories': categories,
|
'categories': categories,
|
||||||
'age_limit': age_limit,
|
'age_limit': age_limit,
|
||||||
}
|
})
|
||||||
|
return info
|
||||||
|
@ -27,6 +27,7 @@ from ..compat import (
|
|||||||
)
|
)
|
||||||
from ..jsinterp import JSInterpreter
|
from ..jsinterp import JSInterpreter
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
bug_reports_message,
|
||||||
clean_html,
|
clean_html,
|
||||||
dict_get,
|
dict_get,
|
||||||
error_to_compat_str,
|
error_to_compat_str,
|
||||||
@ -65,6 +66,7 @@ from ..utils import (
|
|||||||
url_or_none,
|
url_or_none,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
urljoin,
|
urljoin,
|
||||||
|
variadic,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -460,6 +462,26 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
|||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _extract_thumbnails(data, *path_list, **kw_final_key):
|
||||||
|
"""
|
||||||
|
Extract thumbnails from thumbnails dict
|
||||||
|
@param path_list: path list to level that contains 'thumbnails' key
|
||||||
|
"""
|
||||||
|
final_key = kw_final_key.get('final_key', 'thumbnails')
|
||||||
|
|
||||||
|
return traverse_obj(data, ((
|
||||||
|
tuple(variadic(path) + (final_key, Ellipsis)
|
||||||
|
for path in path_list or [()])), {
|
||||||
|
'url': ('url', T(url_or_none),
|
||||||
|
# Sometimes youtube gives a wrong thumbnail URL. See:
|
||||||
|
# https://github.com/yt-dlp/yt-dlp/issues/233
|
||||||
|
# https://github.com/ytdl-org/youtube-dl/issues/28023
|
||||||
|
T(lambda u: update_url(u, query=None) if u and 'maxresdefault' in u else u)),
|
||||||
|
'height': ('height', T(int_or_none)),
|
||||||
|
'width': ('width', T(int_or_none)),
|
||||||
|
}, T(lambda t: t if t.get('url') else None)))
|
||||||
|
|
||||||
def _search_results(self, query, params):
|
def _search_results(self, query, params):
|
||||||
data = {
|
data = {
|
||||||
'context': {
|
'context': {
|
||||||
@ -3183,8 +3205,12 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
|||||||
expected_type=txt_or_none)
|
expected_type=txt_or_none)
|
||||||
|
|
||||||
def _grid_entries(self, grid_renderer):
|
def _grid_entries(self, grid_renderer):
|
||||||
for item in grid_renderer['items']:
|
for item in traverse_obj(grid_renderer, ('items', Ellipsis, T(dict))):
|
||||||
if not isinstance(item, dict):
|
lockup_view_model = traverse_obj(item, ('lockupViewModel', T(dict)))
|
||||||
|
if lockup_view_model:
|
||||||
|
entry = self._extract_lockup_view_model(lockup_view_model)
|
||||||
|
if entry:
|
||||||
|
yield entry
|
||||||
continue
|
continue
|
||||||
renderer = self._extract_grid_item_renderer(item)
|
renderer = self._extract_grid_item_renderer(item)
|
||||||
if not isinstance(renderer, dict):
|
if not isinstance(renderer, dict):
|
||||||
@ -3268,6 +3294,25 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
|||||||
continue
|
continue
|
||||||
yield self._extract_video(renderer)
|
yield self._extract_video(renderer)
|
||||||
|
|
||||||
|
def _extract_lockup_view_model(self, view_model):
|
||||||
|
content_id = view_model.get('contentId')
|
||||||
|
if not content_id:
|
||||||
|
return
|
||||||
|
content_type = view_model.get('contentType')
|
||||||
|
if content_type not in ('LOCKUP_CONTENT_TYPE_PLAYLIST', 'LOCKUP_CONTENT_TYPE_PODCAST'):
|
||||||
|
self.report_warning(
|
||||||
|
'Unsupported lockup view model content type "{0}"{1}'.format(content_type, bug_reports_message()), only_once=True)
|
||||||
|
return
|
||||||
|
return merge_dicts(self.url_result(
|
||||||
|
update_url_query('https://www.youtube.com/playlist', {'list': content_id}),
|
||||||
|
ie=YoutubeTabIE.ie_key(), video_id=content_id), {
|
||||||
|
'title': traverse_obj(view_model, (
|
||||||
|
'metadata', 'lockupMetadataViewModel', 'title', 'content', T(compat_str))),
|
||||||
|
'thumbnails': self._extract_thumbnails(view_model, (
|
||||||
|
'contentImage', 'collectionThumbnailViewModel', 'primaryThumbnail',
|
||||||
|
'thumbnailViewModel', 'image'), final_key='sources'),
|
||||||
|
})
|
||||||
|
|
||||||
def _video_entry(self, video_renderer):
|
def _video_entry(self, video_renderer):
|
||||||
video_id = video_renderer.get('videoId')
|
video_id = video_renderer.get('videoId')
|
||||||
if video_id:
|
if video_id:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user