Browse Source

[itv] fixed extraction (closes ytdl-org#28906)

https://github.com/ytdl-org/youtube-dl/pull/28955 (@sleaux-meaux)
ITV changes require media stream and subtitles to be taken
from different playlist resources. Incorporates suggestion in
ytdl-org#28906 (comment)
Hummy
df 8 months ago
parent
commit
0345a064a7
  1. 58
      youtube_dl/extractor/itv.py

58
youtube_dl/extractor/itv.py

@ -15,6 +15,7 @@ from ..utils import (
merge_dicts,
parse_duration,
smuggle_url,
try_get,
url_or_none,
)
@ -23,15 +24,20 @@ class ITVIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?itv\.com/hub/[^/]+/(?P<id>[0-9a-zA-Z]+)'
_GEO_COUNTRIES = ['GB']
_TESTS = [{
'url': 'https://www.itv.com/hub/liar/2a4547a0012',
'url': 'https://www.itv.com/hub/the-durrells/2a4156a0001',
'info_dict': {
'id': '2a4547a0012',
'id': '2a4156a0001',
'ext': 'mp4',
'title': 'Liar - Series 2 - Episode 6',
'description': 'md5:d0f91536569dec79ea184f0a44cca089',
'series': 'Liar',
'season_number': 2,
'episode_number': 6,
'title': 'The Durrells - Series 1 - Episode 1',
'description': 'md5:43ae58e27aa91720fc933a68a37e9e95',
'series': 'The Durrells',
'season_number': 1,
'episode_number': 1,
'subtitles': {
'en': [
{'url': 'https://itvpnpsubtitles.content.itv.com/2-4156-0001-003/Subtitles/3/WebVTT-OUT-OF-BAND/2-4156-0001-003_Series1590486890_TX000000.vtt'}
]
},
},
'params': {
# m3u8 download
@ -87,13 +93,13 @@ class ITVIE(InfoExtractor):
},
'variantAvailability': {
'featureset': {
'min': ['hls', 'aes', 'outband-webvtt'],
'max': ['hls', 'aes', 'outband-webvtt']
'min': ['hls', 'aes'],
'max': ['hls', 'aes']
},
'platformTag': 'dotcom'
'platformTag': 'mobile'
}
}).encode(), headers=headers)
video_data = ios_playlist['Playlist']['Video']
video_data = try_get(ios_playlist, lambda x: x['Playlist']['Video'], dict) or {}
ios_base_url = video_data.get('Base')
formats = []
@ -114,8 +120,36 @@ class ITVIE(InfoExtractor):
})
self._sort_formats(formats)
subs_playlist = self._download_json(
ios_playlist_url, video_id, data=json.dumps({
'user': {
'itvUserId': '',
'entitlements': [],
'token': ''
},
'device': {
'manufacturer': 'Safari',
'model': '5',
'os': {
'name': 'Windows NT',
'version': '6.1',
'type': 'desktop'
}
},
'client': {
'version': '4.1',
'id': 'browser'
},
'variantAvailability': {
'featureset': {
'min': ['mpeg-dash', 'widevine', 'outband-webvtt'],
'max': ['mpeg-dash', 'widevine', 'outband-webvtt']
},
'platformTag': 'mobile'
}
}).encode(), headers=headers)
subs = try_get(subs_playlist, lambda x: x['Playlist']['Video']['Subtitles'], list) or []
subtitles = {}
subs = video_data.get('Subtitles') or []
for sub in subs:
if not isinstance(sub, dict):
continue

Loading…
Cancel
Save