[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / premiershiprugby.py
blob313b4d2174fcdfa13ee8ad0852d76a4aac28ee39
1 from .common import InfoExtractor
2 from ..utils import int_or_none, traverse_obj
5 class PremiershipRugbyIE(InfoExtractor):
6 _VALID_URL = r'https?://(?:\w+\.)premiershiprugby\.(?:com)/watch/(?P<id>[\w-]+)'
7 _TESTS = [{
8 'url': 'https://www.premiershiprugby.com/watch/full-match-harlequins-v-newcastle-falcons',
9 'info_dict': {
10 'id': '0_mbkb7ldt',
11 'title': 'Full Match: Harlequins v Newcastle Falcons',
12 'ext': 'mp4',
13 'thumbnail': 'https://open.http.mp.streamamg.com/p/3000914/sp/300091400/thumbnail/entry_id/0_mbkb7ldt//width/960/height/540/type/1/quality/75',
14 'duration': 6093.0,
15 'tags': ['video'],
16 'categories': ['Full Match', 'Harlequins', 'Newcastle Falcons', 'gallaher premiership'],
20 def _real_extract(self, url):
21 display_id = self._match_id(url)
22 json_data = self._download_json(
23 f'https://article-cms-api.incrowdsports.com/v2/articles/slug/{display_id}',
24 display_id, query={'clientId': 'PRL'})['data']['article']
26 formats, subs = self._extract_m3u8_formats_and_subtitles(
27 json_data['heroMedia']['content']['videoLink'], display_id)
29 return {
30 'id': json_data['heroMedia']['content']['sourceSystemId'],
31 'display_id': display_id,
32 'title': traverse_obj(json_data, ('heroMedia', 'title')),
33 'formats': formats,
34 'subtitles': subs,
35 'thumbnail': traverse_obj(json_data, ('heroMedia', 'content', 'videoThumbnail')),
36 'duration': int_or_none(traverse_obj(json_data, ('heroMedia', 'content', 'metadata', 'msDuration')), scale=1000),
37 'tags': json_data.get('tags'),
38 'categories': traverse_obj(json_data, ('categories', ..., 'text')),