4 from .common
import InfoExtractor
11 from ..utils
.traversal
import traverse_obj
14 class VidflexIE(InfoExtractor
):
16 r
'[^.]+\.vidflex\.tv',
17 r
'(?:www\.)?acactv\.ca',
18 r
'(?:www\.)?albertalacrossetv\.com',
19 r
'(?:www\.)?cjfltv\.com',
20 r
'(?:www\.)?figureitoutbaseball\.com',
21 r
'(?:www\.)?ocaalive\.com',
22 r
'(?:www\.)?pegasussports\.tv',
23 r
'(?:www\.)?praxisseries\.ca',
24 r
'(?:www\.)?silenticetv\.com',
25 r
'(?:www\.)?tuffhedemantv\.com',
26 r
'(?:www\.)?watchfuntv\.com',
27 r
'live\.ofsaa\.on\.ca',
29 r
'tv\.realcastmedia\.net',
30 r
'tv\.fringetheatre\.ca',
32 r
'video\.hockeycanada\.ca',
33 r
'video\.huuayaht\.org',
34 r
'video\.turningpointensemble\.ca',
35 r
'videos\.livingworks\.net',
36 r
'videos\.telusworldofscienceedmonton\.ca',
37 r
'watch\.binghamtonbulldogs\.com',
38 r
'watch\.rekindle\.tv',
41 _VALID_URL
= rf
'https?://(?:{"|".join(_DOMAINS_RE)})/[a-z]{{2}}(?:-[a-z]{{2}})?/c/[\w-]+\.(?P<id>\d+)'
43 'url': 'https://video.hockeycanada.ca/en/c/nwt-micd-up-with-jamie-lee-rattray.107486',
44 'only_matching': True,
47 'url': 'https://video.hockeycanada.ca/en-us/c/nwt-micd-up-with-jamie-lee-rattray.107486',
50 'title': 'NWT: Mic’d up with Jamie Lee Rattray',
53 'timestamp': 1634310409,
54 'upload_date': '20211015',
55 'tags': ['English', '2021', "National Women's Team"],
56 'description': 'md5:efb1cf6165b48cc3f5555c4262dd5b23',
57 'thumbnail': r
're:^https?://wpmedia01-a\.akamaihd\.net/en/asset/public/image/.+',
59 'params': {'skip_download': True},
61 'url': 'https://video.hockeycanada.ca/en/c/mwc-remembering-the-wild-ride-in-riga.112307',
64 'title': 'MWC: Remembering the wild ride in Riga',
67 'timestamp': 1716235607,
68 'upload_date': '20240520',
69 'tags': ['English', '2024', "National Men's Team", 'IIHF World Championship', 'Fan'],
70 'description': r
're:.+Canada’s National Men’s Team.+',
71 'thumbnail': r
're:^https?://wpmedia01-a\.akamaihd\.net/en/asset/public/image/.+',
73 'params': {'skip_download': True},
75 # the same video in French
76 'url': 'https://video.hockeycanada.ca/fr/c/cmm-retour-sur-un-parcours-endiable-a-riga.112304',
79 'title': 'CMM : Retour sur un parcours endiablé à Riga',
82 'timestamp': 1716235545,
83 'upload_date': '20240520',
84 'tags': ['French', '2024', "National Men's Team", 'IIHF World Championship', 'Fan'],
85 'description': 'md5:cf825222882a3dab1cd62cffcf3b4d1f',
86 'thumbnail': r
're:^https?://wpmedia01-a\.akamaihd\.net/en/asset/public/image/.+',
88 'params': {'skip_download': True},
90 'url': 'https://myfbcgreenville.vidflex.tv/en/c/may-12th-2024.658',
91 'only_matching': True,
93 'url': 'https://www.figureitoutbaseball.com/en/c/fiob-podcast-14-dan-bertolini-ncaa-d1-head-coach-recorded-11-29-2018.1367',
94 'only_matching': True,
96 'url': 'https://videos.telusworldofscienceedmonton.ca/en/c/the-aurora-project-timelapse-4.577',
97 'only_matching': True,
99 'url': 'https://www.tuffhedemantv.com/en/c/2022-tuff-hedeman-tour-hobbs-nm-january-22.227',
100 'only_matching': True,
102 'url': 'https://www.albertalacrossetv.com/en/c/up-floor-ground-balls-one-more.3449',
103 'only_matching': True,
105 'url': 'https://www.silenticetv.com/en/c/jp-unlocked-day-in-the-life-of-langley-ha-15u.5197',
106 'only_matching': True,
108 'url': 'https://jphl.vidflex.tv/en/c/jp-unlocked-day-in-the-life-of-langley-ha-15u.5197',
109 'only_matching': True,
112 def _real_extract(self
, url
):
113 video_id
= self
._match
_id
(url
)
114 webpage
= self
._download
_webpage
(url
, video_id
)
116 data_url
= self
._html
_search
_regex
(
117 r
'content_api:\s*(["\'])(?P
<url
>https?
://(?
:(?
!\
1).)+)\
1', webpage, 'content api url
', group='url
')
118 media_config = traverse_obj(
119 self._download_json(data_url, video_id),
120 ('config
', {base64.b64decode}, {bytes.decode}, {json.loads}, {dict}))
124 'formats
': list(self._yield_formats(media_config, video_id)),
125 **self._search_json_ld(
126 webpage.replace('/*<![CDATA
[*/', '').replace('/*]]>*/', ''), video_id),
129 def _yield_formats(self, media_config, video_id):
130 for media_source in traverse_obj(media_config, ('media
', 'source
', lambda _, v: url_or_none(v['src
']))):
131 media_url = media_source['src
']
132 media_type = mimetype2ext(media_source.get('type'))
134 if media_type == 'm3u8
':
135 yield from self._extract_m3u8_formats(media_url, video_id, fatal=False, m3u8_id='hls
')
136 elif media_type == 'mp4
':
137 bitrate = self._search_regex(r'_(\d
+)k\
.mp4
', media_url, 'bitrate
', default=None)
139 'format_id
': join_nonempty('http
', bitrate),
142 'tbr
': int_or_none(bitrate),