]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/laola1tv.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  16 class Laola1TvEmbedIE(InfoExtractor
): 
  17     IE_NAME 
= 'laola1tv:embed' 
  18     _VALID_URL 
= r
'https?://(?:www\.)?laola1\.tv/titanplayer\.php\?.*?\bvideoid=(?P<id>\d+)' 
  20         # flashvars.premium = "false"; 
  21         'url': 'https://www.laola1.tv/titanplayer.php?videoid=708065&type=V&lang=en&portal=int&customer=1024', 
  25             'title': 'MA Long CHN - FAN Zhendong CHN', 
  26             'uploader': 'ITTF - International Table Tennis Federation', 
  27             'upload_date': '20161211', 
  31     def _real_extract(self
, url
): 
  32         video_id 
= self
._match
_id
(url
) 
  33         webpage 
= self
._download
_webpage
(url
, video_id
) 
  34         flash_vars 
= self
._search
_regex
( 
  35             r
'(?s)flashvars\s*=\s*({.+?});', webpage
, 'flash vars') 
  37         def get_flashvar(x
, *args
, **kwargs
): 
  38             flash_var 
= self
._search
_regex
( 
  39                 r
'%s\s*:\s*"([^"]+)"' % x
, 
  40                 flash_vars
, x
, default
=None) 
  42                 flash_var 
= self
._search
_regex
([ 
  43                     r
'flashvars\.%s\s*=\s*"([^"]+)"' % x
, 
  44                     r
'%s\s*=\s*"([^"]+)"' % x
], 
  45                     webpage
, x
, *args
, **kwargs
) 
  48         hd_doc 
= self
._download
_xml
( 
  49             'http://www.laola1.tv/server/hd_video.php', video_id
, query
={ 
  50                 'play': get_flashvar('streamid'), 
  51                 'partner': get_flashvar('partnerid'), 
  52                 'portal': get_flashvar('portalid'), 
  53                 'lang': get_flashvar('sprache'), 
  57         _v 
= lambda x
, **k
: xpath_text(hd_doc
, './/video/' + x
, **k
) 
  58         title 
= _v('title', fatal
=True) 
  61         premium 
= get_flashvar('premium', default
=None) 
  63             token_url 
= update_url_query( 
  64                 _v('url', fatal
=True), { 
  65                     'timestamp': get_flashvar('timestamp'), 
  66                     'auth': get_flashvar('auth'), 
  69             data_abo 
= urlencode_postdata( 
  70                 dict((i
, v
) for i
, v 
in enumerate(_v('req_liga_abos').split(',')))) 
  71             token_url 
= self
._download
_json
( 
  72                 'https://club.laola1.tv/sp/laola1/api/v3/user/session/premium/player/stream-access', 
  75                     'target': self
._search
_regex
(r
'vs_target = (\d+);', webpage
, 'vs target'), 
  78                 }, data
=data_abo
)['data']['stream-access'][0] 
  80         token_doc 
= self
._download
_xml
( 
  81             token_url
, video_id
, 'Downloading token', 
  82             headers
=self
.geo_verification_headers()) 
  84         token_attrib 
= xpath_element(token_doc
, './/token').attrib
 
  86         if token_attrib
['status'] != '0': 
  88                 'Token error: %s' % token_attrib
['comment'], expected
=True) 
  90         formats 
= self
._extract
_akamai
_formats
( 
  91             '%s?hdnea=%s' % (token_attrib
['url'], token_attrib
['auth']), 
  93         self
._sort
_formats
(formats
) 
  95         categories_str 
= _v('meta_sports') 
  96         categories 
= categories_str
.split(',') if categories_str 
else [] 
  97         is_live 
= _v('islive') == 'true' 
 101             'title': self
._live
_title
(title
) if is_live 
else title
, 
 102             'upload_date': unified_strdate(_v('time_date')), 
 103             'uploader': _v('meta_organisation'), 
 104             'categories': categories
, 
 110 class Laola1TvIE(InfoExtractor
): 
 112     _VALID_URL 
= r
'https?://(?:www\.)?laola1\.tv/[a-z]+-[a-z]+/[^/]+/(?P<id>[^/?#&]+)' 
 114         'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie/227883.html', 
 117             'display_id': 'straubing-tigers-koelner-haie', 
 119             'title': 'Straubing Tigers - Kölner Haie', 
 120             'upload_date': '20140912', 
 122             'categories': ['Eishockey'], 
 125             'skip_download': True, 
 128         'url': 'http://www.laola1.tv/de-de/video/straubing-tigers-koelner-haie', 
 131             'display_id': 'straubing-tigers-koelner-haie', 
 133             'title': 'Straubing Tigers - Kölner Haie', 
 134             'upload_date': '20160129', 
 136             'categories': ['Eishockey'], 
 139             'skip_download': True, 
 142         'url': 'http://www.laola1.tv/de-de/livestream/2016-03-22-belogorie-belgorod-trentino-diatec-lde', 
 145             'display_id': '2016-03-22-belogorie-belgorod-trentino-diatec-lde', 
 147             'title': 'Belogorie BELGOROD - TRENTINO Diatec', 
 148             'upload_date': '20160322', 
 149             'uploader': 'CEV - Europäischer Volleyball Verband', 
 151             'categories': ['Volleyball'], 
 154             'skip_download': True, 
 156         'skip': 'This live stream has already finished.', 
 159     def _real_extract(self
, url
): 
 160         display_id 
= self
._match
_id
(url
) 
 162         webpage 
= self
._download
_webpage
(url
, display_id
) 
 164         if 'Dieser Livestream ist bereits beendet.' in webpage
: 
 165             raise ExtractorError('This live stream has already finished.', expected
=True) 
 167         iframe_url 
= urljoin(url
, self
._search
_regex
( 
 168             r
'<iframe[^>]*?id="videoplayer"[^>]*?src="([^"]+)"', 
 169             webpage
, 'iframe url')) 
 173             'display_id': display_id
, 
 175             'ie_key': 'Laola1TvEmbed',