2015-02-23 19:45:36 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2014-10-28 16:51:32 +01:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2015-02-23 19:45:36 +01:00
|
|
|
from ..utils import (
|
2016-02-09 16:25:30 +01:00
|
|
|
compat_urlparse,
|
2015-02-23 19:45:36 +01:00
|
|
|
ExtractorError,
|
2016-02-09 16:25:30 +01:00
|
|
|
sanitized_Request,
|
|
|
|
xpath_element,
|
2015-02-23 19:45:36 +01:00
|
|
|
xpath_text,
|
2016-02-09 16:25:30 +01:00
|
|
|
unified_strdate,
|
|
|
|
urlencode_postdata,
|
2015-02-23 19:45:36 +01:00
|
|
|
)
|
2014-10-28 16:51:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Laola1TvIE(InfoExtractor):
|
2016-02-09 16:25:30 +01:00
|
|
|
_VALID_URL = r'https?://(?:www\.)?laola1\.tv/(?P<lang>[a-z]+)-(?P<portal>[a-z]+)/.*?/(?P<slug>[\w-]+)'
|
|
|
|
_TESTS = [{
|
2015-02-23 19:45:36 +01:00
|
|
|
'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html',
|
2014-10-28 16:51:32 +01:00
|
|
|
'info_dict': {
|
2016-02-09 16:25:30 +01:00
|
|
|
'categories': ['Eishockey'],
|
|
|
|
'ext': 'flv',
|
2015-02-23 19:45:36 +01:00
|
|
|
'id': '227883',
|
2016-02-09 16:25:30 +01:00
|
|
|
'is_live': False,
|
2015-02-23 19:45:36 +01:00
|
|
|
'title': 'Straubing Tigers - Kölner Haie',
|
2016-02-09 16:25:30 +01:00
|
|
|
'upload_date': '20140912',
|
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie',
|
|
|
|
'info_dict': {
|
2015-02-23 19:45:36 +01:00
|
|
|
'categories': ['Eishockey'],
|
2016-02-09 16:25:30 +01:00
|
|
|
'ext': 'flv',
|
|
|
|
'id': '464602',
|
2015-02-23 19:45:36 +01:00
|
|
|
'is_live': False,
|
2016-02-09 16:25:30 +01:00
|
|
|
'title': 'Straubing Tigers - Kölner Haie',
|
|
|
|
'upload_date': '20160129',
|
2014-10-28 16:51:32 +01:00
|
|
|
},
|
|
|
|
'params': {
|
|
|
|
'skip_download': True,
|
|
|
|
}
|
2016-02-09 16:25:30 +01:00
|
|
|
}]
|
2014-10-28 16:51:32 +01:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
mobj = re.match(self._VALID_URL, url)
|
|
|
|
lang = mobj.group('lang')
|
|
|
|
portal = mobj.group('portal')
|
|
|
|
|
2016-02-09 16:25:30 +01:00
|
|
|
webpage = self._download_webpage(url, mobj.group('slug'))
|
2014-10-28 16:51:32 +01:00
|
|
|
iframe_url = self._search_regex(
|
2016-02-09 16:25:30 +01:00
|
|
|
r'<iframe[^>]*?id="videoplayer"[^>]*?src="([^"]+)"',
|
2014-10-28 16:51:32 +01:00
|
|
|
webpage, 'iframe URL')
|
|
|
|
|
2016-02-09 16:25:30 +01:00
|
|
|
video_id = self._search_regex(
|
|
|
|
r'videoid=(\d+)', iframe_url, 'video ID')
|
|
|
|
|
|
|
|
iframe = self._download_webpage(compat_urlparse.urljoin(
|
|
|
|
url, iframe_url), video_id, note='Downloading iframe')
|
2014-10-28 16:51:32 +01:00
|
|
|
|
2015-02-23 19:45:36 +01:00
|
|
|
partner_id = self._search_regex(
|
2016-02-09 16:25:30 +01:00
|
|
|
r'partnerid\s*:\s*"([^"]+)"', iframe, 'partner ID')
|
2015-02-23 19:45:36 +01:00
|
|
|
|
2014-10-28 16:51:32 +01:00
|
|
|
xml_url = ('http://www.laola1.tv/server/hd_video.php?' +
|
2015-02-23 19:45:36 +01:00
|
|
|
'play=%s&partner=%s&portal=%s&v5ident=&lang=%s' % (
|
|
|
|
video_id, partner_id, portal, lang))
|
2014-10-28 16:51:32 +01:00
|
|
|
hd_doc = self._download_xml(xml_url, video_id)
|
|
|
|
|
2016-02-09 16:25:30 +01:00
|
|
|
_v = lambda x, **k: xpath_text(hd_doc, './/video/' + x, **k)
|
|
|
|
title = _v('title', fatal=True)
|
2015-02-23 19:45:36 +01:00
|
|
|
|
2016-02-09 16:25:30 +01:00
|
|
|
categories = _v('meta_sports')
|
2015-02-23 19:45:36 +01:00
|
|
|
if categories:
|
|
|
|
categories = categories.split(',')
|
2014-10-28 16:51:32 +01:00
|
|
|
|
2016-02-09 16:25:30 +01:00
|
|
|
time_date = _v('time_date')
|
|
|
|
time_start = _v('time_start')
|
|
|
|
upload_date = None
|
|
|
|
if time_date and time_start:
|
|
|
|
upload_date = unified_strdate(time_date + ' ' + time_start)
|
2014-10-28 16:51:32 +01:00
|
|
|
|
2016-02-09 16:25:30 +01:00
|
|
|
json_url = ('https://club.laola1.tv/sp/laola1/api/v3/user/session' +
|
|
|
|
'/premium/player/stream-access?videoId=%s&target=2' +
|
|
|
|
'&label=laola1tv&area=%s') % (video_id, _v('area'))
|
|
|
|
req = sanitized_Request(json_url, urlencode_postdata(
|
|
|
|
dict((i, v) for i, v in enumerate(_v('req_liga_abos').split(',')))))
|
|
|
|
|
|
|
|
token_url = self._download_json(req, video_id)['data']['stream-access'][0]
|
2014-10-28 16:51:32 +01:00
|
|
|
token_doc = self._download_xml(
|
|
|
|
token_url, video_id, note='Downloading token')
|
2016-02-09 16:25:30 +01:00
|
|
|
|
|
|
|
token_attrib = xpath_element(token_doc, './/token').attrib
|
|
|
|
token_auth = token_attrib['auth']
|
|
|
|
|
|
|
|
if token_auth in ('blocked', 'restricted'):
|
2015-02-23 19:45:36 +01:00
|
|
|
raise ExtractorError(
|
2016-02-09 16:25:30 +01:00
|
|
|
'Token error: %s' % token_attrib['comment'], expected=True)
|
2014-10-28 16:51:32 +01:00
|
|
|
|
2016-02-09 16:25:30 +01:00
|
|
|
video_url = '%s?hdnea=%s&hdcore=3.2.0' % (token_attrib['url'], token_auth)
|
2014-10-28 16:51:32 +01:00
|
|
|
|
|
|
|
return {
|
2016-02-09 16:25:30 +01:00
|
|
|
'categories': categories,
|
|
|
|
'formats': self._extract_f4m_formats(
|
|
|
|
video_url, video_id, f4m_id='hds'),
|
2014-10-28 16:51:32 +01:00
|
|
|
'id': video_id,
|
2016-02-09 16:25:30 +01:00
|
|
|
'is_live': _v('islive') == 'true',
|
2014-10-28 16:51:32 +01:00
|
|
|
'title': title,
|
2016-02-09 16:25:30 +01:00
|
|
|
'upload_date': upload_date,
|
|
|
|
'uploader': _v('meta_organisation'),
|
2014-10-28 16:51:32 +01:00
|
|
|
}
|