]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/laola1tv.py
4 from .common
import InfoExtractor
16 class Laola1TvEmbedIE(InfoExtractor
):
17 IE_NAME
= 'laola1tv:embed'
18 _VALID_URL
= r
'https?://(?:www\.)?laola1\.tv/titanplayer\.php\?.*?\bvideoid=(?P<id>\d+)'
20 # flashvars.premium = "false";
21 'url': 'https://www.laola1.tv/titanplayer.php?videoid=708065&type=V&lang=en&portal=int&customer=1024',
25 'title': 'MA Long CHN - FAN Zhendong CHN',
26 'uploader': 'ITTF - International Table Tennis Federation',
27 'upload_date': '20161211',
31 def _extract_token_url(self
, stream_access_url
, video_id
, data
):
32 return self
._download
_json
(
33 self
._proto
_relative
_url
(stream_access_url
, 'https:'), video_id
,
35 'Content-Type': 'application/json',
36 }, data
=json
.dumps(data
).encode())['data']['stream-access'][0]
38 def _extract_formats(self
, token_url
, video_id
):
39 token_doc
= self
._download
_xml
(
40 token_url
, video_id
, 'Downloading token',
41 headers
=self
.geo_verification_headers())
43 token_attrib
= xpath_element(token_doc
, './/token').attrib
45 if token_attrib
['status'] != '0':
47 'Token error: %s' % token_attrib
['comment'], expected
=True)
49 formats
= self
._extract
_akamai
_formats
(
50 '%s?hdnea=%s' % (token_attrib
['url'], token_attrib
['auth']),
54 def _real_extract(self
, url
):
55 video_id
= self
._match
_id
(url
)
56 webpage
= self
._download
_webpage
(url
, video_id
)
57 flash_vars
= self
._search
_regex
(
58 r
'(?s)flashvars\s*=\s*({.+?});', webpage
, 'flash vars')
60 def get_flashvar(x
, *args
, **kwargs
):
61 flash_var
= self
._search
_regex
(
62 r
'%s\s*:\s*"([^"]+)"' % x
,
63 flash_vars
, x
, default
=None)
65 flash_var
= self
._search
_regex
([
66 r
'flashvars\.%s\s*=\s*"([^"]+)"' % x
,
67 r
'%s\s*=\s*"([^"]+)"' % x
],
68 webpage
, x
, *args
, **kwargs
)
71 hd_doc
= self
._download
_xml
(
72 'http://www.laola1.tv/server/hd_video.php', video_id
, query
={
73 'play': get_flashvar('streamid'),
74 'partner': get_flashvar('partnerid'),
75 'portal': get_flashvar('portalid'),
76 'lang': get_flashvar('sprache'),
80 _v
= lambda x
, **k
: xpath_text(hd_doc
, './/video/' + x
, **k
)
81 title
= _v('title', fatal
=True)
84 premium
= get_flashvar('premium', default
=None)
86 token_url
= update_url_query(
87 _v('url', fatal
=True), {
88 'timestamp': get_flashvar('timestamp'),
89 'auth': get_flashvar('auth'),
92 data_abo
= urlencode_postdata(
93 dict((i
, v
) for i
, v
in enumerate(_v('req_liga_abos').split(','))))
94 stream_access_url
= update_url_query(
95 'https://club.laola1.tv/sp/laola1/api/v3/user/session/premium/player/stream-access', {
97 'target': self
._search
_regex
(r
'vs_target = (\d+);', webpage
, 'vs target'),
101 token_url
= self
._extract
_token
_url
(stream_access_url
, video_id
, data_abo
)
103 formats
= self
._extract
_formats
(token_url
, video_id
)
105 categories_str
= _v('meta_sports')
106 categories
= categories_str
.split(',') if categories_str
else []
107 is_live
= _v('islive') == 'true'
112 'upload_date': unified_strdate(_v('time_date')),
113 'uploader': _v('meta_organisation'),
114 'categories': categories
,
120 class Laola1TvBaseIE(Laola1TvEmbedIE
): # XXX: Do not subclass from concrete IE
121 def _extract_video(self
, url
):
122 display_id
= self
._match
_id
(url
)
123 webpage
= self
._download
_webpage
(url
, display_id
)
125 if 'Dieser Livestream ist bereits beendet.' in webpage
:
126 raise ExtractorError('This live stream has already finished.', expected
=True)
128 conf
= self
._parse
_json
(self
._search
_regex
(
129 r
'(?s)conf\s*=\s*({.+?});', webpage
, 'conf'),
131 transform_source
=lambda s
: js_to_json(re
.sub(r
'shareurl:.+,', '', s
)))
132 video_id
= conf
['videoid']
134 config
= self
._download
_json
(conf
['configUrl'], video_id
, query
={
136 'partnerid': conf
['partnerid'],
137 'language': conf
.get('language', ''),
138 'portal': conf
.get('portalid', ''),
140 error
= config
.get('error')
142 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, error
), expected
=True)
144 video_data
= config
['video']
145 title
= video_data
['title']
146 is_live
= video_data
.get('isLivestream') and video_data
.get('isLive')
147 meta
= video_data
.get('metaInformation')
148 sports
= meta
.get('sports')
149 categories
= sports
.split(',') if sports
else []
151 token_url
= self
._extract
_token
_url
(
152 video_data
['streamAccess'], video_id
,
153 video_data
['abo']['required'])
155 formats
= self
._extract
_formats
(token_url
, video_id
)
159 'display_id': display_id
,
161 'description': video_data
.get('description'),
162 'thumbnail': video_data
.get('image'),
163 'categories': categories
,
169 class Laola1TvIE(Laola1TvBaseIE
):
171 _VALID_URL
= r
'https?://(?:www\.)?laola1\.tv/[a-z]+-[a-z]+/[^/]+/(?P<id>[^/?#&]+)'
174 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html',
177 'display_id': 'straubing-tigers-koelner-haie',
179 'title': 'Straubing Tigers - Kölner Haie',
180 'upload_date': '20140912',
182 'categories': ['Eishockey'],
185 'skip_download': True,
188 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie',
191 'display_id': 'straubing-tigers-koelner-haie',
193 'title': 'Straubing Tigers - Kölner Haie',
194 'upload_date': '20160129',
196 'categories': ['Eishockey'],
199 'skip_download': True,
202 'url': 'http://www.laola1.tv/de-de/livestream/2016-03-22-belogorie-belgorod-trentino-diatec-lde',
205 'display_id': '2016-03-22-belogorie-belgorod-trentino-diatec-lde',
207 'title': 'Belogorie BELGOROD - TRENTINO Diatec',
208 'upload_date': '20160322',
209 'uploader': 'CEV - Europäischer Volleyball Verband',
211 'categories': ['Volleyball'],
214 'skip_download': True,
216 'skip': 'This live stream has already finished.',
219 def _real_extract(self
, url
):
220 return self
._extract
_video
(url
)
223 class EHFTVIE(Laola1TvBaseIE
):
225 _VALID_URL
= r
'https?://(?:www\.)?ehftv\.com/[a-z]+(?:-[a-z]+)?/[^/]+/(?P<id>[^/?#&]+)'
228 'url': 'https://www.ehftv.com/int/video/paris-saint-germain-handball-pge-vive-kielce/1166761',
231 'display_id': 'paris-saint-germain-handball-pge-vive-kielce',
233 'title': 'Paris Saint-Germain Handball - PGE Vive Kielce',
235 'categories': ['Handball'],
238 'skip_download': True,
242 def _real_extract(self
, url
):
243 return self
._extract
_video
(url
)
246 class ITTFIE(InfoExtractor
):
247 _VALID_URL
= r
'https?://tv\.ittf\.com/video/[^/]+/(?P<id>\d+)'
249 'url': 'https://tv.ittf.com/video/peng-wang-wei-matsudaira-kenta/951802',
250 'only_matching': True,
253 def _real_extract(self
, url
):
254 return self
.url_result(
255 update_url_query('https://www.laola1.tv/titanplayer.php', {
256 'videoid': self
._match
_id
(url
),
261 }), Laola1TvEmbedIE
.ie_key())