]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/prosiebensat1.py
   2 from __future__ 
import unicode_literals
 
   6 from hashlib 
import sha1
 
   7 from .common 
import InfoExtractor
 
  14 class ProSiebenSat1IE(InfoExtractor
): 
  15     IE_NAME 
= 'prosiebensat1' 
  16     IE_DESC 
= 'ProSiebenSat.1 Digital' 
  17     _VALID_URL 
= r
'https?://(?:www\.)?(?:(?:prosieben|prosiebenmaxx|sixx|sat1|kabeleins|ran|the-voice-of-germany)\.de|fem\.com)/(?P<id>.+)' 
  21             'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge', 
  25                 'title': 'Staffel 2, Episode 18 - Jahresrückblick', 
  26                 'description': 'md5:8733c81b702ea472e069bc48bb658fc1', 
  27                 'upload_date': '20131231', 
  32                 'skip_download': True, 
  36             'url': 'http://www.prosieben.de/videokatalog/Gesellschaft/Leben/Trends/video-Lady-Umstyling-f%C3%BCr-Audrina-Rebekka-Audrina-Fergen-billig-aussehen-Battal-Modica-700544.html', 
  40                 'title': 'Lady-Umstyling für Audrina', 
  41                 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d', 
  42                 'upload_date': '20131014', 
  47                 'skip_download': True, 
  49             'skip': 'Seems to be broken', 
  52             'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge', 
  56                 'title': 'Countdown für die Autowerkstatt', 
  57                 'description': 'md5:809fc051a457b5d8666013bc40698817', 
  58                 'upload_date': '20140223', 
  63                 'skip_download': True, 
  67             'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip', 
  71                 'title': 'Sexy laufen in Ugg Boots', 
  72                 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6', 
  73                 'upload_date': '20140122', 
  78                 'skip_download': True, 
  82             'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip', 
  86                 'title': 'Im Interview: Kai Wiesinger', 
  87                 'description': 'md5:e4e5370652ec63b95023e914190b4eb9', 
  88                 'upload_date': '20140225', 
  93                 'skip_download': True, 
  97             'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge', 
 101                 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2', 
 102                 'description': 'md5:2669cde3febe9bce13904f701e774eb6', 
 103                 'upload_date': '20140225', 
 108                 'skip_download': True, 
 112             'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge', 
 116                 'title': 'Schalke: Tönnies möchte Raul zurück', 
 117                 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f', 
 118                 'upload_date': '20140226', 
 123                 'skip_download': True, 
 127             'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip', 
 131                 'title': 'Andreas Kümmert: Rocket Man', 
 132                 'description': 'md5:6ddb02b0781c6adf778afea606652e38', 
 133                 'upload_date': '20131017', 
 138                 'skip_download': True, 
 142             'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html', 
 146                 'title': 'Kurztrips zum Valentinstag', 
 147                 'description': 'Romantischer Kurztrip zum Valentinstag? Wir verraten, was sich hier wirklich lohnt.', 
 152                 'skip_download': True, 
 158         r
'"clip_id"\s*:\s+"(\d+)"', 
 163         r
'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>', 
 164         r
'<header class="clearfix">\s*<h3>(.+?)</h3>', 
 165         r
'<!-- start video -->\s*<h1>(.+?)</h1>', 
 166         r
'<h1 class="att-name">\s*(.+?)</h1>', 
 168     _DESCRIPTION_REGEXES 
