]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rtp.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  11 class RTPIE(InfoExtractor
): 
  12     _VALID_URL 
= r
'https?://(?:www\.)?rtp\.pt/play/p(?P<program_id>[0-9]+)/(?P<id>[^/?#]+)/?' 
  14         'url': 'http://www.rtp.pt/play/p405/e174042/paixoes-cruzadas', 
  15         'md5': 'e736ce0c665e459ddb818546220b4ef8', 
  19             'title': 'Paixões Cruzadas', 
  20             'description': 'As paixões musicais de António Cartaxo e António Macedo', 
  21             'thumbnail': r
're:^https?://.*\.jpg', 
  24         'url': 'http://www.rtp.pt/play/p831/a-quimica-das-coisas', 
  25         'only_matching': True, 
  28     def _real_extract(self
, url
): 
  29         video_id 
= self
._match
_id
(url
) 
  31         webpage 
= self
._download
_webpage
(url
, video_id
) 
  32         title 
= self
._html
_search
_meta
( 
  33             'twitter:title', webpage
, display_name
='title', fatal
=True) 
  35         config 
= self
._parse
_json
(self
._search
_regex
( 
  36             r
'(?s)RTPPlayer\(({.+?})\);', webpage
, 
  37             'player config'), video_id
, js_to_json
) 
  38         file_url 
= config
['file'] 
  39         ext 
= determine_ext(file_url
) 
  41             file_key 
= config
.get('fileKey') 
  42             formats 
= self
._extract
_m
3u8_formats
( 
  43                 file_url
, video_id
, 'mp4', 'm3u8_native', 
  44                 m3u8_id
='hls', fatal
=file_key
) 
  47                     'url': 'https://cdn-ondemand.rtp.pt' + file_key
, 
  50             self
._sort
_formats
(formats
) 
  56         if config
.get('mediaType') == 'audio': 
  64             'description': self
._html
_search
_meta
(['description', 'twitter:description'], webpage
), 
  65             'thumbnail': config
.get('poster') or self
._og
_search
_thumbnail
(webpage
),