3 from .common
import InfoExtractor
9 class MetacriticIE(InfoExtractor
):
10 _VALID_URL
= r
'https?://(?:www\.)?metacritic\.com/.+?/trailers/(?P<id>\d+)'
13 'url': 'http://www.metacritic.com/game/playstation-4/infamous-second-son/trailers/3698222',
17 'title': 'inFamous: Second Son - inSide Sucker Punch: Smoke & Mirrors',
18 'description': 'Take a peak behind-the-scenes to see how Sucker Punch brings smoke into the universe of inFAMOUS Second Son on the PS4.',
21 'skip': 'Not providing trailers anymore',
23 'url': 'http://www.metacritic.com/game/playstation-4/tales-from-the-borderlands-a-telltale-game-series/trailers/5740315',
27 'title': 'Tales from the Borderlands - Finale: The Vault of the Traveler',
28 'description': 'In the final episode of the season, all hell breaks loose. Jack is now in control of Helios\' systems, and he\'s ready to reclaim his rightful place as king of Hyperion (with or without you).',
33 def _real_extract(self
, url
):
34 mobj
= self
._match
_valid
_url
(url
)
35 video_id
= mobj
.group('id')
36 webpage
= self
._download
_webpage
(url
, video_id
)
37 # The xml is not well formatted, there are raw '&'
38 info
= self
._download
_xml
('http://www.metacritic.com/video_data?video=' + video_id
,
39 video_id
, 'Downloading info xml', transform_source
=fix_xml_ampersands
)
41 clip
= next(c
for c
in info
.findall('playList/clip') if c
.find('id').text
== video_id
)
43 for video_file
in clip
.findall('httpURI/videoFile'):
44 rate_str
= video_file
.find('rate').text
45 video_url
= video_file
.find('filePath').text
49 'format_id': rate_str
,
53 description
= self
._html
_search
_regex
(r
'<b>Description:</b>(.*?)</p>',
54 webpage
, 'description', flags
=re
.DOTALL
)
58 'title': clip
.find('title').text
,
60 'description': description
,
61 'duration': int(clip
.find('duration').text
),