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 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 Laola1TvBaseIE(Laola1TvEmbedIE):
124 def _extract_video(self, url):
125 display_id = self._match_id(url)
126 webpage = self._download_webpage(url, display_id)
128 if 'Dieser Livestream ist bereits beendet.' in webpage:
129 raise ExtractorError('This live stream has already finished.', expected=True)
131 conf = self._parse_json(self._search_regex(
132 r'(?s)conf\s*=\s*({.+?});', webpage, 'conf'),
134 transform_source=lambda s: js_to_json(re.sub(r'shareurl:.+,', '', s)))
135 video_id = conf['videoid']
137 config = self._download_json(conf['configUrl'], video_id, query={
139 'partnerid': conf['partnerid'],
140 'language': conf.get('language', ''),
141 'portal': conf.get('portalid', ''),
143 error = config.get('error')
145 raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
147 video_data = config['video']
148 title = video_data['title']
149 is_live = video_data.get('isLivestream') and video_data.get('isLive')
150 meta = video_data.get('metaInformation')
151 sports = meta.get('sports')
152 categories = sports.split(',') if sports else []
154 token_url = self._extract_token_url(
155 video_data['streamAccess'], video_id,
156 video_data['abo']['required'])
158 formats = self._extract_formats(token_url, video_id)
162 'display_id': display_id,
163 'title': self._live_title(title) if is_live else title,
164 'description': video_data.get('description'),
165 'thumbnail': video_data.get('image'),
166 'categories': categories,
172 class Laola1TvIE(Laola1TvBaseIE):
174 _VALID_URL = r'https?://(?:www\.)?laola1\.tv/[a-z]+-[a-z]+/[^/]+/(?P<id>[^/?#&]+)'
177 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html',
180 'display_id': 'straubing-tigers-koelner-haie',
182 'title': 'Straubing Tigers - Kölner Haie',
183 'upload_date': '20140912',
185 'categories': ['Eishockey'],
188 'skip_download': True,
191 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie',
194 'display_id': 'straubing-tigers-koelner-haie',
196 'title': 'Straubing Tigers - Kölner Haie',
197 'upload_date': '20160129',
199 'categories': ['Eishockey'],
202 'skip_download': True,
205 'url': 'http://www.laola1.tv/de-de/livestream/2016-03-22-belogorie-belgorod-trentino-diatec-lde',
208 'display_id': '2016-03-22-belogorie-belgorod-trentino-diatec-lde',
210 'title': 'Belogorie BELGOROD - TRENTINO Diatec',
211 'upload_date': '20160322',
212 'uploader': 'CEV - Europäischer Volleyball Verband',
214 'categories': ['Volleyball'],
217 'skip_download': True,
219 'skip': 'This live stream has already finished.',
222 def _real_extract(self, url):
223 return self._extract_video(url)
226 class EHFTVIE(Laola1TvBaseIE):
228 _VALID_URL = r'https?://(?:www\.)?ehftv\.com/[a-z]+(-[a-z]+)?/[^/]+/(?P<id>[^/?#&]+)'
231 'url': 'https://www.ehftv.com/int/video/paris-saint-germain-handball-pge-vive-kielce/1166761',
234 'display_id': 'paris-saint-germain-handball-pge-vive-kielce',
236 'title': 'Paris Saint-Germain Handball - PGE Vive Kielce',
238 'categories': ['Handball'],
241 'skip_download': True,
245 def _real_extract(self, url):
246 return self._extract_video(url)
249 class ITTFIE(InfoExtractor):
250 _VALID_URL = r'https?://tv\.ittf\.com/video/[^/]+/(?P<id>\d+)'
252 'url': 'https://tv.ittf.com/video/peng-wang-wei-matsudaira-kenta/951802',
253 'only_matching': True,
256 def _real_extract(self, url):
257 return self.url_result(
258 update_url_query('https://www.laola1.tv/titanplayer.php', {
259 'videoid': self._match_id(url),
264 }), Laola1TvEmbedIE.ie_key())