]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/laola1tv.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
21 class Laola1TvIE(InfoExtractor
):
22 _VALID_URL
= r
'https?://(?:www\.)?laola1\.tv/(?P<lang>[a-z]+)-(?P<portal>[a-z]+)/[^/]+/(?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,
53 def _real_extract(self
, url
):
54 mobj
= re
.match(self
._VALID
_URL
, url
)
55 display_id
= mobj
.group('slug')
56 lang
= mobj
.group('lang')
57 portal
= mobj
.group('portal')
59 webpage
= self
._download
_webpage
(url
, display_id
)
61 iframe_url
= self
._search
_regex
(
62 r
'<iframe[^>]*?id="videoplayer"[^>]*?src="([^"]+)"',
63 webpage
, 'iframe url')
65 video_id
= self
._search
_regex
(
66 r
'videoid=(\d+)', iframe_url
, 'video id')
68 iframe
= self
._download
_webpage
(compat_urlparse
.urljoin(
69 url
, iframe_url
), display_id
, 'Downloading iframe')
71 partner_id
= self
._search
_regex
(
72 r
'partnerid\s*:\s*(["\'])(?P
<partner_id
>.+?
)\
1',
73 iframe, 'partner
id', group='partner_id
')
75 hd_doc = self._download_xml(
76 'http
://www
.laola1
.tv
/server
/hd_video
.php?
%s'
77 % compat_urllib_parse.urlencode({
79 'partner
': partner_id,
85 _v = lambda x, **k: xpath_text(hd_doc, './/video
/' + x, **k)
86 title = _v('title
', fatal=True)
88 req = sanitized_Request(
89 'https
://club
.laola1
.tv
/sp
/laola1
/api
/v3
/user
/session
/premium
/player
/stream
-access?
%s' %
90 compat_urllib_parse.urlencode({
97 dict((i, v) for i, v in enumerate(_v('req_liga_abos
').split(',')))))
99 token_url = self._download_json(req, display_id)['data
']['stream
-access
'][0]
100 token_doc = self._download_xml(token_url, display_id, 'Downloading token
')
102 token_attrib = xpath_element(token_doc, './/token
').attrib
103 token_auth = token_attrib['auth
']
105 if token_auth in ('blocked
', 'restricted
', 'error
'):
106 raise ExtractorError(
107 'Token error
: %s' % token_attrib['comment
'], expected=True)
109 formats = self._extract_f4m_formats(
110 '%s?hdnea
=%s&hdcore
=3.2.0' % (token_attrib['url
'], token_auth),
111 video_id, f4m_id='hds
')
113 categories_str = _v('meta_sports
')
114 categories = categories_str.split(',') if categories_str else []
118 'display_id
': display_id,
120 'upload_date
': unified_strdate(_v('time_date
')),
121 'uploader
': _v('meta_organisation
'),
122 'categories
': categories,
123 'is_live
': _v('islive
') == 'true
',