]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/laola1tv.py
2 from __future__
import unicode_literals
7 from .common
import InfoExtractor
19 class Laola1TvEmbedIE(InfoExtractor
):
20 IE_NAME
= 'laola1tv:embed'
21 _VALID_URL
= r
'https?://(?:www\.)?laola1\.tv/titanplayer\.php\?.*?\bvideoid=(?P<id>\d+)'
23 # flashvars.premium = "false";
24 'url': 'https://www.laola1.tv/titanplayer.php?videoid=708065&type=V&lang=en&portal=int&customer=1024',
28 'title': 'MA Long CHN - FAN Zhendong CHN',
29 'uploader': 'ITTF - International Table Tennis Federation',
30 'upload_date': '20161211',
34 def _extract_token_url(self
, stream_access_url
, video_id
, data
):
35 return self
._download
_json
(
36 self
._proto
_relative
_url
(stream_access_url
, 'https:'), video_id
,
38 'Content-Type': 'application/json',
39 }, data
=json
.dumps(data
).encode())['data']['stream-access'][0]
41 def _extract_formats(self
, token_url
, video_id
):
42 token_doc
= self
._download
_xml
(
43 token_url
, video_id
, 'Downloading token',
44 headers
=self
.geo_verification_headers())
46 token_attrib
= xpath_element(token_doc
, './/token').attrib
48 if token_attrib
['status'] != '0':
50 'Token error: %s' % token_attrib
['comment'], expected
=True)
52 formats
= self
._extract
_akamai
_formats
(
53 '%s?hdnea=%s' % (token_attrib
['url'], token_attrib
['auth']),
55 self
._sort
_formats
(formats
)
58 def _real_extract(self
, url
):
59 video_id
= self
._match
_id
(url
)
60 webpage
= self
._download
_webpage
(url
, video_id
)
61 flash_vars
= self
._search
_regex
(
62 r
'(?s)flashvars\s*=\s*({.+?});', webpage
, 'flash vars')
64 def get_flashvar(x
, *args
, **kwargs
):
65 flash_var
= self
._search
_regex
(
66 r
'%s\s*:\s*"([^"]+)"' % x
,
67 flash_vars
, x
, default
=None)
69 flash_var
= self
._search
_regex
([
70 r
'flashvars\.%s\s*=\s*"([^"]+)"' % x
,
71 r
'%s\s*=\s*"([^"]+)"' % x
],
72 webpage
, x
, *args
, **kwargs
)
75 hd_doc
= self
._download
_xml
(
76 'http://www.laola1.tv/server/hd_video.php', video_id
, query
={
77 'play': get_flashvar('streamid'),
78 'partner': get_flashvar('partnerid'),
79 'portal': get_flashvar('portalid'),
80 'lang': get_flashvar('sprache'),
84 _v
= lambda x
, **k
: xpath_text(hd_doc
, './/video/' + x
, **k
)
85 title
= _v('title', fatal
=True)
88 premium
= get_flashvar('premium', default
=None)
90 token_url
= update_url_query(
91 _v('url', fatal
=True), {
92 'timestamp': get_flashvar('timestamp'),
93 'auth': get_flashvar('auth'),
96 data_abo
= urlencode_postdata(
97 dict((i
, v
) for i
, v
in enumerate(_v('req_liga_abos').split(','))))
98 stream_access_url
= update_url_query(
99 'https://club.laola1.tv/sp/laola1/api/v3/user/session/premium/player/stream-access', {
101 'target': self
._search
_regex
(r
'vs_target = (\d+);', webpage
, 'vs target'),
102 'label': _v('label'),
105 token_url
= self
._extract
_token
_url
(stream_access_url
, video_id
, data_abo
)
107 formats
= self
._extract
_formats
(token_url
, video_id
)
109 categories_str
= _v('meta_sports')
110 categories
= categories_str
.split(',') if categories_str
else []
111 is_live
= _v('islive') == 'true'
115 'title': self
._live
_title
(title
) if is_live
else title
,
116 'upload_date': unified_strdate(_v('time_date')),
117 'uploader': _v('meta_organisation'),
118 'categories': categories
,
124 class Laola1TvBaseIE(Laola1TvEmbedIE
):
125 def _extract_video(self
, url
):
126 display_id
= self
._match
_id
(url
)
127 webpage
= self
._download
_webpage
(url
, display_id
)
129 if 'Dieser Livestream ist bereits beendet.' in webpage
:
130 raise ExtractorError('This live stream has already finished.', expected
=True)
132 conf
= self
._parse
_json
(self
._search
_regex
(
133 r
'(?s)conf\s*=\s*({.+?});', webpage
, 'conf'),
135 transform_source
=lambda s
: js_to_json(re
.sub(r
'shareurl:.+,', '', s
)))
136 video_id
= conf
['videoid']
138 config
= self
._download
_json
(conf
['configUrl'], video_id
, query
={
140 'partnerid': conf
['partnerid'],
141 'language': conf
.get('language', ''),
142 'portal': conf
.get('portalid', ''),
144 error
= config
.get('error')
146 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, error
), expected
=True)
148 video_data
= config
['video']
149 title
= video_data
['title']
150 is_live
= video_data
.get('isLivestream') and video_data
.get('isLive')
151 meta
= video_data
.get('metaInformation')
152 sports
= meta
.get('sports')
153 categories
= sports
.split(',') if sports
else []
155 token_url
= self
._extract
_token
_url
(
156 video_data
['streamAccess'], video_id
,
157 video_data
['abo']['required'])
159 formats
= self
._extract
_formats
(token_url
, video_id
)
163 'display_id': display_id
,
164 'title': self
._live
_title
(title
) if is_live
else title
,
165 'description': video_data
.get('description'),
166 'thumbnail': video_data
.get('image'),
167 'categories': categories
,
173 class Laola1TvIE(Laola1TvBaseIE
):
175 _VALID_URL
= r
'https?://(?:www\.)?laola1\.tv/[a-z]+-[a-z]+/[^/]+/(?P<id>[^/?#&]+)'
178 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html',
181 'display_id': 'straubing-tigers-koelner-haie',
183 'title': 'Straubing Tigers - Kölner Haie',
184 'upload_date': '20140912',
186 'categories': ['Eishockey'],
189 'skip_download': True,
192 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie',
195 'display_id': 'straubing-tigers-koelner-haie',
197 'title': 'Straubing Tigers - Kölner Haie',
198 'upload_date': '20160129',
200 'categories': ['Eishockey'],
203 'skip_download': True,
206 'url': 'http://www.laola1.tv/de-de/livestream/2016-03-22-belogorie-belgorod-trentino-diatec-lde',
209 'display_id': '2016-03-22-belogorie-belgorod-trentino-diatec-lde',
211 'title': 'Belogorie BELGOROD - TRENTINO Diatec',
212 'upload_date': '20160322',
213 'uploader': 'CEV - Europäischer Volleyball Verband',
215 'categories': ['Volleyball'],
218 'skip_download': True,
220 'skip': 'This live stream has already finished.',
223 def _real_extract(self
, url
):
224 return self
._extract
_video
(url
)
227 class EHFTVIE(Laola1TvBaseIE
):
229 _VALID_URL
= r
'https?://(?:www\.)?ehftv\.com/[a-z]+(?:-[a-z]+)?/[^/]+/(?P<id>[^/?#&]+)'
232 'url': 'https://www.ehftv.com/int/video/paris-saint-germain-handball-pge-vive-kielce/1166761',
235 'display_id': 'paris-saint-germain-handball-pge-vive-kielce',
237 'title': 'Paris Saint-Germain Handball - PGE Vive Kielce',
239 'categories': ['Handball'],
242 'skip_download': True,
246 def _real_extract(self
, url
):
247 return self
._extract
_video
(url
)
250 class ITTFIE(InfoExtractor
):
251 _VALID_URL
= r
'https?://tv\.ittf\.com/video/[^/]+/(?P<id>\d+)'
253 'url': 'https://tv.ittf.com/video/peng-wang-wei-matsudaira-kenta/951802',
254 'only_matching': True,
257 def _real_extract(self
, url
):
258 return self
.url_result(
259 update_url_query('https://www.laola1.tv/titanplayer.php', {
260 'videoid': self
._match
_id
(url
),
265 }), Laola1TvEmbedIE
.ie_key())