]>
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
 
  20 class ProSiebenSat1IE(InfoExtractor
): 
  21     IE_NAME 
= 'prosiebensat1' 
  22     IE_DESC 
= 'ProSiebenSat.1 Digital' 
  23     _VALID_URL 
= r
'https?://(?:www\.)?(?:(?:prosieben|prosiebenmaxx|sixx|sat1|kabeleins|the-voice-of-germany)\.(?:de|at|ch)|ran\.de|fem\.com)/(?P<id>.+)' 
  27             # Tests changes introduced in https://github.com/rg3/youtube-dl/pull/6242 
  28             # in response to fixing https://github.com/rg3/youtube-dl/issues/6215: 
  29             # - malformed f4m manifest support 
  30             # - proper handling of URLs starting with `https?://` in 2.0 manifests 
  31             # - recursive child f4m manifests extraction 
  32             'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge', 
  36                 'title': 'Episode 18 - Staffel 2', 
  37                 'description': 'md5:8733c81b702ea472e069bc48bb658fc1', 
  38                 'upload_date': '20131231', 
  43                 'skip_download': True, 
  47             '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', 
  51                 'title': 'Lady-Umstyling für Audrina', 
  52                 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d', 
  53                 'upload_date': '20131014', 
  58                 'skip_download': True, 
  60             'skip': 'Seems to be broken', 
  63             'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge', 
  67                 'title': 'Countdown für die Autowerkstatt', 
  68                 'description': 'md5:809fc051a457b5d8666013bc40698817', 
  69                 'upload_date': '20140223', 
  74                 'skip_download': True, 
  78             'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip', 
  82                 'title': 'Sexy laufen in Ugg Boots', 
  83                 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6', 
  84                 'upload_date': '20140122', 
  89                 'skip_download': True, 
  93             'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip', 
  97                 'title': 'Im Interview: Kai Wiesinger', 
  98                 'description': 'md5:e4e5370652ec63b95023e914190b4eb9', 
  99                 'upload_date': '20140203', 
 104                 'skip_download': True, 
 108             'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge', 
 112                 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2', 
 113                 'description': 'md5:2669cde3febe9bce13904f701e774eb6', 
 114                 'upload_date': '20141014', 
 119                 'skip_download': True, 
 123             'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge', 
 127                 'title': 'Schalke: Tönnies möchte Raul zurück', 
 128                 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f', 
 129                 'upload_date': '20140226', 
 134                 'skip_download': True, 
 138             'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip', 
 142                 'title': 'Andreas Kümmert: Rocket Man', 
 143                 'description': 'md5:6ddb02b0781c6adf778afea606652e38', 
 144                 'upload_date': '20131017', 
 149                 'skip_download': True, 
 153             'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html', 
 157                 'title': 'Kurztrips zum Valentinstag', 
 158                 'description': 'Romantischer Kurztrip zum Valentinstag? Wir verraten, was sich hier wirklich lohnt.', 
 163                 'skip_download': True, 
 167             'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist', 
 170                 'title': 'Episode 8 - Ganze Folge - Playlist', 
 171                 'description': 'md5:63b8963e71f481782aeea877658dec84', 
 178         r
'"clip_id"\s*:\s+"(\d+)"', 
 181         r
"'itemImageUrl'\s*:\s*'/dynamic/thumbnails/full/\d+/(\d+)", 
 184         r
'<h2 class="subtitle" itemprop="name">\s*(.+?)</h2>', 
 185         r
'<header class="clearfix">\s*<h3>(.+?)</h3>', 
 186         r
'<!-- start video -->\s*<h1>(.+?)</h1>', 
 187         r
'<h1 class="att-name">\s*(.+?)</h1>', 
 188         r
'<header class="module_header">\s*<h2>([^<]+)</h2>\s*</header>', 
 190     _DESCRIPTION_REGEXES 
