2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
8 compat_urllib_parse_urlencode
,
21 class Laola1TvIE(InfoExtractor
):
22 _VALID_URL
= r
'https?://(?:www\.)?laola1\.tv/(?P<lang>[a-z]+)-(?P<portal>[a-z]+)/(?P<kind>[^/]+)/(?P<slug>[^/?#&]+)'
24 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html',
27 'display_id': 'straubing-tigers-koelner-haie',
29 'title': 'Straubing Tigers - Kölner Haie',
30 'upload_date': '20140912',
32 'categories': ['Eishockey'],
35 'skip_download': True,
38 'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie',
41 'display_id': 'straubing-tigers-koelner-haie',
43 'title': 'Straubing Tigers - Kölner Haie',
44 'upload_date': '20160129',
46 'categories': ['Eishockey'],
49 'skip_download': True,
52 'url': 'http://www.laola1.tv/de-de/livestream/2016-03-22-belogorie-belgorod-trentino-diatec-lde',
55 'display_id': '2016-03-22-belogorie-belgorod-trentino-diatec-lde',
57 'title': 'Belogorie BELGOROD - TRENTINO Diatec',
58 'upload_date': '20160322',
59 'uploader': 'CEV - Europäischer Volleyball Verband',
61 'categories': ['Volleyball'],
64 'skip_download': True,
66 'skip': 'This live stream has already finished.',
69 def _real_extract(self
, url
):
70 mobj
= re
.match(self
._VALID
_URL
, url
)
71 display_id
= mobj
.group('slug')
72 kind
= mobj
.group('kind')
73 lang
= mobj
.group('lang')
74 portal
= mobj
.group('portal')
76 webpage
= self
._download
_webpage
(url
, display_id
)
78 if 'Dieser Livestream ist bereits beendet.' in webpage
:
79 raise ExtractorError('This live stream has already finished.', expected
=True)
81 iframe_url
= self
._search
_regex
(
82 r
'<iframe[^>]*?id="videoplayer"[^>]*?src="([^"]+)"',
83 webpage
, 'iframe url')
85 video_id
= self
._search
_regex
(
86 r
'videoid=(\d+)', iframe_url
, 'video id')
88 iframe
= self
._download
_webpage
(compat_urlparse
.urljoin(
89 url
, iframe_url
), display_id
, 'Downloading iframe')
91 partner_id
= self
._search
_regex
(
92 r
'partnerid\s*:\s*(["\'])(?P
<partner_id
>.+?
)\
1',
93 iframe, 'partner
id', group='partner_id
')
95 hd_doc = self._download_xml(
96 'http
://www
.laola1
.tv
/server
/hd_video
.php?
%s'
97 % compat_urllib_parse_urlencode({
99 'partner
': partner_id,
105 _v = lambda x, **k: xpath_text(hd_doc, './/video
/' + x, **k)
106 title = _v('title
', fatal=True)
113 req = sanitized_Request(
114 'https
://club
.laola1
.tv
/sp
/laola1
/api
/v3
/user
/session
/premium
/player
/stream
-access?
%s' %
115 compat_urllib_parse_urlencode({
117 'target
': VS_TARGETS.get(kind, '2'),
118 'label
': _v('label
'),
122 dict((i, v) for i, v in enumerate(_v('req_liga_abos
').split(',')))))
124 token_url = self._download_json(req, display_id)['data
']['stream
-access
'][0]
125 token_doc = self._download_xml(token_url, display_id, 'Downloading token
')
127 token_attrib = xpath_element(token_doc, './/token
').attrib
128 token_auth = token_attrib['auth
']
130 if token_auth in ('blocked
', 'restricted
', 'error
'):
131 raise ExtractorError(
132 'Token error
: %s' % token_attrib['comment
'], expected=True)
134 formats = self._extract_f4m_formats(
135 '%s?hdnea
=%s&hdcore
=3.2.0' % (token_attrib['url
'], token_auth),
136 video_id, f4m_id='hds
')
137 self._sort_formats(formats)
139 categories_str = _v('meta_sports
')
140 categories = categories_str.split(',') if categories_str else []
144 'display_id
': display_id,
146 'upload_date
': unified_strdate(_v('time_date
')),
147 'uploader
': _v('meta_organisation
'),
148 'categories
': categories,
149 'is_live
': _v('islive
') == 'true
',