]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/r7.py
976c8feec657f8de731d3ffadfa09189ed1628cf
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
12 class R7IE(InfoExtractor
):
13 _VALID_URL
= r
'''(?x)https?://
15 (?:[a-zA-Z]+)\.r7\.com(?:/[^/]+)+/idmedia/|
16 noticias\.r7\.com(?:/[^/]+)+/[^/]+-|
17 player\.r7\.com/video/i/
22 'url': 'http://videos.r7.com/policiais-humilham-suspeito-a-beira-da-morte-morre-com-dignidade-/idmedia/54e7050b0cf2ff57e0279389.html',
23 'md5': '403c4e393617e8e8ddc748978ee8efde',
25 'id': '54e7050b0cf2ff57e0279389',
27 'title': 'Policiais humilham suspeito à beira da morte: "Morre com dignidade"',
28 'thumbnail': 're:^https?://.*\.jpg$',
34 'url': 'http://esportes.r7.com/videos/cigano-manda-recado-aos-fas/idmedia/4e176727b51a048ee6646a1b.html',
35 'only_matching': True,
37 'url': 'http://noticias.r7.com/record-news/video/representante-do-instituto-sou-da-paz-fala-sobre-fim-do-estatuto-do-desarmamento-5480fc580cf2285b117f438d/',
38 'only_matching': True,
40 'url': 'http://player.r7.com/video/i/54e7050b0cf2ff57e0279389?play=true&video=http://vsh.r7.com/54e7050b0cf2ff57e0279389/ER7_RE_BG_MORTE_JOVENS_570kbps_2015-02-2009f17818-cc82-4c8f-86dc-89a66934e633-ATOS_copy.mp4&linkCallback=http://videos.r7.com/policiais-humilham-suspeito-a-beira-da-morte-morre-com-dignidade-/idmedia/54e7050b0cf2ff57e0279389.html&thumbnail=http://vtb.r7.com/ER7_RE_BG_MORTE_JOVENS_570kbps_2015-02-2009f17818-cc82-4c8f-86dc-89a66934e633-thumb.jpg&idCategory=192&share=true&layout=full&full=true',
41 'only_matching': True,
44 def _real_extract(self
, url
):
45 video_id
= self
._match
_id
(url
)
47 webpage
= self
._download
_webpage
(
48 'http://player.r7.com/video/i/%s' % video_id
, video_id
)
50 item
= self
._parse
_json
(js_to_json(self
._search
_regex
(
51 r
'(?s)var\s+item\s*=\s*({.+?});', webpage
, 'player')), video_id
)
53 title
= unescapeHTML(item
['title'])
54 thumbnail
= item
.get('init', {}).get('thumbUri')
57 statistics
= item
.get('statistics', {})
58 like_count
= int_or_none(statistics
.get('likes'))
59 view_count
= int_or_none(statistics
.get('views'))
62 for format_key
, format_dict
in item
['playlist'][0].items():
63 src
= format_dict
.get('src')
66 format_id
= format_dict
.get('format') or format_key
68 duration
= format_dict
.get('duration')
70 formats
.extend(self
._extract
_f
4m
_formats
(src
, video_id
, preference
=-1))
71 elif src
.endswith('.m3u8'):
72 formats
.extend(self
._extract
_m
3u8_formats
(src
, video_id
, 'mp4', preference
=-2))
76 'format_id': format_id
,
78 self
._sort
_formats
(formats
)
83 'thumbnail': thumbnail
,
85 'like_count': like_count
,
86 'view_count': view_count
,