2 from __future__ import unicode_literals
6 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 stream_access_url, video_id, headers={
37 'Content-Type': 'application/json',
38 }, data=json.dumps(data).encode())['data']['stream-access'][0]
40 def _extract_formats(self, token_url, video_id):
41 token_doc = self._download_xml(
42 token_url, video_id, 'Downloading token',
43 headers=self.geo_verification_headers())
45 token_attrib = xpath_element(token_doc, './/token').attrib
47 if token_attrib['status'] != '0':
49 'Token error: %s' % token_attrib['comment'], expected=True)
51 formats = self._extract_akamai_formats(
52 '%s?hdnea=%s' % (token_attrib['url'], token_attrib['auth']),
54 self._sort_formats(formats)
57 def _real_extract(self, url):
58 video_id = self._match_id(url)
59 webpage = self._download_webpage(url, video_id)
60 flash_vars = self._search_regex(
61 r'(?s)flashvars\s*=\s*({.+?});', webpage, 'flash vars')
63 def get_flashvar(x, *args, **kwargs):
64 flash_var = self._search_regex(
65 r'%s\s*:\s*"([^"]+)"' % x,
66 flash_vars, x, default=None)
68 flash_var = self._search_regex([
69 r'flashvars\.%s\s*=\s*"([^"]+)"' % x,
70 r'%s\s*=\s*"([^"]+)"' % x],
71 webpage, x, *args, **kwargs)
74 hd_doc = self._download_xml(
75 'http://www.laola1.tv/server/hd_video.php', video_id, query={
76 'play': get_flashvar('streamid'),
77 'partner': get_flashvar('partnerid'),
78 'portal': get_flashvar('portalid'),
79 'lang': get_flashvar('sprache'),
83 _v = lambda x, **k: xpath_text(hd_doc, './/video/' + x, **k)
84 title = _v('title', fatal=True)
87 premium = get_flashvar('premium', default=None)
89 token_url = update_url_query(
90 _v('url', fatal=True), {
91 'timestamp': get_flashvar('timestamp'),
92 'auth': get_flashvar('auth'),
95 data_abo = urlencode_postdata(
96 dict((i, v) for i, v in enumerate(_v('req_liga_abos').split(','))))
97 stream_access_url = update_url_query(
98 'https://club.laola1.tv/sp/laola1/api/v3/user/session/premium/player/stream-access', {
100 'target': self._search_regex(r'vs_target = (\d+);', webpage, 'vs target'),
101 'label': _v('label'),
104 token_url = self._extract_token_url(stream_access_url, video_id, data_abo)
106 formats = self._extract_formats(token_url, video_id)
108 categories_str = _v('meta_sports')
109 categories = categories_str.split(',') if categories_str else []
110 is_live = _v('islive') == 'true'
114 'title': self._live_title(title) if is_live else title,
115 'upload_date': unified_strdate(_v('time_date')),
116 'uploader': _v('meta_organisation'),
117 'categories': categories,
123 class Laola1TvIE(Laola1TvEmbedIE):
125 _VALID_URL = r'https?://(?:www\.)?laola1\.tv/[a-z]+-[a-z]+/[^/]+/(?P<id>[^/?#&]+)'
127 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html',
130 'display_id': 'straubing-tigers-koelner-haie',
132 'title': 'Straubing Tigers - Kölner Haie',
133 'upload_date': '20140912',
135 'categories': ['Eishockey'],
138 'skip_download': True,
141 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie',
144 'display_id': 'straubing-tigers-koelner-haie',
146 'title': 'Straubing Tigers - Kölner Haie',
147 'upload_date': '20160129',
149 'categories': ['Eishockey'],
152 'skip_download': True,
155 'url': 'http://www.laola1.tv/de-de/livestream/2016-03-22-belogorie-belgorod-trentino-diatec-lde',
158 'display_id': '2016-03-22-belogorie-belgorod-trentino-diatec-lde',
160 'title': 'Belogorie BELGOROD - TRENTINO Diatec',
161 'upload_date': '20160322',
162 'uploader': 'CEV - Europäischer Volleyball Verband',
164 'categories': ['Volleyball'],
167 'skip_download': True,
169 'skip': 'This live stream has already finished.',
172 def _real_extract(self, url):
173 display_id = self._match_id(url)
175 webpage = self._download_webpage(url, display_id)
177 if 'Dieser Livestream ist bereits beendet.' in webpage:
178 raise ExtractorError('This live stream has already finished.', expected=True)
180 conf = self._parse_json(self._search_regex(
181 r'(?s)conf\s*=\s*({.+?});', webpage, 'conf'),
182 display_id, js_to_json)
184 video_id = conf['videoid']
186 config = self._download_json(conf['configUrl'], video_id, query={
188 'partnerid': conf['partnerid'],
189 'language': conf.get('language', ''),
190 'portal': conf.get('portalid', ''),
192 error = config.get('error')
194 raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
196 video_data = config['video']
197 title = video_data['title']
198 is_live = video_data.get('isLivestream') and video_data.get('isLive')
199 meta = video_data.get('metaInformation')
200 sports = meta.get('sports')
201 categories = sports.split(',') if sports else []
203 token_url = self._extract_token_url(
204 video_data['streamAccess'], video_id,
205 video_data['abo']['required'])
207 formats = self._extract_formats(token_url, video_id)
211 'display_id': display_id,
212 'title': self._live_title(title) if is_live else title,
213 'description': video_data.get('description'),
214 'thumbnail': video_data.get('image'),
215 'categories': categories,