]>
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, 
  85     def _real_extract(self
, url
): 
  86         video_id 
= self
._match
_id
(url
) 
  89         if video_id
.isdigit(): 
  93             embed_page 
= self
._download
_webpage
( 
  94                 'https://jsuol.com.br/c/tv/uol/embed/?params=[embed,%s]' % video_id
, 
  95                 video_id
, 'Downloading embed page', fatal
=False) 
  97                 media_id 
= self
._search
_regex
( 
  98                     (r
'uol\.com\.br/(\d+)', r
'mediaId=(\d+)'), 
  99                     embed_page
, 'media id', default
=None) 
 102             webpage 
= self
._download
_webpage
(url
, video_id
) 
 103             media_id 
= self
._search
_regex
(r
'mediaId=(\d+)', webpage
, 'media id') 
 105         video_data 
= self
._download
_json
( 
 106             'http://mais.uol.com.br/apiuol/v3/player/getMedia/%s.json' % media_id
, 
 108         title 
= video_data
['title'] 
 111             'ver': video_data
.get('numRevision', 2), 
 112             'r': 'http://mais.uol.com.br', 
 115         for f 
in video_data
.get('formats', []): 
 116             f_url 
= f
.get('url') or f
.get('secureUrl') 
 119             format_id 
= str_or_none(f
.get('id')) 
 121                 'format_id': format_id
, 
 122                 'url': update_url_query(f_url
, query
), 
 124             fmt
.update(self
._FORMATS
.get(format_id
, {})) 
 126         self
._sort
_formats
(formats
) 
 129         for tag 
in video_data
.get('tags', []): 
 130             tag_description 
= tag
.get('description') 
 131             if not tag_description
: 
 133             tags
.append(tag_description
) 
 138             'description': clean_html(video_data
.get('desMedia')), 
 139             'thumbnail': video_data
.get('thumbnail'), 
 140             'duration': int_or_none(video_data
.get('durationSeconds')) or parse_duration(video_data
.get('duration')),