]>
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']),
52 self
._sort
_formats
(formats
)
55 def _real_extract(self
, url
):
56 video_id
= self
._match
_id
(url
)
57 webpage
= self
._download
_webpage
(url
, video_id
)
58 flash_vars
= self
._search
_regex
(
59 r
'(?s)flashvars\s*=\s*({.+?});', webpage
, 'flash vars')
61 def get_flashvar(x
, *args
, **kwargs
):
62 flash_var
= self
._search
_regex
(
63 r
'%s\s*:\s*"([^"]+)"' % x
,
64 flash_vars
, x
, default
=None)
66 flash_var
= self
._search
_regex
([
67 r
'flashvars\.%s\s*=\s*"([^"]+)"' % x
,
68 r
'%s\s*=\s*"([^"]+)"' % x
],
69 webpage
, x
, *args
, **kwargs
)
72 hd_doc
= self
._download
_xml
(
73 'http://www.laola1.tv/server/hd_video.php', video_id
, query
={
74 'play': get_flashvar('streamid'),
75 'partner': get_flashvar('partnerid'),
76 'portal': get_flashvar('portalid'),
77 'lang': get_flashvar('sprache'),
81 _v
= lambda x
, **k
: xpath_text(hd_doc
, './/video/' + x
, **k
)
82 title
= _v('title', fatal
=True)
85 premium
= get_flashvar('premium', default
=None)
87 token_url
= update_url_query(
88 _v('url', fatal
=True), {
89 'timestamp': get_flashvar('timestamp'),
90 'auth': get_flashvar('auth'),
93 data_abo
= urlencode_postdata(
94 dict((i
, v
) for i
, v
in enumerate(_v('req_liga_abos').split(','))))
95 stream_access_url
= update_url_query(
96 'https://club.laola1.tv/sp/laola1/api/v3/user/session/premium/player/stream-access', {
98 'target': self
._search
_regex
(r
'vs_target = (\d+);', webpage
, 'vs target'),
102 token_url
= self
._extract
_token
_url
(stream_access_url
, video_id
, data_abo
)
104 formats
= self
._extract
_formats
(token_url
, video_id
)
106 categories_str
= _v('meta_sports')
107 categories
= categories_str
.split(',') if categories_str
else []
108 is_live
= _v('islive') == 'true'
113 'upload_date': unified_strdate(_v('time_date')),
114 'uploader': _v('meta_organisation'),
115 'categories': categories
,
121 class Laola1TvBaseIE(Laola1TvEmbedIE
):
122 def _extract_video(self
, url
):
123 display_id
= self
._match
_id
(url
)
124 webpage
= self
._download
_webpage
(url
, display_id
)
126 if 'Dieser Livestream ist bereits beendet.' in webpage
:
127 raise ExtractorError('This live stream has already finished.', expected
=True)
129 conf
= self
._parse
_json
(self
._search
_regex
(
130 r
'(?s)conf\s*=\s*({.+?});', webpage
, 'conf'),
132 transform_source
=lambda s
: js_to_json(re
.sub(r
'shareurl:.+,', '', s
)))
133 video_id
= conf
['videoid']
135 config
= self
._download
_json
(conf
['configUrl'], video_id
, query
={
137 'partnerid': conf
['partnerid'],
138 'language': conf
.get('language', ''),
139 'portal': conf
.get('portalid', ''),
141 error
= config
.get('error')
143 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, error
), expected
=True)
145 video_data
= config
['video']
146 title
= video_data
['title']
147 is_live
= video_data
.get('isLivestream') and video_data
.get('isLive')
148 meta
= video_data
.get('metaInformation')
149 sports
= meta
.get('sports')
150 categories
= sports
.split(',') if sports
else []
152 token_url
= self
._extract
_token
_url
(
153 video_data
['streamAccess'], video_id
,
154 video_data
['abo']['required'])
156 formats
= self
._extract
_formats
(token_url
, video_id
)
160 'display_id': display_id
,
162 'description': video_data
.get('description'),
163 'thumbnail': video_data
.get('image'),
164 'categories': categories
,
170 class Laola1TvIE(Laola1TvBaseIE
):
172 _VALID_URL
= r
'https?://(?:www\.)?laola1\.tv/[a-z]+-[a-z]+/[^/]+/(?P<id>[^/?#&]+)'
175 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html',
178 'display_id': 'straubing-tigers-koelner-haie',
180 'title': 'Straubing Tigers - Kölner Haie',
181 'upload_date': '20140912',
183 'categories': ['Eishockey'],
186 'skip_download': True,
189 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie',
192 'display_id': 'straubing-tigers-koelner-haie',
194 'title': 'Straubing Tigers - Kölner Haie',
195 'upload_date': '20160129',
197 'categories': ['Eishockey'],
200 'skip_download': True,
203 'url': 'http://www.laola1.tv/de-de/livestream/2016-03-22-belogorie-belgorod-trentino-diatec-lde',
206 'display_id': '2016-03-22-belogorie-belgorod-trentino-diatec-lde',
208 'title': 'Belogorie BELGOROD - TRENTINO Diatec',
209 'upload_date': '20160322',
210 'uploader': 'CEV - Europäischer Volleyball Verband',
212 'categories': ['Volleyball'],
215 'skip_download': True,
217 'skip': 'This live stream has already finished.',
220 def _real_extract(self
, url
):
221 return self
._extract
_video
(url
)
224 class EHFTVIE(Laola1TvBaseIE
):
226 _VALID_URL
= r
'https?://(?:www\.)?ehftv\.com/[a-z]+(?:-[a-z]+)?/[^/]+/(?P<id>[^/?#&]+)'
229 'url': 'https://www.ehftv.com/int/video/paris-saint-germain-handball-pge-vive-kielce/1166761',
232 'display_id': 'paris-saint-germain-handball-pge-vive-kielce',
234 'title': 'Paris Saint-Germain Handball - PGE Vive Kielce',
236 'categories': ['Handball'],
239 'skip_download': True,
243 def _real_extract(self
, url
):
244 return self
._extract
_video
(url
)
247 class ITTFIE(InfoExtractor
):
248 _VALID_URL
= r
'https?://tv\.ittf\.com/video/[^/]+/(?P<id>\d+)'
250 'url': 'https://tv.ittf.com/video/peng-wang-wei-matsudaira-kenta/951802',
251 'only_matching': True,
254 def _real_extract(self
, url
):
255 return self
.url_result(
256 update_url_query('https://www.laola1.tv/titanplayer.php', {
257 'videoid': self
._match
_id
(url
),
262 }), Laola1TvEmbedIE
.ie_key())