Compare commits

...

18 Commits

Author SHA1 Message Date
Mozi
346550f721
Merge 98e034ff8c into 2009cb27e1 2024-11-17 22:34:16 +01:00
bashonly
2009cb27e1
[ie/SonyLIVSeries] Add sort_order extractor-arg (#11569)
Authored by: bashonly
2024-11-17 21:16:22 +00:00
Jackson Humphrey
f351440f1d
[ie/ctvnews] Fix extractor (#11534)
Closes #8689
Authored by: jshumphrey, bashonly

Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
2024-11-17 21:06:50 +00:00
qbnu
f9d98509a8
[ie/ctvnews] Fix playlist ID extraction (#8892)
Authored by: qbnu
2024-11-17 19:35:10 +00:00
Mozi
98e034ff8c comment about DRM 2024-10-31 01:23:23 +00:00
Mozi
971bf92c06 code style 2024-10-31 01:12:57 +00:00
Mozi
aa512f8b45 merge 'master' 2024-10-31 01:09:27 +00:00
Mozi
81075d168e fix typo; compat code 2024-10-31 01:06:31 +00:00
Mozi
77debf548f FifaContent: no positive redirection detection 2024-10-30 17:42:19 +00:00
Mozi
7f94f2fceb merge 'master' 2024-10-30 17:37:36 +00:00
Mozi
5f6a442047 Rewrite code; DRM content is being only matching 2024-10-30 17:37:09 +00:00
Mozi
76111ea625 merge 'master' 2024-10-28 00:32:14 +00:00
Mozi
ac5c846921 fix usage of self._merge_subtitles 2024-10-28 00:31:56 +00:00
Mozi
3585397c7f add fatal to _call_api 2024-10-18 16:11:54 +00:00
Mozi
dcc4a1672b merge 'master' 2024-10-18 16:03:20 +00:00
Mozi
bb98db29a1 simplify _call_api 2024-10-18 16:03:03 +00:00
Mozi
4e649c6a28 use "getter" in playlist_from_matches() 2024-10-13 10:26:00 +00:00
Mozi
a29bfa3b0c [ie/Fifa] Add extractors 2024-09-30 17:14:06 +00:00
5 changed files with 478 additions and 92 deletions

View File

@ -1869,6 +1869,9 @@ The following extractors use this feature:
#### digitalconcerthall #### digitalconcerthall
* `prefer_combined_hls`: Prefer extracting combined/pre-merged video and audio HLS formats. This will exclude 4K/HEVC video and lossless/FLAC audio formats, which are only available as split video/audio HLS formats * `prefer_combined_hls`: Prefer extracting combined/pre-merged video and audio HLS formats. This will exclude 4K/HEVC video and lossless/FLAC audio formats, which are only available as split video/audio HLS formats
#### sonylivseries
* `sort_order`: Episode sort order for series extraction - one of `asc` (ascending, oldest first) or `desc` (descending, newest first). Default is `asc`
**Note**: These options may be changed/removed in the future without concern for backward compatibility **Note**: These options may be changed/removed in the future without concern for backward compatibility
<!-- MANPAGE: MOVE "INSTALLATION" SECTION HERE --> <!-- MANPAGE: MOVE "INSTALLATION" SECTION HERE -->

View File

@ -646,7 +646,11 @@ from .fc2 import (
FC2LiveIE, FC2LiveIE,
) )
from .fczenit import FczenitIE from .fczenit import FczenitIE
from .fifa import FifaIE from .fifa import (
FifaArticleIE,
FifaContentIE,
FifaPlayerIE,
)
from .filmon import ( from .filmon import (
FilmOnChannelIE, FilmOnChannelIE,
FilmOnIE, FilmOnIE,

View File

@ -1,14 +1,27 @@
import json
import re import re
import urllib.parse
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import orderedSet from .ninecninemedia import NineCNineMediaIE
from ..utils import extract_attributes, orderedSet
from ..utils.traversal import find_element, traverse_obj
class CTVNewsIE(InfoExtractor): class CTVNewsIE(InfoExtractor):
_VALID_URL = r'https?://(?:.+?\.)?ctvnews\.ca/(?:video\?(?:clip|playlist|bin)Id=|.*?)(?P<id>[0-9.]+)' _BASE_REGEX = r'https?://(?:[^.]+\.)?ctvnews\.ca/'
_VIDEO_ID_RE = r'(?P<id>\d{5,})'
_PLAYLIST_ID_RE = r'(?P<id>\d\.\d{5,})'
_VALID_URL = [
rf'{_BASE_REGEX}video/c{_VIDEO_ID_RE}',
rf'{_BASE_REGEX}video(?:-gallery)?/?\?clipId={_VIDEO_ID_RE}',
rf'{_BASE_REGEX}video/?\?(?:playlist|bin)Id={_PLAYLIST_ID_RE}',
rf'{_BASE_REGEX}(?!video/)[^?#]*?{_PLAYLIST_ID_RE}/?(?:$|[?#])',
rf'{_BASE_REGEX}(?!video/)[^?#]+\?binId={_PLAYLIST_ID_RE}',
]
_TESTS = [{ _TESTS = [{
'url': 'http://www.ctvnews.ca/video?clipId=901995', 'url': 'http://www.ctvnews.ca/video?clipId=901995',
'md5': '9b8624ba66351a23e0b6e1391971f9af', 'md5': 'b608f466c7fa24b9666c6439d766ab7e',
'info_dict': { 'info_dict': {
'id': '901995', 'id': '901995',
'ext': 'flv', 'ext': 'flv',
@ -16,6 +29,33 @@ class CTVNewsIE(InfoExtractor):
'description': 'md5:958dd3b4f5bbbf0ed4d045c790d89285', 'description': 'md5:958dd3b4f5bbbf0ed4d045c790d89285',
'timestamp': 1467286284, 'timestamp': 1467286284,
'upload_date': '20160630', 'upload_date': '20160630',
'categories': [],
'season_number': 0,
'season': 'Season 0',
'tags': [],
'series': 'CTV News National | Archive | Stories 2',
'season_id': '57981',
'thumbnail': r're:https?://.*\.jpg$',
'duration': 764.631,
},
}, {
'url': 'https://barrie.ctvnews.ca/video/c3030933-here_s-what_s-making-news-for-nov--15?binId=1272429',
'md5': '8b8c2b33c5c1803e3c26bc74ff8694d5',
'info_dict': {
'id': '3030933',
'ext': 'flv',
'title': 'Heres whats making news for Nov. 15',
'description': 'Here are the top stories were working on for CTV News at 11 for Nov. 15',
'thumbnail': 'http://images2.9c9media.com/image_asset/2021_2_22_a602e68e-1514-410e-a67a-e1f7cccbacab_png_2000x1125.jpg',
'season_id': '58104',
'season_number': 0,
'tags': [],
'season': 'Season 0',
'categories': [],
'series': 'CTV News Barrie',
'upload_date': '20241116',
'duration': 42.943,
'timestamp': 1731722452,
}, },
}, { }, {
'url': 'http://www.ctvnews.ca/video?playlistId=1.2966224', 'url': 'http://www.ctvnews.ca/video?playlistId=1.2966224',
@ -31,6 +71,72 @@ class CTVNewsIE(InfoExtractor):
'id': '1.2876780', 'id': '1.2876780',
}, },
'playlist_mincount': 100, 'playlist_mincount': 100,
}, {
'url': 'https://www.ctvnews.ca/it-s-been-23-years-since-toronto-called-in-the-army-after-a-major-snowstorm-1.5736957',
'info_dict':
{
'id': '1.5736957',
},
'playlist_mincount': 6,
}, {
'url': 'https://www.ctvnews.ca/business/respondents-to-bank-of-canada-questionnaire-largely-oppose-creating-a-digital-loonie-1.6665797',
'md5': '24bc4b88cdc17d8c3fc01dfc228ab72c',
'info_dict': {
'id': '2695026',
'ext': 'flv',
'season_id': '89852',
'series': 'From CTV News Channel',
'description': 'md5:796a985a23cacc7e1e2fafefd94afd0a',
'season': '2023',
'title': 'Bank of Canada asks public about digital currency',
'categories': [],
'tags': [],
'upload_date': '20230526',
'season_number': 2023,
'thumbnail': 'http://images2.9c9media.com/image_asset/2019_3_28_35f5afc3-10f6-4d92-b194-8b9a86f55c6a_png_1920x1080.jpg',
'timestamp': 1685105157,
'duration': 253.553,
},
}, {
'url': 'https://stox.ctvnews.ca/video-gallery?clipId=582589',
'md5': '135cc592df607d29dddc931f1b756ae2',
'info_dict': {
'id': '582589',
'ext': 'flv',
'categories': [],
'timestamp': 1427906183,
'season_number': 0,
'duration': 125.559,
'thumbnail': 'http://images2.9c9media.com/image_asset/2019_3_28_35f5afc3-10f6-4d92-b194-8b9a86f55c6a_png_1920x1080.jpg',
'series': 'CTV News Stox',
'description': 'CTV original footage of the rise and fall of the Berlin Wall.',
'title': 'Berlin Wall',
'season_id': '63817',
'season': 'Season 0',
'tags': [],
'upload_date': '20150401',
},
}, {
'url': 'https://ottawa.ctvnews.ca/features/regional-contact/regional-contact-archive?binId=1.1164587#3023759',
'md5': 'a14c0603557decc6531260791c23cc5e',
'info_dict': {
'id': '3023759',
'ext': 'flv',
'season_number': 2024,
'timestamp': 1731798000,
'season': '2024',
'episode': 'Episode 125',
'description': 'CTV News Ottawa at Six',
'duration': 2712.076,
'episode_number': 125,
'upload_date': '20241116',
'title': 'CTV News Ottawa at Six for Saturday, November 16, 2024',
'thumbnail': 'http://images2.9c9media.com/image_asset/2019_3_28_35f5afc3-10f6-4d92-b194-8b9a86f55c6a_png_1920x1080.jpg',
'categories': [],
'tags': [],
'series': 'CTV News Ottawa at Six',
'season_id': '92667',
},
}, { }, {
'url': 'http://www.ctvnews.ca/1.810401', 'url': 'http://www.ctvnews.ca/1.810401',
'only_matching': True, 'only_matching': True,
@ -42,29 +148,35 @@ class CTVNewsIE(InfoExtractor):
'only_matching': True, 'only_matching': True,
}] }]
def _ninecninemedia_url_result(self, clip_id):
return self.url_result(f'9c9media:ctvnews_web:{clip_id}', NineCNineMediaIE, clip_id)
def _real_extract(self, url): def _real_extract(self, url):
page_id = self._match_id(url) page_id = self._match_id(url)
def ninecninemedia_url_result(clip_id): if mobj := re.fullmatch(self._VIDEO_ID_RE, urllib.parse.urlparse(url).fragment):
return { page_id = mobj.group('id')
'_type': 'url_transparent',
'id': clip_id,
'url': f'9c9media:ctvnews_web:{clip_id}',
'ie_key': 'NineCNineMedia',
}
if page_id.isdigit(): if re.fullmatch(self._VIDEO_ID_RE, page_id):
return ninecninemedia_url_result(page_id) return self._ninecninemedia_url_result(page_id)
else:
webpage = self._download_webpage(f'http://www.ctvnews.ca/{page_id}', page_id, query={ webpage = self._download_webpage(f'https://www.ctvnews.ca/{page_id}', page_id, query={
'ot': 'example.AjaxPageLayout.ot', 'ot': 'example.AjaxPageLayout.ot',
'maxItemsPerPage': 1000000, 'maxItemsPerPage': 1000000,
}) })
entries = [ninecninemedia_url_result(clip_id) for clip_id in orderedSet( entries = [self._ninecninemedia_url_result(clip_id)
re.findall(r'clip\.id\s*=\s*(\d+);', webpage))] for clip_id in orderedSet(re.findall(r'clip\.id\s*=\s*(\d+);', webpage))]
if not entries: if not entries:
webpage = self._download_webpage(url, page_id) webpage = self._download_webpage(url, page_id)
if 'getAuthStates("' in webpage: if 'getAuthStates("' in webpage:
entries = [ninecninemedia_url_result(clip_id) for clip_id in entries = [self._ninecninemedia_url_result(clip_id) for clip_id in
self._search_regex(r'getAuthStates\("([\d+,]+)"', webpage, 'clip ids').split(',')] self._search_regex(r'getAuthStates\("([\d+,]+)"', webpage, 'clip ids').split(',')]
return self.playlist_result(entries, page_id) else:
entries = [
self._ninecninemedia_url_result(clip_id) for clip_id in
traverse_obj(webpage, (
{find_element(tag='jasper-player-container', html=True)},
{extract_attributes}, 'axis-ids', {json.loads}, ..., 'axisId'))
]
return self.playlist_result(entries, page_id)

View File

@ -1,82 +1,339 @@
import functools
import json
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
ExtractorError,
determine_ext,
float_or_none,
int_or_none, int_or_none,
traverse_obj, parse_iso8601,
strip_or_none,
unified_timestamp, unified_timestamp,
update_url_query,
) )
from ..utils.traversal import traverse_obj
class FifaIE(InfoExtractor): class FifaBaseIE(InfoExtractor):
_VALID_URL = r'https?://www\.fifa\.com/fifaplus/(?P<locale>\w{2})/watch/([^#?]+/)?(?P<id>\w+)' _HEADERS = {
_TESTS = [{ 'content-type': 'application/json; charset=UTF-8',
'url': 'https://www.fifa.com/fifaplus/en/watch/7on10qPcnyLajDDU3ntg6y', 'x-chili-accept-language': 'en',
'info_dict': { 'x-chili-api-version': '1.1',
'id': '7on10qPcnyLajDDU3ntg6y', 'x-chili-authenticated': 'false',
'title': 'Italy v France | Final | 2006 FIFA World Cup Germany™ | Full Match Replay', 'x-chili-device-id': 'undefined',
'description': 'md5:f4520d0ee80529c8ba4134a7d692ff8b', 'x-chili-device-profile': 'WEB',
'ext': 'mp4', 'x-chili-device-store': 'CHILI',
'categories': ['FIFA Tournaments'], 'x-chili-user-country': 'US',
'thumbnail': 'https://digitalhub.fifa.com/transform/135e2656-3a51-407b-8810-6c34bec5b59b/FMR_2006_Italy_France_Final_Hero', 'x-chili-accept-stream-mode': 'multi/codec-compatibility;q=0.8, mono/strict;q=0.7',
'duration': 8165, 'x-chili-avod-compatibility': 'free,free-ads',
'release_timestamp': 1152403200, 'x-chili-manifest-properties': 'subtitles',
'release_date': '20060709', 'x-chili-streaming-proto': 'https',
}, }
'params': {'skip_download': 'm3u8'},
}, {
'url': 'https://www.fifa.com/fifaplus/pt/watch/1cg5r5Qt6Qt12ilkDgb1sV',
'info_dict': {
'id': '1cg5r5Qt6Qt12ilkDgb1sV',
'title': 'Brazil v Germany | Semi-finals | 2014 FIFA World Cup Brazil™ | Extended Highlights',
'description': 'md5:d908c74ee66322b804ae2e521b02a855',
'ext': 'mp4',
'categories': ['FIFA Tournaments', 'Highlights'],
'thumbnail': 'https://digitalhub.fifa.com/transform/d8fe6f61-276d-4a73-a7fe-6878a35fd082/FIFAPLS_100EXTHL_2014BRAvGER_TMB',
'duration': 902,
'release_timestamp': 1404777600,
'release_date': '20140708',
},
'params': {'skip_download': 'm3u8'},
}, {
'url': 'https://www.fifa.com/fifaplus/fr/watch/3C6gQH9C2DLwzNx7BMRQdp',
'info_dict': {
'id': '3C6gQH9C2DLwzNx7BMRQdp',
'title': 'Josimar goal against Northern Ireland | Classic Goals',
'description': 'md5:cbe7e7bb52f603c9f1fe9a4780fe983b',
'ext': 'mp4',
'categories': ['FIFA Tournaments', 'Goal'],
'duration': 28,
'thumbnail': 'https://digitalhub.fifa.com/transform/f9301391-f8d9-48b5-823e-c093ac5e3e11/CG_MEN_1986_JOSIMAR',
},
'params': {'skip_download': 'm3u8'},
}]
def _real_extract(self, url): def _call_api(self, path, video_id, note=None, headers=None, query=None, data=None):
video_id, locale = self._match_valid_url(url).group('id', 'locale') return self._download_json(
webpage = self._download_webpage(url, video_id) f'https://www.plus.fifa.com/{path}', video_id, note, headers={
**self._HEADERS,
**(headers or {}),
}, query=query, data=data)
preconnect_link = self._search_regex( def _real_initialize(self):
r'<link\b[^>]+\brel\s*=\s*"preconnect"[^>]+href\s*=\s*"([^"]+)"', webpage, 'Preconnect Link') device_info = self._call_api(
'gatekeeper/api/v1/devices/', None, 'Getting device info',
data=json.dumps({
'appVersion': '2.6.93',
'displayName': None,
'model': 'Chrome',
'manufacturer': 'Google Inc.',
'osName': 'Windows',
'osVersion': '10',
'platform': 'Chrome',
'platformVersion': '129.0.0.0',
'architecture': 'unknown',
'profile': 'WEB',
'store': 'CHILI',
'screenWidth': '1920',
'screenHeight': '1080',
}).encode())
self._HEADERS['x-chili-device-id'] = device_info['id']
video_details = self._download_json( def _extract_video(self, video_info, video_id):
f'{preconnect_link}/sections/videoDetails/{video_id}', video_id, 'Downloading Video Details', fatal=False) formats = []
subtitles = {}
preplay_parameters = self._download_json( for stream_type in [
f'{preconnect_link}/videoPlayerData/{video_id}', video_id, 'Downloading Preplay Parameters')['preplayParameters'] 'hls/cbcs+h265.sdr;q=0.9, hls/cbcs+h264;q=0.5, hls/clear+h264;q=0.4, mp4/;q=0.1',
'mpd/cenc+h264;q=0.9, mpd/clear+h264;q=0.7, mp4/;q=0.1',
]:
session_info = self._call_api(
'flux-capacitor/api/v1/streaming/session', video_id,
'Getting streaming session', headers={'x-chili-accept-stream': stream_type},
data=json.dumps({'videoAssetId': video_info['id'], 'autoPlay': False}).encode())
streams_info = self._call_api(
'flux-capacitor/api/v1/streaming/urls', video_id, 'Getting streaming urls',
headers={'x-chili-streaming-session': session_info['id']})
content_data = self._download_json( for playlist_url in traverse_obj(streams_info, (..., 'url')):
'https://content.uplynk.com/preplay/{contentId}/multiple.json?{queryStr}&sig={signature}'.format(**preplay_parameters), ext = determine_ext(playlist_url)
video_id, 'Downloading Content Data') if ext == 'mpd':
fmts, subs = self._extract_mpd_formats_and_subtitles(playlist_url, video_id)
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
elif ext == 'm3u8':
fmts, subs = self._extract_m3u8_formats_and_subtitles(playlist_url, video_id, m3u8_id='hls')
formats.extend(fmts)
self._merge_subtitles(subs, target=subtitles)
else:
raise ExtractorError(f'Unknown playlist URL {playlist_url}', video_id=video_id)
formats, subtitles = self._extract_m3u8_formats_and_subtitles(content_data['playURL'], video_id) self._remove_duplicate_formats(formats)
return { return {
'id': video_id, 'id': video_id,
'title': video_details.get('title'), 'title': strip_or_none(video_info['title']),
'description': video_details.get('description'), 'duration': float_or_none(video_info.get('duration'), scale=1000),
'duration': int_or_none(video_details.get('duration')),
'release_timestamp': unified_timestamp(video_details.get('dateOfRelease')),
'categories': traverse_obj(video_details, (('videoCategory', 'videoSubcategory'),)),
'thumbnail': traverse_obj(video_details, ('backgroundImage', 'src')),
'formats': formats, 'formats': formats,
'subtitles': subtitles, 'subtitles': subtitles,
'age_limit': traverse_obj(video_info, ('parental', 'age', {int_or_none})),
'thumbnails': [{
'url': update_url_query(x, {'width': 1408}),
'width': 1408,
} for x in [video_info.get('posterUrl'), video_info.get('wideCoverUrl')] if x],
} }
class FifaPlayerIE(FifaBaseIE):
_VALID_URL = r'https?://(www\.)?plus\.fifa\.com/(?:\w{2})/player/(?P<id>[\w-]+)/?\?(?:[^#]+&)?catalogId=(?P<catalog_id>[\w-]+)'
_TESTS = [{
'url': 'https://www.plus.fifa.com/en/player/f67b9d46-38c3-4e38-bbf3-89cf14cbcc1a?catalogId=b9c32230-1426-46d0-8448-ca824ae48603&entryPoint=Slider',
'info_dict': {
'id': 'f67b9d46-38c3-4e38-bbf3-89cf14cbcc1a',
'ext': 'mp4',
'title': 'Trailer | HD Cutz',
'age_limit': 0,
'duration': 195.84,
'thumbnail': r're:https://cdn\.plus\.fifa\.com//images/public/cms/[/\w-]+\.jpg\?width=1408',
},
'params': {'skip_download': 'm3u8'},
}, {
'url': 'https://www.plus.fifa.com/en/player/af65939f-bbce-4b8f-8462-5140af533c5f?catalogId=fac6685c-a900-4e78-b5cd-192af5131ffe&entryPoint=Slider',
'md5': '2c4f5c591448d372f6ba85b8f3be37df',
'info_dict': {
'id': 'af65939f-bbce-4b8f-8462-5140af533c5f',
'ext': 'mp4',
'title': 'Trailer | Bravas de Juárez',
'age_limit': 0,
'duration': 73.984,
'thumbnail': r're:https://cdn\.plus\.fifa\.com//images/public/cms/[/\w-]+\.jpg\?width=1408',
},
}, {
'url': 'https://plus.fifa.com/en/player/eeebdd38-5d51-4891-8307-ab5dd62c2c32?catalogId=ed3b2dcb-6886-4b34-8ba7-c8800027f7dd',
'only_matching': True,
}]
def _real_extract(self, url):
video_id, catalog_id = self._match_valid_url(url).group('id', 'catalog_id')
video_asset = self._call_api(
'flux-capacitor/api/v1/videoasset', video_id,
'Downloading video asset', query={'catalog': catalog_id})
video_info = traverse_obj(video_asset, (lambda _, v: v['id'] == video_id), get_all=False)
if not video_info:
raise ExtractorError('Unable to extract video info')
return self._extract_video(video_info, video_id)
class FifaContentIE(FifaBaseIE):
_VALID_URL = r'https?://(www\.)?plus\.fifa\.com/(?:\w{2})/content/(?P<display_id>[\w-]+)/(?P<id>[\w-]+)/?(?:[#?]|$)'
_TESTS = [{
# from https://www.fifa.com/fifaplus/en/watch/series/48PQFX2J4TiDJcxWOxUPho/2ka5yomq8MBvfxe205zdQ9/6H72309PLWXafBIavvPzPQ#ReadMore
'url': 'https://www.plus.fifa.com/en/content/kariobangi/6f3be63f-76d9-4290-9e60-fd62afa95ed7',
'info_dict': {
'id': '6f3be63f-76d9-4290-9e60-fd62afa95ed7',
'title': 'Kariobangi',
'description': 'md5:b57eb012db2b84d482adedda82faf1c8',
'display_id': 'kariobangi',
'thumbnails': 'count:2',
},
'playlist_count': 0,
}, {
# from https://www.fifa.com/fifaplus/en/watch/series/5Ja1dDLuudkFF95OVHcYBG/5epcWav73zMbjTJh2RxIOt/1NIHdDxPlYodbNobjS1iX5
'url': 'https://www.plus.fifa.com/en/content/hd-cutz/b9c32230-1426-46d0-8448-ca824ae48603',
'info_dict': {
'id': 'b9c32230-1426-46d0-8448-ca824ae48603',
'title': 'HD Cutz',
'description': 'md5:86dd1e6d9b4463b3ccc2063ab3180c44',
'display_id': 'hd-cutz',
'thumbnails': 'count:2',
},
'playlist': [{
'info_dict': {
'id': 'b9c32230-1426-46d0-8448-ca824ae48603',
'ext': 'mp4',
'title': 'Trailer | HD Cutz',
'age_limit': 0,
'duration': 195.840,
'thumbnail': r're:https://cdn\.plus\.fifa\.com//images/public/cms/[/\w-]+\.jpg\?width=1408',
},
}],
'params': {'skip_download': 'm3u8'},
}, {
# from https://www.fifa.com/fifaplus/en/watch/movie/2OFuZ9TGyPH6x7nZsgnVBN
'url': 'https://www.plus.fifa.com/en/content/bravas-de-juarez/fac6685c-a900-4e78-b5cd-192af5131ffe',
'info_dict': {
'id': 'fac6685c-a900-4e78-b5cd-192af5131ffe',
'title': 'Bravas de Juárez',
'description': 'md5:e48e0f56fb27ac334e616976e0e62362',
'display_id': 'bravas-de-juarez',
},
'playlist': [{
'info_dict': {
'id': 'fac6685c-a900-4e78-b5cd-192af5131ffe',
'ext': 'mp4',
'title': 'Trailer | Bravas de Juárez',
'age_limit': 0,
'duration': 73.984,
'thumbnail': r're:https://cdn\.plus\.fifa\.com//images/public/cms/[/\w-]+\.jpg\?width=1408',
},
}],
}]
_WEBPAGE_TESTS = [{
# https://www.plus.fifa.com/en/content/le-moment-the-official-film-of-the-2019-fifa-womens-world-cup/68a89002-0182-4cc7-b858-e548de0fb9cc
'url': 'https://www.fifa.com/fifaplus/en/watch/movie/01ioUo8QHiajSisrvP3ES2',
'info_dict': {
'id': '68a89002-0182-4cc7-b858-e548de0fb9cc',
'title': 'Le Moment',
'description': 'md5:155f0c28ea9de733668d7eb1f7dbcb52',
'display_id': 'le-moment-the-official-film-of-the-2019-fifa-womens-world-cup',
},
'playlist_count': 0,
}, {
# https://www.plus.fifa.com/en/content/dreams-2018-fifa-world-cup-official-film/ebdce1da-ab82-4c0b-a7d3-b4fc71030339
'url': 'https://www.fifa.com/fifaplus/en/watch/movie/69GbI9lVcwhOeBvea5eKUB',
'info_dict': {
'id': 'ebdce1da-ab82-4c0b-a7d3-b4fc71030339',
'title': 'Dreams',
'description': 'md5:b795d218d5c2b88bff3c1569cb617acb',
'display_id': 'dreams-2018-fifa-world-cup-official-film',
},
'playlist_count': 0,
}]
def _entries(self, video_asset, video_id):
# trailers are non-DRM'd
for video_info in traverse_obj(video_asset, (lambda _, v: v['type'] == 'TRAILER', {dict})):
yield self._extract_video(video_info, video_id)
def _real_extract(self, url):
video_id, display_id = self._match_valid_url(url).group('id', 'display_id')
video_content = self._call_api(
f'entertainment/api/v1/contents/{video_id}', video_id, 'Downloading video content')
video_asset = self._call_api(
'flux-capacitor/api/v1/videoasset', video_id,
'Downloading video asset', query={'catalog': video_id})
thumbnails = []
for key, width in [('coverUrl', 330), ('wideCoverUrl', 1408)]:
if thumbnail_url := video_content.get(key):
thumbnails.append({
'url': update_url_query(thumbnail_url, {'width': width}),
'width': width,
})
return self.playlist_result(
self._entries(video_asset, video_id), video_id,
strip_or_none(video_content['title']), strip_or_none(video_content.get('storyLine')),
display_id=display_id, thumbnails=thumbnails)
class FifaArticleIE(InfoExtractor):
_VALID_URL = r'https?://(www\.)?fifa\.com/(fifaplus/)?(?P<locale>\w{2})/articles/(?P<id>[\w-]+)'
_TESTS = [{
'url': 'https://www.fifa.com/en/articles/foord-talks-2023-and-battling-kerr-for-the-wsl-title',
'info_dict': {
'id': 'foord-talks-2023-and-battling-kerr-for-the-wsl-title',
'title': 'Foord talks 2023 and battling Kerr for the WSL title',
'timestamp': 1651136400,
'upload_date': '20220428',
},
'playlist': [{
'info_dict': {
'id': '6B2xtOT2SDMB4JeF3i9n2y',
'ext': 'mp4',
'title': 'Foord & Kerr: Friends and rivals',
'description': 'md5:756e14e1814196948ec4d2a9663f7214',
'duration': 82,
'categories': ['News', 'Interview'],
'thumbnail': r're:https://digitalhub\.fifa\.com/transform/[^/]+/\w+',
},
}, {
'info_dict': {
'id': 'R2Y1vbwvggrlSr02Cfr99',
'ext': 'mp4',
'title': 'Foord: 2023 will be the best Women\'s World Cup yet',
'description': 'Matildas star Caitlin Foord looks ahead to the FIFA Women\'s World Cup Australia & New Zealand 2023™.',
'duration': 44,
'categories': ['News', 'Interview'],
'thumbnail': r're:https://digitalhub\.fifa\.com/transform/[^/]+/\w+',
},
}],
'params': {'skip_download': 'm3u8'},
}, {
# https://www.fifa.com/en/articles/stars-set-to-collide-in-uwcl-final
'url': 'https://www.fifa.com/fifaplus/en/articles/stars-set-to-collide-in-uwcl-final',
'only_matching': True,
}]
@functools.cached_property
def _preconnect_link(self):
return self._search_regex(
r'<link\b[^>]+\brel\s*=\s*"preconnect"[^>]+href\s*=\s*"([^"]+)"',
self._download_webpage('https://fifa.com/', None), 'Preconnect Link')
def _call_api(self, path, video_id, note=None, query=None, fatal=True):
return self._download_json(
f'{self._preconnect_link}/{path}', video_id, note, query=query, fatal=fatal)
def _entries(self, video_ids, article_id):
for video_id in video_ids:
video_details = self._call_api(
f'sections/videoDetails/{video_id}', article_id,
'Downloading Video Details', fatal=False)
preplay_parameters = self._call_api(
f'videoPlayerData/{video_id}', article_id,
'Downloading Preplay Parameters')['preplayParameters']
content_data = self._download_json(
'https://content.uplynk.com/preplay/{contentId}/multiple.json?{queryStr}&sig={signature}'.format(
**preplay_parameters), article_id, 'Downloading Content Data')
formats, subtitles = self._extract_m3u8_formats_and_subtitles(content_data['playURL'], article_id)
yield {
'id': video_id,
'title': video_details.get('title'),
'description': video_details.get('description'),
'duration': int_or_none(video_details.get('duration')),
'release_timestamp': unified_timestamp(video_details.get('dateOfRelease')),
'categories': traverse_obj(video_details, (('videoCategory', 'videoSubcategory'),)),
'thumbnail': traverse_obj(video_details, ('backgroundImage', 'src')),
'formats': formats,
'subtitles': subtitles,
}
def _real_extract(self, url):
article_id, locale = self._match_valid_url(url).group('id', 'locale')
page_id = self._call_api(f'pages/en/articles/{article_id}', article_id)['pageId']
page_info = self._call_api(f'sections/article/{page_id}', article_id, query={'locale': locale})
video_ids = []
if hero_video_entry_id := page_info.get('heroVideoEntryId'):
video_ids.append(hero_video_entry_id)
video_ids.extend(traverse_obj(page_info, (
'richtext', 'content', lambda _, v: v['data']['target']['contentTypesCheckboxValue'] == 'Video',
'data', 'target', 'sys', 'id')))
return self.playlist_result(
self._entries(video_ids, article_id), article_id, page_info.get('articleTitle'),
timestamp=parse_iso8601(page_info.get('articlePublishedDate')))

