mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-20 18:34:14 +09:00
Compare commits
12 Commits
4efdea369c
...
87ed730eb2
Author | SHA1 | Date | |
---|---|---|---|
![]() |
87ed730eb2 | ||
![]() |
673277e510 | ||
![]() |
91b1569f68 | ||
![]() |
47217e7b54 | ||
![]() |
1734e55a96 | ||
![]() |
ee9ee5a0b7 | ||
![]() |
0ab278e488 | ||
![]() |
0edd71f0b1 | ||
![]() |
c63cbdb443 | ||
![]() |
17a9592f29 | ||
![]() |
f630222253 | ||
![]() |
f19d8c9885 |
@ -4,11 +4,12 @@ import re
|
|||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import int_or_none
|
from ..utils import int_or_none
|
||||||
|
from ..compat import compat_urllib_parse_urlencode
|
||||||
|
|
||||||
|
|
||||||
class TwentyThreeVideoIE(InfoExtractor):
|
class TwentyThreeVideoIE(InfoExtractor):
|
||||||
IE_NAME = '23video'
|
IE_NAME = '23video'
|
||||||
_VALID_URL = r'https?://(?P<domain>[^.]+\.(?:twentythree\.net|23video\.com|filmweb\.no))/v\.ihtml/player\.html\?(?P<query>.*?\bphoto(?:_|%5f)id=(?P<id>\d+).*)'
|
_VALID_URL = r'https?://(?P<domain>[^.]+\.(?:twentythree\.net|kglteater\.dk|23video\.com|filmweb\.no))/v\.ihtml/player\.html\?(?P<query>.*?\bphoto(?:_|%5f)id=(?P<id>\d+).*)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://video.twentythree.net/v.ihtml/player.html?showDescriptions=0&source=site&photo%5fid=20448876&autoPlay=1',
|
'url': 'https://video.twentythree.net/v.ihtml/player.html?showDescriptions=0&source=site&photo%5fid=20448876&autoPlay=1',
|
||||||
'md5': '75fcf216303eb1dae9920d651f85ced4',
|
'md5': '75fcf216303eb1dae9920d651f85ced4',
|
||||||
@ -23,18 +24,93 @@ class TwentyThreeVideoIE(InfoExtractor):
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://bonnier-publications-danmark.23video.com/v.ihtml/player.html?token=f0dc46476e06e13afd5a1f84a29e31e8&source=embed&photo%5fid=36137620',
|
'url': 'https://bonnier-publications-danmark.23video.com/v.ihtml/player.html?token=f0dc46476e06e13afd5a1f84a29e31e8&source=embed&photo%5fid=36137620',
|
||||||
'only_matching': True,
|
'md5': '772a91f83d129ee5f015b12bea61a78b',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '36137620',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Photoshop Elements 2019 - Photo Text',
|
||||||
|
'timestamp': 1538664032,
|
||||||
|
'upload_date': '20181004',
|
||||||
|
'uploader_id': '10801356',
|
||||||
|
'uploader': 'Kristoffer Engbo',
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'url': 'https://video.kglteater.dk/v.ihtml/player.html?source=share&photo%5fid=65098499',
|
||||||
|
'md5': '4e20a33ce86b13ca114ee44a0a8d8efb',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '65098499',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'Askepot',
|
||||||
|
'timestamp': 1605173942,
|
||||||
|
'upload_date': '20201112',
|
||||||
|
'uploader_id': '62151179',
|
||||||
|
'uploader': 'jbny',
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
'url': 'https://video.kglteater.dk/v.ihtml/player.html?showDescriptions=0&source=site&photo%5fid=52486482&autoPlay=1',
|
||||||
|
'md5': 'c39ffb965079fb4395788e6814ec3cdc',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '52486482',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'N\xf8ddekn\xe6kkeren 2019',
|
||||||
|
'timestamp': 1558953133,
|
||||||
|
'upload_date': '20190527',
|
||||||
|
'uploader_id': '7450690',
|
||||||
|
'uploader': 'Tejs Holm',
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
domain, query, photo_id = re.match(self._VALID_URL, url).groups()
|
domain, query, photo_id = re.match(self._VALID_URL, url).groups()
|
||||||
base_url = 'https://%s' % domain
|
base_url = 'https://%s' % domain
|
||||||
photo_data = self._download_json(
|
|
||||||
base_url + '/api/photo/list?' + query, photo_id, query={
|
|
||||||
'format': 'json',
|
|
||||||
}, transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'photo data'))['photo']
|
|
||||||
title = photo_data['title']
|
|
||||||
|
|
||||||
|
def is_geo_blocked():
|
||||||
|
# /api/player/settings
|
||||||
|
playersettings_0 = {'player_id': 0, 'parameters': 'showDescriptions=0&source=site&photo%5fid=' + photo_id + '&autoPlay=1', '_li': 0, '_bot': 0}
|
||||||
|
playersettings_0_param = '/api/player/settings?' + compat_urllib_parse_urlencode(playersettings_0)
|
||||||
|
|
||||||
|
# /api/live/list
|
||||||
|
livelist_1 = {'include_actions_p': 1, 'showDescriptions': 0, 'source': 'site', 'photo_id': photo_id, 'autoPlay': 1, 'upcoming_p': 1, 'ordering': 'streaming', 'player_id': 0}
|
||||||
|
livelist_1_param = '/api/live/list?' + compat_urllib_parse_urlencode(livelist_1)
|
||||||
|
|
||||||
|
# /api/photo/list
|
||||||
|
photolist_2 = {'size': 10, 'include_actions_p': 1, 'showDescriptions': 0, 'source': 'site', 'photo_id': photo_id, 'autoPlay': 1, 'player_id': 0}
|
||||||
|
photolist_2_param = '/api/photo/list?' + compat_urllib_parse_urlencode(photolist_2)
|
||||||
|
|
||||||
|
new_query = {'format': 'json', 'callback': 'test', 'playersettings_0': playersettings_0_param, 'livelist_1': livelist_1_param, 'photolist_2': photolist_2_param}
|
||||||
|
photolist_result = self._download_json(
|
||||||
|
base_url + '/api/concatenate',
|
||||||
|
photo_id,
|
||||||
|
query=new_query,
|
||||||
|
transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'photolist_2')
|
||||||
|
)["photolist_2"]
|
||||||
|
|
||||||
|
if "photos" in photolist_result:
|
||||||
|
for photo in photolist_result['photos']:
|
||||||
|
if photo['photo_id'] == photo_id:
|
||||||
|
return photo['protection_method'] == 'geoblocking'
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get_video_query():
|
||||||
|
if is_geo_blocked():
|
||||||
|
token = self._download_json(
|
||||||
|
base_url + '/api/protection/verify',
|
||||||
|
photo_id,
|
||||||
|
query={'protection_method': 'geoblocking', 'object_id': photo_id, 'object_type': 'photo', 'format': 'json', 'callback': 'visualplatform_1'},
|
||||||
|
transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'protectedtoken'))['protectedtoken']['protected_token']
|
||||||
|
|
||||||
|
return {'format': 'json', 'token': token}
|
||||||
|
else:
|
||||||
|
return {'format': 'json'}
|
||||||
|
|
||||||
|
video_query = get_video_query()
|
||||||
|
photo_data = self._download_json(
|
||||||
|
base_url + '/api/photo/list?' + query, photo_id,
|
||||||
|
query=video_query,
|
||||||
|
transform_source=lambda s: self._search_regex(r'(?s)({.+})', s, 'photo data'))['photo']
|
||||||
|
|
||||||
|
title = photo_data['title']
|
||||||
formats = []
|
formats = []
|
||||||
|
|
||||||
audio_path = photo_data.get('audio_download')
|
audio_path = photo_data.get('audio_download')
|
||||||
|
@ -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