= [ 
 191         r
'<p itemprop="description">\s*(.+?)</p>', 
 192         r
'<div class="videoDecription">\s*<p><strong>Beschreibung</strong>: (.+?)</p>', 
 193         r
'<div class="g-plusone" data-size="medium"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>', 
 194         r
'<p class="att-description">\s*(.+?)\s*</p>', 
 196     _UPLOAD_DATE_REGEXES 
= [ 
 197         r
'<meta property="og:published_time" content="(.+?)">', 
 198         r
'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration"', 
 199         r
'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr', 
 200         r
'<span style="padding-left: 4px;line-height:20px; color:#404040">(\d{2}\.\d{2}\.\d{4})</span>', 
 201         r
'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>', 
 203     _PAGE_TYPE_REGEXES 
= [ 
 204         r
'<meta name="page_type" content="([^"]+)">', 
 205         r
"'itemType'\s*:\s*'([^']*)'", 
 207     _PLAYLIST_ID_REGEXES 
= [ 
 208         r
'content[iI]d=(\d+)', 
 209         r
"'itemId'\s*:\s*'([^']*)'", 
 211     _PLAYLIST_CLIP_REGEXES 
= [ 
 212         r
'(?s)data-qvt=.+?<a href="([^"]+)"', 
 215     def _extract_clip(self
, url
, webpage
): 
 216         clip_id 
= self
._html
_search
_regex
(self
._CLIPID
_REGEXES
, webpage
, 'clip id') 
 218         access_token 
= 'prosieben' 
 219         client_name 
= 'kolibri-2.0.19-splec4' 
 220         client_location 
= url
 
 222         videos_api_url 
= 'http://vas.sim-technik.de/vas/live/v2/videos?%s' % compat_urllib_parse
.urlencode({ 
 223             'access_token': access_token
, 
 224             'client_location': client_location
, 
 225             'client_name': client_name
, 
 229         video 
= self
._download
_json
(videos_api_url
, clip_id
, 'Downloading videos JSON')[0] 
 231         if video
.get('is_protected') is True: 
 232             raise ExtractorError('This video is DRM protected.', expected
=True) 
 234         duration 
= float_or_none(video
.get('duration')) 
 235         source_ids 
= [source
['id'] for source 
in video
['sources']] 
 236         source_ids_str 
= ','.join(map(str, source_ids
)) 
 238         g 
= '01!8d8F_)r9]4s[qeuXfP%' 
 240         client_id 
= g
[:2] + sha1(''.join([clip_id
, g
, access_token
, client_location
, g
, client_name
]) 
 241                                  .encode('utf-8')).hexdigest() 
 243         sources_api_url 
= 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?%s' % (clip_id
, compat_urllib_parse
.urlencode({ 
 244             'access_token': access_token
, 
 245             'client_id': client_id
, 
 246             'client_location': client_location
, 
 247             'client_name': client_name
, 
 250         sources 
= self
._download
_json
(sources_api_url
, clip_id
, 'Downloading sources JSON') 
 251         server_id 
= sources
['server_id'] 
 253         client_id 
= g
[:2] + sha1(''.join([g
, clip_id
, access_token
, server_id
, 
 254                                           client_location
, source_ids_str
, g
, client_name
]) 
 255                                  .encode('utf-8')).hexdigest() 
 257         url_api_url 
= 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (clip_id
, compat_urllib_parse
.urlencode({ 
 258             'access_token': access_token
, 
 259             'client_id': client_id
, 
 260             'client_location': client_location
, 
 261             'client_name': client_name
, 
 262             'server_id': server_id
, 
 263             'source_ids': source_ids_str
, 
 266         urls 
= self
._download
_json
(url_api_url
, clip_id
, 'Downloading urls JSON') 
 268         title 
= self
._html
_search
_regex
(self
._TITLE
_REGEXES
, webpage
, 'title') 
 269         description 
= self
._html
_search
_regex
(self
._DESCRIPTION
_REGEXES
, webpage
, 'description', fatal
=False) 
 270         thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
 272         upload_date 
= unified_strdate(self
._html
_search
_regex
( 
 273             self
._UPLOAD
_DATE
_REGEXES
, webpage
, 'upload date', default
=None)) 
 277         urls_sources 
= urls
['sources'] 
 278         if isinstance(urls_sources
, dict): 
 279             urls_sources 
= urls_sources
.values() 
 281         def fix_bitrate(bitrate
): 
 282             bitrate 
= int_or_none(bitrate
) 
 285             return (bitrate 
// 1000) if bitrate 
% 1000 == 0 else bitrate
 
 287         for source 
in urls_sources
: 
 288             protocol 
= source
['protocol'] 
 289             source_url 
= source
['url'] 
 290             if protocol 
== 'rtmp' or protocol 
== 'rtmpe': 
 291                 mobj 
= re
.search(r
'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source_url
) 
 294                 path 
= mobj
.group('path') 
 295                 mp4colon_index 
= path
.rfind('mp4:') 
 296                 app 
= path
[:mp4colon_index
] 
 297                 play_path 
= path
[mp4colon_index
:] 
 299                     'url': '%s/%s' % (mobj
.group('url'), app
), 
 301                     'play_path': play_path
, 
 302                     'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf', 
 303                     'page_url': 'http://www.prosieben.de', 
 304                     'vbr': fix_bitrate(source
['bitrate']), 
 306                     'format_id': '%s_%s' % (source
['cdn'], source
['bitrate']), 
 308             elif 'f4mgenerator' in source_url 
or determine_ext(source_url
) == 'f4m': 
 309                 formats
.extend(self
._extract
_f
4m
_formats
(source_url
, clip_id
)) 
 313                     'vbr': fix_bitrate(source
['bitrate']), 
 316         self
._sort
_formats
(formats
) 
 321             'description': description
, 
 322             'thumbnail': thumbnail
, 
 323             'upload_date': upload_date
, 
 324             'duration': duration
, 
 328     def _extract_playlist(self
, url
, webpage
): 
 329         playlist_id 
= self
._html
_search
_regex
( 
 330             self
._PLAYLIST
_ID
_REGEXES
, webpage
, 'playlist id') 
 331         for regex 
in self
._PLAYLIST
_CLIP
_REGEXES
: 
 332             playlist_clips 
= re
.findall(regex
, webpage
) 
 334                 title 
= self
._html
_search
_regex
( 
 335                     self
._TITLE
_REGEXES
, webpage
, 'title') 
 336                 description 
= self
._html
_search
_regex
( 
 337                     self
._DESCRIPTION
_REGEXES
, webpage
, 'description', fatal
=False) 
 340                         re
.match('(.+?//.+?)/', url
).group(1) + clip_path
, 
 342                     for clip_path 
in playlist_clips
] 
 343                 return self
.playlist_result(entries
, playlist_id
, title
, description
) 
 345     def _real_extract(self
, url
): 
 346         video_id 
= self
._match
_id
(url
) 
 347         webpage 
= self
._download
_webpage
(url
, video_id
) 
 348         page_type 
= self
._search
_regex
( 
 349             self
._PAGE
_TYPE
_REGEXES
, webpage
, 
 350             'page type', default
='clip').lower() 
 351         if page_type 
== 'clip': 
 352             return self
._extract
_clip
(url
, webpage
) 
 353         elif page_type 
== 'playlist': 
 354             return self
._extract
_playlist
(url
, webpage
)