]>
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
 
   8 from ..compat 
import compat_str
 
  18 class ProSiebenSat1BaseIE(InfoExtractor
): 
  19     def _extract_video_info(self
, url
, clip_id
): 
  22         video 
= self
._download
_json
( 
  23             'http://vas.sim-technik.de/vas/live/v2/videos', 
  24             clip_id
, 'Downloading videos JSON', query
={ 
  25                 'access_token': self
._TOKEN
, 
  26                 'client_location': client_location
, 
  27                 'client_name': self
._CLIENT
_NAME
, 
  31         if video
.get('is_protected') is True: 
  32             raise ExtractorError('This video is DRM protected.', expected
=True) 
  34         duration 
= float_or_none(video
.get('duration')) 
  35         source_ids 
= [compat_str(source
['id']) for source 
in video
['sources']] 
  37         client_id 
= self
._SALT
[:2] + sha1(''.join([clip_id
, self
._SALT
, self
._TOKEN
, client_location
, self
._SALT
, self
._CLIENT
_NAME
]).encode('utf-8')).hexdigest() 
  39         sources 
= self
._download
_json
( 
  40             'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources' % clip_id
, 
  41             clip_id
, 'Downloading sources JSON', query
={ 
  42                 'access_token': self
._TOKEN
, 
  43                 'client_id': client_id
, 
  44                 'client_location': client_location
, 
  45                 'client_name': self
._CLIENT
_NAME
, 
  47         server_id 
= sources
['server_id'] 
  49         def fix_bitrate(bitrate
): 
  50             bitrate 
= int_or_none(bitrate
) 
  53             return (bitrate 
// 1000) if bitrate 
% 1000 == 0 else bitrate
 
  56         for source_id 
in source_ids
: 
  57             client_id 
= self
._SALT
[:2] + sha1(''.join([self
._SALT
, clip_id
, self
._TOKEN
, server_id
, client_location
, source_id
, self
._SALT
, self
._CLIENT
_NAME
]).encode('utf-8')).hexdigest() 
  58             urls 
= self
._download
_json
( 
  59                 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url' % clip_id
, 
  60                 clip_id
, 'Downloading urls JSON', fatal
=False, query
={ 
  61                     'access_token': self
._TOKEN
, 
  62                     'client_id': client_id
, 
  63                     'client_location': client_location
, 
  64                     'client_name': self
._CLIENT
_NAME
, 
  65                     'server_id': server_id
, 
  66                     'source_ids': source_id
, 
  70             if urls
.get('status_code') != 0: 
  71                 raise ExtractorError('This video is unavailable', expected
=True) 
  72             urls_sources 
= urls
['sources'] 
  73             if isinstance(urls_sources
, dict): 
  74                 urls_sources 
= urls_sources
.values() 
  75             for source 
in urls_sources
: 
  76                 source_url 
= source
.get('url') 
  79                 protocol 
= source
.get('protocol') 
  80                 mimetype 
= source
.get('mimetype') 
  81                 if mimetype 
== 'application/f4m+xml' or 'f4mgenerator' in source_url 
or determine_ext(source_url
) == 'f4m': 
  82                     formats
.extend(self
._extract
_f
4m
_formats
( 
  83                         source_url
, clip_id
, f4m_id
='hds', fatal
=False)) 
  84                 elif mimetype 
== 'application/x-mpegURL': 
  85                     formats
.extend(self
._extract
_m
3u8_formats
( 
  86                         source_url
, clip_id
, 'mp4', 'm3u8_native', 
  87                         m3u8_id
='hls', fatal
=False)) 
  88                 elif mimetype 
== 'application/dash+xml': 
  89                     formats
.extend(self
._extract
_mpd
_formats
( 
  90                         source_url
, clip_id
, mpd_id
='dash', fatal
=False)) 
  92                     tbr 
= fix_bitrate(source
['bitrate']) 
  93                     if protocol 
in ('rtmp', 'rtmpe'): 
  94                         mobj 
= re
.search(r
'^(?P<url>rtmpe?://[^/]+)/(?P<path>.+)$', source_url
) 
  97                         path 
= mobj
.group('path') 
  98                         mp4colon_index 
= path
.rfind('mp4:') 
  99                         app 
= path
[:mp4colon_index
] 
 100                         play_path 
= path
[mp4colon_index
:] 
 102                             'url': '%s/%s' % (mobj
.group('url'), app
), 
 104                             'play_path': play_path
, 
 105                             'player_url': 'http://livepassdl.conviva.com/hf/ver/2.79.0.17083/LivePassModuleMain.swf', 
 106                             'page_url': 'http://www.prosieben.de', 
 109                             'format_id': 'rtmp%s' % ('-%d' % tbr 
if tbr 
else ''), 
 115                             'format_id': 'http%s' % ('-%d' % tbr 
if tbr 
else ''), 
 117         self
._sort
_formats
(formats
) 
 120             'duration': duration
, 
 125 class ProSiebenSat1IE(ProSiebenSat1BaseIE
): 
 126     IE_NAME 
= 'prosiebensat1' 
 127     IE_DESC 
= 'ProSiebenSat.1 Digital' 
 128     _VALID_URL 
= r
'''(?x) 
 134                                 prosieben(?:maxx)?|sixx|sat1(?:gold)?|kabeleins(?:doku)?|the-voice-of-germany|7tv|advopedia 
 136                             ran\.de|fem\.com|advopedia\.de|galileo\.tv/video 
 143             # Tests changes introduced in https://github.com/rg3/youtube-dl/pull/6242 
 144             # in response to fixing https://github.com/rg3/youtube-dl/issues/6215: 
 145             # - malformed f4m manifest support 
 146             # - proper handling of URLs starting with `https?://` in 2.0 manifests 
 147             # - recursive child f4m manifests extraction 
 148             'url': 'http://www.prosieben.de/tv/circus-halligalli/videos/218-staffel-2-episode-18-jahresrueckblick-ganze-folge', 
 152                 'title': 'Episode 18 - Staffel 2', 
 153                 'description': 'md5:8733c81b702ea472e069bc48bb658fc1', 
 154                 'upload_date': '20131231', 
 159             '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', 
 163                 'title': 'Lady-Umstyling für Audrina', 
 164                 'description': 'md5:4c16d0c17a3461a0d43ea4084e96319d', 
 165                 'upload_date': '20131014', 
 170                 'skip_download': True, 
 172             'skip': 'Seems to be broken', 
 175             'url': 'http://www.prosiebenmaxx.de/tv/experience/video/144-countdown-fuer-die-autowerkstatt-ganze-folge', 
 179                 'title': 'Countdown für die Autowerkstatt', 
 180                 'description': 'md5:809fc051a457b5d8666013bc40698817', 
 181                 'upload_date': '20140223', 
 186                 'skip_download': True, 
 188             'skip': 'This video is unavailable', 
 191             'url': 'http://www.sixx.de/stars-style/video/sexy-laufen-in-ugg-boots-clip', 
 195                 'title': 'Sexy laufen in Ugg Boots', 
 196                 'description': 'md5:edf42b8bd5bc4e5da4db4222c5acb7d6', 
 197                 'upload_date': '20140122', 
 202                 'skip_download': True, 
 204             'skip': 'This video is unavailable', 
 207             'url': 'http://www.sat1.de/film/der-ruecktritt/video/im-interview-kai-wiesinger-clip', 
 211                 'title': 'Im Interview: Kai Wiesinger', 
 212                 'description': 'md5:e4e5370652ec63b95023e914190b4eb9', 
 213                 'upload_date': '20140203', 
 218                 'skip_download': True, 
 220             'skip': 'This video is unavailable', 
 223             'url': 'http://www.kabeleins.de/tv/rosins-restaurants/videos/jagd-auf-fertigkost-im-elsthal-teil-2-ganze-folge', 
 227                 'title': 'Jagd auf Fertigkost im Elsthal - Teil 2', 
 228                 'description': 'md5:2669cde3febe9bce13904f701e774eb6', 
 229                 'upload_date': '20141014', 
 234                 'skip_download': True, 
 236             'skip': 'This video is unavailable', 
 239             'url': 'http://www.ran.de/fussball/bundesliga/video/schalke-toennies-moechte-raul-zurueck-ganze-folge', 
 243                 'title': 'Schalke: Tönnies möchte Raul zurück', 
 244                 'description': 'md5:4b5b271d9bcde223b54390754c8ece3f', 
 245                 'upload_date': '20140226', 
 250                 'skip_download': True, 
 252             'skip': 'This video is unavailable', 
 255             'url': 'http://www.the-voice-of-germany.de/video/31-andreas-kuemmert-rocket-man-clip', 
 259                 'title': 'Andreas Kümmert: Rocket Man', 
 260                 'description': 'md5:6ddb02b0781c6adf778afea606652e38', 
 261                 'upload_date': '20131017', 
 265                 'skip_download': True, 
 269             'url': 'http://www.fem.com/wellness/videos/wellness-video-clip-kurztripps-zum-valentinstag.html', 
 273                 'title': 'Kurztrips zum Valentinstag', 
 274                 'description': 'Romantischer Kurztrip zum Valentinstag? Nina Heinemann verrät, was sich hier wirklich lohnt.', 
 278                 'skip_download': True, 
 282             'url': 'http://www.prosieben.de/tv/joko-gegen-klaas/videos/playlists/episode-8-ganze-folge-playlist', 
 285                 'title': 'Episode 8 - Ganze Folge - Playlist', 
 286                 'description': 'md5:63b8963e71f481782aeea877658dec84', 
 289             'skip': 'This video is unavailable', 
 292             'url': 'http://www.7tv.de/circus-halligalli/615-best-of-circus-halligalli-ganze-folge', 
 296                 'title': 'Best of Circus HalliGalli', 
 297                 'description': 'md5:8849752efd90b9772c9db6fdf87fb9e9', 
 298                 'upload_date': '20151229', 
 301                 'skip_download': True, 
 305             # title in <h2 class="subtitle"> 
 306             'url': 'http://www.prosieben.de/stars/oscar-award/videos/jetzt-erst-enthuellt-das-geheimnis-von-emma-stones-oscar-robe-clip', 
 310                 'title': 'Jetzt erst enthüllt: Das Geheimnis von Emma Stones Oscar-Robe', 
 311                 'description': 'md5:e5ace2bc43fadf7b63adc6187e9450b9', 
 312                 'upload_date': '20170302', 
 315                 'skip_download': True, 
 317             'skip': 'geo restricted to Germany', 
 320             # geo restricted to Germany 
 321             'url': 'http://www.kabeleinsdoku.de/tv/mayday-alarm-im-cockpit/video/102-notlandung-im-hudson-river-ganze-folge', 
 322             'only_matching': True, 
 325             # geo restricted to Germany 
 326             'url': 'http://www.sat1gold.de/tv/edel-starck/video/11-staffel-1-episode-1-partner-wider-willen-ganze-folge', 
 327             'only_matching': True, 
 330             # geo restricted to Germany 
 331             'url': 'https://www.galileo.tv/video/diese-emojis-werden-oft-missverstanden', 
 332             'only_matching': True, 
 335             'url': 'http://www.sat1gold.de/tv/edel-starck/playlist/die-gesamte-1-staffel', 
 336             'only_matching': True, 
 339             'url': 'http://www.advopedia.de/videos/lenssen-klaert-auf/lenssen-klaert-auf-folge-8-staffel-3-feiertage-und-freie-tage', 
 340             'only_matching': True, 
 345     _SALT 
= '01!8d8F_)r9]4s[qeuXfP%' 
 346     _CLIENT_NAME 
= 'kolibri-2.0.19-splec4' 
 348         r
'"clip_id"\s*:\s+"(\d+)"', 
 351         r
'clip[iI][dD]\s*=\s*["\'](\d
+)', 
 352         r"'itemImageUrl
'\s*:\s*'/dynamic
/thumbnails
/full
/\d
+/(\d
+)", 
 353         r'proMamsId"\s*:\s*"(\d+)', 
 354         r'proMamsId"\s
*:\s
*"(\d+)', 
 357         r'<h2 class="subtitle
" itemprop="name
">\s*(.+?)</h2>', 
 358         r'<header class="clearfix
">\s*<h3>(.+?)</h3>', 
 359         r'<!-- start video -->\s*<h1>(.+?)</h1>', 
 360         r'<h1 class="att
-name
">\s*(.+?)</h1>', 
 361         r'<header class="module_header
">\s*<h2>([^<]+)</h2>\s*</header>', 
 362         r'<h2 class="video
-title
" itemprop="name
">\s*(.+?)</h2>', 
 363         r'<div[^>]+id="veeseoTitle
"[^>]*>(.+?)</div>', 
 364         r'<h2[^>]+class="subtitle
"[^>]*>([^<]+)</h2>', 
 366     _DESCRIPTION_REGEXES = [ 
 367         r'<p itemprop="description
">\s*(.+?)</p>', 
 368         r'<div class="videoDecription
">\s*<p><strong>Beschreibung</strong>: (.+?)</p>', 
 369         r'<div class="g
-plusone
" data-size="medium
"></div>\s*</div>\s*</header>\s*(.+?)\s*<footer>', 
 370         r'<p class="att
-description
">\s*(.+?)\s*</p>', 
 371         r'<p class="video
-description
" itemprop="description
">\s*(.+?)</p>', 
 372         r'<div[^>]+id="veeseoDescription
"[^>]*>(.+?)</div>', 
 374     _UPLOAD_DATE_REGEXES = [ 
 375         r'<meta property="og
:published_time
" content="(.+?
)">', 
 376         r'<span>\s*(\d{2}\.\d{2}\.\d{4} \d{2}:\d{2}) \|\s*<span itemprop="duration
"', 
 377         r'<footer>\s*(\d{2}\.\d{2}\.\d{4}) \d{2}:\d{2} Uhr', 
 378         r'<span style="padding
-left
: 4px
;line
-height
:20px
; color
:#404040">(\d{2}\.\d{2}\.\d{4})</span>', 
 379         r
'(\d{2}\.\d{2}\.\d{4}) \| \d{2}:\d{2} Min<br/>', 
 381     _PAGE_TYPE_REGEXES 
= [ 
 382         r
'<meta name="page_type" content="([^"]+)">', 
 383         r
"'itemType'\s*:\s*'([^']*)'", 
 385     _PLAYLIST_ID_REGEXES 
= [ 
 386         r
'content[iI]d=(\d+)', 
 387         r
"'itemId'\s*:\s*'([^']*)'", 
 389     _PLAYLIST_CLIP_REGEXES 
= [ 
 390         r
'(?s)data-qvt=.+?<a href="([^"]+)"', 
 393     def _extract_clip(self
, url
, webpage
): 
 394         clip_id 
= self
._html
_search
_regex
( 
 395             self
._CLIPID
_REGEXES
, webpage
, 'clip id') 
 396         title 
= self
._html
_search
_regex
( 
 397             self
._TITLE
_REGEXES
, webpage
, 'title', 
 398             default
=None) or self
._og
_search
_title
(webpage
) 
 399         info 
= self
._extract
_video
_info
(url
, clip_id
) 
 400         description 
= self
._html
_search
_regex
( 
 401             self
._DESCRIPTION
_REGEXES
, webpage
, 'description', default
=None) 
 402         if description 
is None: 
 403             description 
= self
._og
_search
_description
(webpage
) 
 404         thumbnail 
= self
._og
_search
_thumbnail
(webpage
) 
 405         upload_date 
= unified_strdate(self
._html
_search
_regex
( 
 406             self
._UPLOAD
_DATE
_REGEXES
, webpage
, 'upload date', default
=None)) 
 411             'description': description
, 
 412             'thumbnail': thumbnail
, 
 413             'upload_date': upload_date
, 
 417     def _extract_playlist(self
, url
, webpage
): 
 418         playlist_id 
= self
._html
_search
_regex
( 
 419             self
._PLAYLIST
_ID
_REGEXES
, webpage
, 'playlist id') 
 420         playlist 
= self
._parse
_json
( 
 422                 r
'var\s+contentResources\s*=\s*(\[.+?\]);\s*</script', 
 423                 webpage
, 'playlist'), 
 426         for item 
in playlist
: 
 427             clip_id 
= item
.get('id') or item
.get('upc') 
 430             info 
= self
._extract
_video
_info
(url
, clip_id
) 
 433                 'title': item
.get('title') or item
.get('teaser', {}).get('headline'), 
 434                 'description': item
.get('teaser', {}).get('description'), 
 435                 'thumbnail': item
.get('poster'), 
 436                 'duration': float_or_none(item
.get('duration')), 
 437                 'series': item
.get('tvShowTitle'), 
 438                 'uploader': item
.get('broadcastPublisher'), 
 441         return self
.playlist_result(entries
, playlist_id
) 
 443     def _real_extract(self
, url
): 
 444         video_id 
= self
._match
_id
(url
) 
 445         webpage 
= self
._download
_webpage
(url
, video_id
) 
 446         page_type 
= self
._search
_regex
( 
 447             self
._PAGE
_TYPE
_REGEXES
, webpage
, 
 448             'page type', default
='clip').lower() 
 449         if page_type 
== 'clip': 
 450             return self
._extract
_clip
(url
, webpage
) 
 451         elif page_type 
== 'playlist': 
 452             return self
._extract
_playlist
(url
, webpage
) 
 454             raise ExtractorError( 
 455                 'Unsupported page type %s' % page_type
, expected
=True)