]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/metacritic.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
11 class MetacriticIE(InfoExtractor
):
12 _VALID_URL
= r
'https?://www\.metacritic\.com/.+?/trailers/(?P<id>\d+)'
15 'url': 'http://www.metacritic.com/game/playstation-4/infamous-second-son/trailers/3698222',
16 'file': '3698222.mp4',
18 'title': 'inFamous: Second Son - inSide Sucker Punch: Smoke & Mirrors',
19 'description': 'Take a peak behind-the-scenes to see how Sucker Punch brings smoke into the universe of inFAMOUS Second Son on the PS4.',
24 def _real_extract(self
, url
):
25 mobj
= re
.match(self
._VALID
_URL
, url
)
26 video_id
= mobj
.group('id')
27 webpage
= self
._download
_webpage
(url
, video_id
)
28 # The xml is not well formatted, there are raw '&'
29 info
= self
._download
_xml
('http://www.metacritic.com/video_data?video=' + video_id
,
30 video_id
, 'Downloading info xml', transform_source
=fix_xml_ampersands
)
32 clip
= next(c
for c
in info
.findall('playList/clip') if c
.find('id').text
== video_id
)
34 for videoFile
in clip
.findall('httpURI/videoFile'):
35 rate_str
= videoFile
.find('rate').text
36 video_url
= videoFile
.find('filePath').text
40 'format_id': rate_str
,
43 self
._sort
_formats
(formats
)
45 description
= self
._html
_search
_regex
(r
'<b>Description:</b>(.*?)</p>',
46 webpage
, 'description', flags
=re
.DOTALL
)
50 'title': clip
.find('title').text
,
52 'description': description
,
53 'duration': int(clip
.find('duration').text
),