]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rtl2.py
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
   7 from ..aes 
import aes_cbc_decrypt
 
  22 class RTL2IE(InfoExtractor
): 
  24     _VALID_URL 
= r
'https?://(?:www\.)?rtl2\.de/sendung/[^/]+/(?:video/(?P<vico_id>\d+)[^/]+/(?P<vivi_id>\d+)-|folge/)(?P<id>[^/?#]+)' 
  26         'url': 'http://www.rtl2.de/sendung/grip-das-motormagazin/folge/folge-203-0', 
  30             'title': 'GRIP sucht den Sommerkönig', 
  31             'description': 'md5:e3adbb940fd3c6e76fa341b8748b562f' 
  35             'skip_download': True, 
  37         'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'], 
  39         'url': 'http://www.rtl2.de/sendung/koeln-50667/video/5512-anna/21040-anna-erwischt-alex/', 
  41             'id': 'anna-erwischt-alex', 
  43             'title': 'Anna erwischt Alex!', 
  44             'description': 'Anna nimmt ihrem Vater nicht ab, dass er nicht spielt. Und tatsächlich erwischt sie ihn auf frischer Tat.' 
  48             'skip_download': True, 
  50         'expected_warnings': ['Unable to download f4m manifest', 'Failed to download m3u8 information'], 
  53     def _real_extract(self
, url
): 
  54         vico_id
, vivi_id
, display_id 
= re
.match(self
._VALID
_URL
, url
).groups() 
  56             webpage 
= self
._download
_webpage
(url
, display_id
) 
  59                 r
'data-collection="(?P<vico_id>\d+)"[^>]+data-video="(?P<vivi_id>\d+)"', 
  62                 vico_id 
= mobj
.group('vico_id') 
  63                 vivi_id 
= mobj
.group('vivi_id') 
  65                 vico_id 
= self
._html
_search
_regex
( 
  66                     r
'vico_id\s*:\s*([0-9]+)', webpage
, 'vico_id') 
  67                 vivi_id 
= self
._html
_search
_regex
( 
  68                     r
'vivi_id\s*:\s*([0-9]+)', webpage
, 'vivi_id') 
  70         info 
= self
._download
_json
( 
  71             'https://service.rtl2.de/api-player-vipo/video.php', 
  76         video_info 
= info
['video'] 
  77         title 
= video_info
['titel'] 
  81         rtmp_url 
= video_info
.get('streamurl') 
  83             rtmp_url 
= rtmp_url
.replace('\\', '') 
  84             stream_url 
= 'mp4:' + self
._html
_search
_regex
(r
'/ondemand/(.+)', rtmp_url
, 'stream URL') 
  85             rtmp_conn 
= ['S:connect', 'O:1', 'NS:pageUrl:' + url
, 'NB:fpad:0', 'NN:videoFunction:1', 'O:0'] 
  90                 'play_path': stream_url
, 
  91                 'player_url': 'https://www.rtl2.de/sites/default/modules/rtl2/jwplayer/jwplayer-7.6.0/jwplayer.flash.swf', 
  93                 'flash_version': 'LNX 11,2,202,429', 
  94                 'rtmp_conn': rtmp_conn
, 
  99         m3u8_url 
= video_info
.get('streamurl_hls') 
 101             formats
.extend(self
._extract
_akamai
_formats
(m3u8_url
, display_id
)) 
 103         self
._sort
_formats
(formats
) 
 108             'thumbnail': video_info
.get('image'), 
 109             'description': video_info
.get('beschreibung'), 
 110             'duration': int_or_none(video_info
.get('duration')), 
 115 class RTL2YouBaseIE(InfoExtractor
): 
 116     _BACKWERK_BASE_URL 
= 'https://p-you-backwerk.rtl2apps.de/' 
 119 class RTL2YouIE(RTL2YouBaseIE
): 
 121     _VALID_URL 
= r
'http?://you\.rtl2\.de/(?:video/\d+/|youplayer/index\.html\?.*?\bvid=)(?P<id>\d+)' 
 123         'url': 'http://you.rtl2.de/video/3002/15740/MJUNIK%20%E2%80%93%20Home%20of%20YOU/307-hirn-wo-bist-du', 
 127             'title': 'MJUNIK – Home of YOU - #307 Hirn, wo bist du?!', 
 128             'description': 'md5:ddaa95c61b372b12b66e115b2772fe01', 
 132         'url': 'http://you.rtl2.de/youplayer/index.html?vid=15712', 
 133         'only_matching': True, 
 135     _AES_KEY 
= b
'\xe9W\xe4.<*\xb8\x1a\xd2\xb6\x92\xf3C\xd3\xefL\x1b\x03*\xbbbH\xc0\x03\xffo\xc2\xf2(\xaa\xaa!' 
 136     _GEO_COUNTRIES 
= ['DE'] 
 138     def _real_extract(self
, url
): 
 139         video_id 
= self
._match
_id
(url
) 
 141         stream_data 
= self
._download
_json
( 
 142             self
._BACKWERK
_BASE
_URL 
+ 'stream/video/' + video_id
, video_id
) 
 144         data
, iv 
= compat_b64decode(stream_data
['streamUrl']).decode().split(':') 
 145         stream_url 
= intlist_to_bytes(aes_cbc_decrypt( 
 146             bytes_to_intlist(compat_b64decode(data
)), 
 147             bytes_to_intlist(self
._AES
_KEY
), 
 148             bytes_to_intlist(compat_b64decode(iv
)) 
 150         if b
'rtl2_you_video_not_found' in stream_url
: 
 151             raise ExtractorError('video not found', expected
=True) 
 153         formats 
= self
._extract
_m
3u8_formats
( 
 154             stream_url
[:-compat_ord(stream_url
[-1])].decode(), 
 155             video_id
, 'mp4', 'm3u8_native') 
 156         self
._sort
_formats
(formats
) 
 158         video_data 
= self
._download
_json
( 
 159             self
._BACKWERK
_BASE
_URL 
+ 'video/' + video_id
, video_id
) 
 161         series 
= video_data
.get('formatTitle') 
 162         title 
= episode 
= video_data
.get('title') or series
 
 163         if series 
and series 
!= title
: 
 164             title 
= '%s - %s' % (series
, title
) 
 170             'description': strip_or_none(video_data
.get('description')), 
 171             'thumbnail': video_data
.get('image'), 
 172             'duration': int_or_none(stream_data
.get('duration') or video_data
.get('duration'), 1000), 
 175             'age_limit': int_or_none(video_data
.get('minimumAge')), 
 179 class RTL2YouSeriesIE(RTL2YouBaseIE
): 
 180     IE_NAME 
= 'rtl2:you:series' 
 181     _VALID_URL 
= r
'http?://you\.rtl2\.de/videos/(?P<id>\d+)' 
 183         'url': 'http://you.rtl2.de/videos/115/dragon-ball', 
 187         'playlist_mincount': 5, 
 190     def _real_extract(self
, url
): 
 191         series_id 
= self
._match
_id
(url
) 
 192         stream_data 
= self
._download
_json
( 
 193             self
._BACKWERK
_BASE
_URL 
+ 'videos', 
 195                 'formatId': series_id
, 
 200         for video 
in stream_data
.get('videos', []): 
 201             video_id 
= compat_str(video
['videoId']) 
 204             entries
.append(self
.url_result( 
 205                 'http://you.rtl2.de/video/%s/%s' % (series_id
, video_id
), 
 206                 'RTL2You', video_id
)) 
 207         return self
.playlist_result(entries
, series_id
)