]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rtp.py
7736cabbac6b855be739b8c7521a073ea630f32f
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..utils
import js_to_json
10 class RTPIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?rtp\.pt/play/p(?P<program_id>[0-9]+)/(?P<id>[^/?#]+)/?'
13 'url': 'http://www.rtp.pt/play/p405/e174042/paixoes-cruzadas',
17 'title': 'Paixões Cruzadas',
18 'description': 'As paixões musicais de António Cartaxo e António Macedo',
19 'thumbnail': 're:^https?://.*\.jpg',
22 'skip_download': True, # RTMP download
25 'url': 'http://www.rtp.pt/play/p831/a-quimica-das-coisas',
26 'only_matching': True,
29 def _real_extract(self
, url
):
30 video_id
= self
._match
_id
(url
)
32 webpage
= self
._download
_webpage
(url
, video_id
)
33 title
= self
._html
_search
_meta
(
34 'twitter:title', webpage
, display_name
='title', fatal
=True)
35 description
= self
._html
_search
_meta
('description', webpage
)
36 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
38 player_config
= self
._search
_regex
(
39 r
'(?s)RTPPLAY\.player\.newPlayer\(\s*(\{.*?\})\s*\)', webpage
, 'player config')
40 config
= json
.loads(js_to_json(player_config
))
42 path
, ext
= config
.get('file').rsplit('.', 1)
44 'app': config
.get('application'),
45 'play_path': '{ext:s}:{path:s}'.format(ext
=ext
, path
=path
),
47 'url': 'rtmp://{streamer:s}/{application:s}'.format(**config
),
48 'rtmp_live': config
.get('live', False),
50 'vcodec': config
.get('type') == 'audio' and 'none' or None,
51 'player_url': 'http://programas.rtp.pt/play/player.swf?v3',
58 'description': description
,
59 'thumbnail': thumbnail
,