1 # -*- coding: utf-8 -*-
2 from __future__ import unicode_literals
7 from .common import InfoExtractor
14 class Laola1TvIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?laola1\.tv/(?P<lang>[a-z]+)-(?P<portal>[a-z]+)/.*?/(?P<id>[0-9]+)\.html'
17 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html',
21 'title': 'Straubing Tigers - Kölner Haie',
22 'categories': ['Eishockey'],
26 'skip_download': True,
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 video_id = mobj.group('id')
33 lang = mobj.group('lang')
34 portal = mobj.group('portal')
36 webpage = self._download_webpage(url, video_id)
37 iframe_url = self._search_regex(
38 r'<iframe[^>]*?class="main_tv_player"[^>]*?src="([^"]+)"',
39 webpage, 'iframe URL')
41 iframe = self._download_webpage(
42 iframe_url, video_id, note='Downloading iframe')
43 flashvars_m = re.findall(
44 r'flashvars\.([_a-zA-Z0-9]+)\s*=\s*"([^"]*)";', iframe)
45 flashvars = dict((m[0], m[1]) for m in flashvars_m)
47 partner_id = self._search_regex(
48 r'partnerid\s*:\s*"([^"]+)"', iframe, 'partner id')
50 xml_url = ('http://www.laola1.tv/server/hd_video.php?' +
51 'play=%s&partner=%s&portal=%s&v5ident=&lang=%s' % (
52 video_id, partner_id, portal, lang))
53 hd_doc = self._download_xml(xml_url, video_id)
55 title = xpath_text(hd_doc, './/video/title', fatal=True)
56 flash_url = xpath_text(hd_doc, './/video/url', fatal=True)
57 uploader = xpath_text(hd_doc, './/video/meta_organistation')
58 is_live = xpath_text(hd_doc, './/video/islive') == 'true'
60 categories = xpath_text(hd_doc, './/video/meta_sports')
62 categories = categories.split(',')
64 ident = random.randint(10000000, 99999999)
65 token_url = '%s&ident=%s&klub=0&unikey=0×tamp=%s&auth=%s' % (
66 flash_url, ident, flashvars['timestamp'], flashvars['auth'])
68 token_doc = self._download_xml(
69 token_url, video_id, note='Downloading token')
70 token_attrib = token_doc.find('.//token').attrib
71 if token_attrib.get('auth') in ('blocked', 'restricted'):
73 'Token error: %s' % token_attrib.get('comment'), expected=True)
75 video_url = '%s?hdnea=%s&hdcore=3.2.0' % (
76 token_attrib['url'], token_attrib['auth'])
84 'categories': categories,