]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/uol.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
  14 class UOLIE(InfoExtractor
): 
  15     IE_NAME 
= 'uol.com.br' 
  16     _VALID_URL 
= r
'https?://(?:.+?\.)?uol\.com\.br/.*?(?:(?:mediaId|v)=|view/(?:[a-z0-9]+/)?|video(?:=|/(?:\d{4}/\d{2}/\d{2}/)?))(?P<id>\d+|[\w-]+-[A-Z0-9]+)' 
  18         'url': 'http://player.mais.uol.com.br/player_video_v3.swf?mediaId=15951931', 
  19         'md5': '25291da27dc45e0afb5718a8603d3816', 
  23             'title': 'Miss simpatia é encontrada morta', 
  24             'description': 'md5:3f8c11a0c0556d66daf7e5b45ef823b2', 
  27         'url': 'http://tvuol.uol.com.br/video/incendio-destroi-uma-das-maiores-casas-noturnas-de-londres-04024E9A3268D4C95326', 
  28         'md5': 'e41a2fb7b7398a3a46b6af37b15c00c9', 
  32             'title': 'Incêndio destrói uma das maiores casas noturnas de Londres', 
  33             'description': 'Em Londres, um incêndio destruiu uma das maiores boates da cidade. Não há informações sobre vítimas.', 
  36         'url': 'http://mais.uol.com.br/static/uolplayer/index.html?mediaId=15951931', 
  37         'only_matching': True, 
  39         'url': 'http://mais.uol.com.br/view/15954259', 
  40         'only_matching': True, 
  42         'url': 'http://noticias.band.uol.com.br/brasilurgente/video/2016/08/05/15951931/miss-simpatia-e-encontrada-morta.html', 
  43         'only_matching': True, 
  45         'url': 'http://videos.band.uol.com.br/programa.asp?e=noticias&pr=brasil-urgente&v=15951931&t=Policia-desmonte-base-do-PCC-na-Cracolandia', 
  46         'only_matching': True, 
  48         'url': 'http://mais.uol.com.br/view/cphaa0gl2x8r/incendio-destroi-uma-das-maiores-casas-noturnas-de-londres-04024E9A3268D4C95326', 
  49         'only_matching': True, 
  51         'url': 'http://noticias.uol.com.br//videos/assistir.htm?video=rafaela-silva-inspira-criancas-no-judo-04024D983968D4C95326', 
  52         'only_matching': True, 
  54         'url': 'http://mais.uol.com.br/view/e0qbgxid79uv/15275470', 
  55         'only_matching': True, 
  89     def _real_extract(self
, url
): 
  90         video_id 
= self
._match
_id
(url
) 
  93         if video_id
.isdigit(): 
  97             embed_page 
= self
._download
_webpage
( 
  98                 'https://jsuol.com.br/c/tv/uol/embed/?params=[embed,%s]' % video_id
, 
  99                 video_id
, 'Downloading embed page', fatal
=False) 
 101                 media_id 
= self
._search
_regex
( 
 102                     (r
'uol\.com\.br/(\d+)', r
'mediaId=(\d+)'), 
 103                     embed_page
, 'media id', default
=None) 
 106             webpage 
= self
._download
_webpage
(url
, video_id
) 
 107             media_id 
= self
._search
_regex
(r
'mediaId=(\d+)', webpage
, 'media id') 
 109         video_data 
= self
._download
_json
( 
 110             'http://mais.uol.com.br/apiuol/v3/player/getMedia/%s.json' % media_id
, 
 112         title 
= video_data
['title'] 
 115             'ver': video_data
.get('numRevision', 2), 
 116             'r': 'http://mais.uol.com.br', 
 118         for k 
in ('token', 'sign'): 
 119             v 
= video_data
.get(k
) 
 124         for f 
in video_data
.get('formats', []): 
 125             f_url 
= f
.get('url') or f
.get('secureUrl') 
 128             f_url 
= update_url_query(f_url
, query
) 
 129             format_id 
= str_or_none(f
.get('id')) 
 130             if format_id 
== '10': 
 131                 formats
.extend(self
._extract
_m
3u8_formats
( 
 132                     f_url
, video_id
, 'mp4', 'm3u8_native', 
 133                     m3u8_id
='hls', fatal
=False)) 
 136                 'format_id': format_id
, 
 138                 'source_preference': 1, 
 140             fmt
.update(self
._FORMATS
.get(format_id
, {})) 
 142         self
._sort
_formats
(formats
, ('height', 'width', 'source_preference', 'tbr', 'ext')) 
 145         for tag 
in video_data
.get('tags', []): 
 146             tag_description 
= tag
.get('description') 
 147             if not tag_description
: 
 149             tags
.append(tag_description
) 
 154             'description': clean_html(video_data
.get('desMedia')), 
 155             'thumbnail': video_data
.get('thumbnail'), 
 156             'duration': int_or_none(video_data
.get('durationSeconds')) or parse_duration(video_data
.get('duration')),