= [ 
 169         r
'<p itemprop="description">\s*(.+?)</p>', 
 170         r
'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>', 
 171         r
'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>', 
 172         r
'<p class="att-description">\s*(.+?)\s*</p>', 
 174     _UPLOAD_DATE_REGEXES 
= [ 
 175         r
'<meta property="og:published_time" content="(.+?)">', 
 176         r
'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"', 
 177         r
'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr', 
 178         r
'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>', 
 179         r
'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>', 
 182     def _real_extract(self
, url
): 
 183         video_id 
= self
._match
_id
(url
) 
 184         webpage 
= self
._download
_webpage
(url
, video_id
) 
 186         clip_id 
= self
._html
_search
_regex
(self
._CLIPID
_REGEXES
, webpage
, 'clip id') 
 188         access_token 
= 'testclient' 
 189         client_name 
= 'kolibri-1.2.5' 
 190         client_location 
= url
 
 192         videos_api_url 
= 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse
.urlencode({ 
 193             'access_token': access_token
, 
 194             'client_location': client_location
, 
 195             'client_name': client_name
, 
 199         videos 
= self
._download
_json
(videos_api_url
, clip_id
, 'Downloading videos JSON') 
 201         duration 
= float(videos
[0]['duration']) 
 202         source_ids 
= [source
['id'] for source 
in videos
[0]['sources']] 
 203         source_ids_str 
= ','.join(map(str, source_ids
)) 
 205         g 
= '01!8d8F_)r9]4s[qeuXfP%' 
 207         client_id 
= g
[:2] + sha1(''.join([clip_id
, g
, access_token
, client_location
, g
, client_name
]) 
 208                                  .encode('utf-8')).hexdigest() 
 210         sources_api_url 
= 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?%s' % (clip_id
, compat_urllib_parse
.urlencode({ 
 211             'access_token': access_token
, 
 212             'client_id': client_id
, 
 213             'client_location': client_location
, 
 214             'client_name': client_name
, 
 217         sources 
= self
._download
_json
(sources_api_url
, clip_id
, 'Downloading sources JSON') 
 218         server_id 
= sources
['server_id'] 
 220         client_id 
= g
[:2] + sha1(''.join([g
, clip_id
, access_token
, server_id
, 
 221                                           client_location
, source_ids_str
, g
, client_name
]) 
 222                                  .encode('utf-8')).hexdigest() 
 224         url_api_url 
= 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (clip_id
, compat_urllib_parse
.urlencode({ 
 225             'access_token': access_token
, 
 226             'client_id': client_id
, 
 227             'client_location': client_location
, 
 228             'client_name': client_name
, 
 229             'server_id': server_id
, 
 230             'source_ids': source_ids_str
, 
 233         urls 
= self
._download
_json
(url_api_url
, clip_id
, 'Downloading urls JSON') 
 235         title 
= self
._html
_search
_regex
(self
._TITLE
_REGEXES
, webpage
, 'title') 
 236         description 
= self
._html
_search
_regex
(self
._DESCRIPTION
_REGEXES
, webpage
, 'description', fatal
=False) 
 237         thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
 239         upload_date 
= unified_strdate(self
._html
_search
_regex
( 
 240             self
._UPLOAD
_DATE
_REGEXES
, webpage
, 'upload date', default
=None)) 
 244         urls_sources 
= urls
['sources'] 
 245         if isinstance(urls_sources
, dict): 
 246             urls_sources 
= urls_sources
.values() 
 248         def fix_bitrate(bitrate
): 
 249             return (bitrate 
// 1000) if bitrate 
% 1000 == 0 else bitrate
 
 251         for source 
in urls_sources
: 
 252             protocol 
= source
['protocol'] 
 253             if protocol 
== 'rtmp' or protocol 
== 'rtmpe': 
 254                 mobj 
= re
.search(r
'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+))/(?P<playpath>.+)$', source
['url']) 
 258                     'url': mobj
.group('url'), 
 259                     'app': mobj
.group('app'), 
 260                     'play_path': mobj
.group('playpath'), 
 261                     'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf', 
 262                     'page_url': 'http://www.prosieben.de', 
 263                     'vbr': fix_bitrate(source
['bitrate']), 
 265                     'format_id': '%s_%s' % (source
['cdn'], source
['bitrate']), 
 269                     'url': source
['url'], 
 270                     'vbr': fix_bitrate(source
['bitrate']), 
 273         self
._sort
_formats
(formats
) 
 278             'description': description
, 
 279             'thumbnail': thumbnail
, 
 280             'upload_date': upload_date
, 
 281             'duration': duration
,