View File

@ -199,8 +199,9 @@ class SonyLIVSeriesIE(InfoExtractor):
}, },
}] }]
_API_BASE = 'https://apiv2.sonyliv.com/AGL' _API_BASE = 'https://apiv2.sonyliv.com/AGL'
_SORT_ORDERS = ('asc', 'desc')
def _entries(self, show_id): def _entries(self, show_id, sort_order):
headers = { headers = {
'Accept': 'application/json, text/plain, */*', 'Accept': 'application/json, text/plain, */*',
'Referer': 'https://www.sonyliv.com', 'Referer': 'https://www.sonyliv.com',
@ -215,6 +216,9 @@ class SonyLIVSeriesIE(InfoExtractor):
'from': '0', 'from': '0',
'to': '49', 'to': '49',
}), ('resultObj', 'containers', 0, 'containers', lambda _, v: int_or_none(v['id']))) }), ('resultObj', 'containers', 0, 'containers', lambda _, v: int_or_none(v['id'])))
if sort_order == 'desc':
seasons = reversed(seasons)
for season in seasons: for season in seasons:
season_id = str(season['id']) season_id = str(season['id'])
note = traverse_obj(season, ('metadata', 'title', {str})) or 'season' note = traverse_obj(season, ('metadata', 'title', {str})) or 'season'
@ -226,7 +230,7 @@ class SonyLIVSeriesIE(InfoExtractor):
'from': str(cursor), 'from': str(cursor),
'to': str(cursor + 99), 'to': str(cursor + 99),
'orderBy': 'episodeNumber', 'orderBy': 'episodeNumber',
'sortOrder': 'asc', 'sortOrder': sort_order,
}), ('resultObj', 'containers', 0, 'containers', lambda _, v: int_or_none(v['id']))) }), ('resultObj', 'containers', 0, 'containers', lambda _, v: int_or_none(v['id'])))
if not episodes: if not episodes:
break break
@ -237,4 +241,10 @@ class SonyLIVSeriesIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
show_id = self._match_id(url) show_id = self._match_id(url)
return self.playlist_result(self._entries(show_id), playlist_id=show_id)
sort_order = self._configuration_arg('sort_order', [self._SORT_ORDERS[0]])[0]
if sort_order not in self._SORT_ORDERS:
raise ValueError(
f'Invalid sort order "{sort_order}". Allowed values are: {", ".join(self._SORT_ORDERS)}')
return self.playlist_result(self._entries(show_id, sort_order), playlist_id=show_id)