1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
6 from .common import InfoExtractor
18 class Laola1TvIE(InfoExtractor):
19 _VALID_URL = r'https?://(?:www\.)?laola1\.tv/(?P<lang>[a-z]+)-(?P<portal>[a-z]+)/.*?/(?P<slug>[\w-]+)'
21 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html',
23 'categories': ['Eishockey'],
27 'title': 'Straubing Tigers - Kölner Haie',
28 'upload_date': '20140912',
31 'skip_download': True,
34 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie',
36 'categories': ['Eishockey'],
40 'title': 'Straubing Tigers - Kölner Haie',
41 'upload_date': '20160129',
44 'skip_download': True,
48 def _real_extract(self, url):
49 mobj = re.match(self._VALID_URL, url)
50 lang = mobj.group('lang')
51 portal = mobj.group('portal')
53 webpage = self._download_webpage(url, mobj.group('slug'))
54 iframe_url = self._search_regex(
55 r'<iframe[^>]*?id="videoplayer"[^>]*?src="([^"]+)"',
56 webpage, 'iframe URL')
58 video_id = self._search_regex(
59 r'videoid=(\d+)', iframe_url, 'video ID')
61 iframe = self._download_webpage(compat_urlparse.urljoin(
62 url, iframe_url), video_id, note='Downloading iframe')
64 partner_id = self._search_regex(
65 r'partnerid\s*:\s*"([^"]+)"', iframe, 'partner ID')
67 xml_url = ('http://www.laola1.tv/server/hd_video.php?' +
68 'play=%s&partner=%s&portal=%s&v5ident=&lang=%s' % (
69 video_id, partner_id, portal, lang))
70 hd_doc = self._download_xml(xml_url, video_id)
72 _v = lambda x, **k: xpath_text(hd_doc, './/video/' + x, **k)
73 title = _v('title', fatal=True)
75 categories = _v('meta_sports')
77 categories = categories.split(',')
79 time_date = _v('time_date')
80 time_start = _v('time_start')
82 if time_date and time_start:
83 upload_date = unified_strdate(time_date + ' ' + time_start)
85 json_url = ('https://club.laola1.tv/sp/laola1/api/v3/user/session' +
86 '/premium/player/stream-access?videoId=%s&target=2' +
87 '&label=laola1tv&area=%s') % (video_id, _v('area'))
88 req = sanitized_Request(json_url, urlencode_postdata(
89 dict((i, v) for i, v in enumerate(_v('req_liga_abos').split(',')))))
91 token_url = self._download_json(req, video_id)['data']['stream-access'][0]
92 token_doc = self._download_xml(
93 token_url, video_id, note='Downloading token')
95 token_attrib = xpath_element(token_doc, './/token').attrib
96 token_auth = token_attrib['auth']
98 if token_auth in ('blocked', 'restricted'):
100 'Token error: %s' % token_attrib['comment'], expected=True)
102 video_url = '%s?hdnea=%s&hdcore=3.2.0' % (token_attrib['url'], token_auth)
105 'categories': categories,
106 'formats': self._extract_f4m_formats(
107 video_url, video_id, f4m_id='hds'),
109 'is_live': _v('islive') == 'true',
111 'upload_date': upload_date,
112 'uploader': _v('meta_organisation'),