]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rtp.py
82b323cdd4e40b027d3a6c2c06e9ea9d58b171e2
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
9 class RTPIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:www\.)?rtp\.pt/play/p(?P<program_id>[0-9]+)/(?P<id>[^/?#]+)/?'
12 'url': 'http://www.rtp.pt/play/p405/e174042/paixoes-cruzadas',
13 'md5': 'e736ce0c665e459ddb818546220b4ef8',
17 'title': 'Paixões Cruzadas',
18 'description': 'As paixões musicais de António Cartaxo e António Macedo',
19 'thumbnail': 're:^https?://.*\.jpg',
23 'skip_download': True,
26 'url': 'http://www.rtp.pt/play/p831/a-quimica-das-coisas',
27 'only_matching': True,
30 def _real_extract(self
, url
):
31 video_id
= self
._match
_id
(url
)
33 webpage
= self
._download
_webpage
(url
, video_id
)
34 title
= self
._html
_search
_meta
(
35 'twitter:title', webpage
, display_name
='title', fatal
=True)
36 description
= self
._html
_search
_meta
('description', webpage
)
37 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
39 player_config
= self
._search
_regex
(
40 r
'(?s)RTPPLAY\.player\.newPlayer\(\s*(\{.*?\})\s*\)', webpage
, 'player config')
41 config
= self
._parse
_json
(player_config
, video_id
)
43 path
, ext
= config
.get('file').rsplit('.', 1)
47 'vcodec': config
.get('type') == 'audio' and 'none' or None,
49 'url': 'rtmp://{streamer:s}/{application:s}'.format(**config
),
50 'app': config
.get('application'),
51 'play_path': '{ext:s}:{path:s}'.format(ext
=ext
, path
=path
),
53 'rtmp_live': config
.get('live', False),
54 'player_url': 'http://programas.rtp.pt/play/player.swf?v3',
55 'rtmp_real_time': True,
58 # Construct regular HTTP download URLs
62 'pattern': r
'^nas2\.share/wavrss/',
63 'repl': 'http://rsspod.rtp.pt/podcasts/',
67 'format_id': 'mp4_h264',
68 'pattern': r
'^nas2\.share/h264/',
69 'repl': 'http://rsspod.rtp.pt/videocasts/',
73 r
= replacements
[config
['type']]
74 if re
.match(r
['pattern'], config
['file']) is not None:
76 'format_id': r
['format_id'],
77 'url': re
.sub(r
['pattern'], r
['repl'], config
['file']),
78 'vcodec': r
['vcodec'],
81 self
._sort
_formats
(formats
)
87 'description': description
,
88 'thumbnail': thumbnail
,