]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/laola1tv.py
263f687736c3f7fe3e980d79a10971a6dc4df5b2
[youtubedl] / youtube_dl / extractor / laola1tv.py
1 from __future__ import unicode_literals
2
3 import random
4 import re
5
6 from .common import InfoExtractor
7
8
9 class Laola1TvIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?laola1\.tv/(?P<lang>[a-z]+)-(?P<portal>[a-z]+)/.*?/(?P<id>[0-9]+)\.html'
11 _TEST = {
12 'url': 'http://www.laola1.tv/de-de/live/bwf-bitburger-open-grand-prix-gold-court-1/250019.html',
13 'info_dict': {
14 'id': '250019',
15 'ext': 'mp4',
16 'title': 'Bitburger Open Grand Prix Gold - Court 1',
17 'categories': ['Badminton'],
18 'uploader': 'BWF - Badminton World Federation',
19 'is_live': True,
20 },
21 'params': {
22 'skip_download': True,
23 }
24 }
25
26 _BROKEN = True # Not really - extractor works fine, but f4m downloader does not support live streams yet.
27
28 def _real_extract(self, url):
29 mobj = re.match(self._VALID_URL, url)
30 video_id = mobj.group('id')
31 lang = mobj.group('lang')
32 portal = mobj.group('portal')
33
34 webpage = self._download_webpage(url, video_id)
35 iframe_url = self._search_regex(
36 r'<iframe[^>]*?class="main_tv_player"[^>]*?src="([^"]+)"',
37 webpage, 'iframe URL')
38
39 iframe = self._download_webpage(
40 iframe_url, video_id, note='Downloading iframe')
41 flashvars_m = re.findall(
42 r'flashvars\.([_a-zA-Z0-9]+)\s*=\s*"([^"]*)";', iframe)
43 flashvars = dict((m[0], m[1]) for m in flashvars_m)
44
45 xml_url = ('http://www.laola1.tv/server/hd_video.php?' +
46 'play=%s&partner=1&portal=%s&v5ident=&lang=%s' % (
47 video_id, portal, lang))
48 hd_doc = self._download_xml(xml_url, video_id)
49
50 title = hd_doc.find('.//video/title').text
51 flash_url = hd_doc.find('.//video/url').text
52 categories = hd_doc.find('.//video/meta_sports').text.split(',')
53 uploader = hd_doc.find('.//video/meta_organistation').text
54
55 ident = random.randint(10000000, 99999999)
56 token_url = '%s&ident=%s&klub=0&unikey=0&timestamp=%s&auth=%s' % (
57 flash_url, ident, flashvars['timestamp'], flashvars['auth'])
58
59 token_doc = self._download_xml(
60 token_url, video_id, note='Downloading token')
61 token_attrib = token_doc.find('.//token').attrib
62 if token_attrib.get('auth') == 'blocked':
63 raise ExtractorError('Token error: ' % token_attrib.get('comment'))
64
65 video_url = '%s?hdnea=%s&hdcore=3.2.0' % (
66 token_attrib['url'], token_attrib['auth'])
67
68 return {
69 'id': video_id,
70 'is_live': True,
71 'title': title,
72 'url': video_url,
73 'uploader': uploader,
74 'categories': categories,
75 'ext': 'mp4',
76 }
77