3 from .common
import InfoExtractor
12 class WimTVIE(InfoExtractor
):
14 _UUID_RE
= r
'[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}'
16 https?://platform.wim.tv/
21 (?P<type>vod|live|cast)[=/]
22 (?P<id>%s).*?)''' % _UUID_RE
25 'url': 'https://platform.wim.tv/embed/?vod=db29fb32-bade-47b6-a3a6-cb69fe80267a',
26 'md5': 'db29fb32-bade-47b6-a3a6-cb69fe80267a',
28 'id': 'db29fb32-bade-47b6-a3a6-cb69fe80267a',
30 'title': 'AMA SUPERCROSS 2020 - R2 ST. LOUIS',
32 'thumbnail': r
're:https?://.+?/thumbnail/.+?/720$'
35 'skip_download': True,
39 'url': 'https://platform.wim.tv/embed/?live=28e22c22-49db-40f3-8c37-8cbb0ff44556&autostart=true',
41 'id': '28e22c22-49db-40f3-8c37-8cbb0ff44556',
43 'title': 'Streaming MSmotorTV',
47 'skip_download': True,
50 'url': 'https://platform.wim.tv/#/webtv/automotornews/vod/422492b6-539e-474d-9c6b-68c9d5893365',
51 'only_matching': True,
53 'url': 'https://platform.wim.tv/#/webtv/renzoarborechannel/cast/f47e0d15-5b45-455e-bf0d-dba8ffa96365',
54 'only_matching': True,
58 def _extract_urls(webpage
):
61 for mobj
in re
.finditer(
62 r
'<iframe[^>]+src=["\'](?P
<url
>%s)' % WimTVIE._VALID_URL,
65 def _real_initialize(self):
67 self._get_player_data()
69 def _get_player_data(self):
70 msg_id = 'Player data
'
74 'url
': 'https
://platform
.wim
.tv
/common
/libs
/player
/wimtv
/wim
-rest
.js
',
76 'regex
': r'appAuth
= "(.+?)"',
77 'variable
': 'app_auth
',
80 'url
': 'https
://platform
.wim
.tv
/common
/config
/endpointconfig
.js
',
82 'regex
': r'PRODUCTION_HOSTNAME_THUMB
= "(.+?)"',
83 'variable
': 'thumb_server
',
85 'regex
': r'PRODUCTION_HOSTNAME_THUMB\s
*\
+\s
*"(.+?)"',
86 'variable
': 'thumb_server_path
',
91 temp = self._download_webpage(data['url
'], msg_id)
92 for var in data['vars']:
93 val = self._search_regex(var['regex
'], temp, msg_id)
95 raise ExtractorError('%s not found
' % var['variable
'])
96 self._player[var['variable
']] = val
98 def _generate_token(self):
99 json = self._download_json(
100 'https
://platform
.wim
.tv
/wimtv
-server
/oauth
/token
', 'Token generation
',
101 headers={'Authorization': 'Basic %s' % self._player['app_auth']},
102 data=urlencode_postdata({'grant_type': 'client_credentials'}))
103 token = json.get('access_token
')
105 raise ExtractorError('access token
not generated
')
108 def _generate_thumbnail(self, thumb_id, width='720'):
109 if not thumb_id or not self._player.get('thumb_server
'):
111 if not self._player.get('thumb_server_path
'):
112 self._player['thumb_server_path
'] = ''
113 return '%s%s/asset
/thumbnail
/%s/%s' % (
114 self._player['thumb_server
'],
115 self._player['thumb_server_path
'],
118 def _real_extract(self, url):
119 urlc = self._match_valid_url(url).groupdict()
120 video_id = urlc['id']
121 stream_type = is_live = None
122 if urlc['type'] in {'live', 'cast'}:
123 stream_type = urlc['type'] + '/channel
'
128 token = self._generate_token()
129 json = self._download_json(
130 'https
://platform
.wim
.tv
/wimtv
-server
/api
/public
/%s/%s/play
' % (
131 stream_type, video_id), video_id,
132 headers={'Authorization
': 'Bearer
%s' % token,
133 'Content
-Type
': 'application
/json
'},
134 data=bytes('{}', 'utf
-8'))
137 for src in json.get('srcs
') or []:
138 if src.get('mimeType
') == 'application
/x
-mpegurl
':
140 self._extract_m3u8_formats(
141 src.get('uniqueStreamer
'), video_id, 'mp4
'))
142 if src.get('mimeType
') == 'video
/flash
':
145 'url
': src.get('uniqueStreamer
'),
146 'ext
': determine_ext(src.get('uniqueStreamer
'), 'flv
'),
147 'rtmp_live
': is_live,
149 json = json.get('resource
')
150 thumb = self._generate_thumbnail(json.get('thumbnailId
'))
151 self._sort_formats(formats)
155 'title
': json.get('title
') or json.get('name
'),
156 'duration
': parse_duration(json.get('duration
')),