]>
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' ,
19 'title' : 'inFamous: Second Son - inSide Sucker Punch: Smoke & Mirrors' ,
20 'description' : 'Take a peak behind-the-scenes to see how Sucker Punch brings smoke into the universe of inFAMOUS Second Son on the PS4.' ,
23 'skip' : 'Not providing trailers anymore' ,
25 'url' : 'http://www.metacritic.com/game/playstation-4/tales-from-the-borderlands-a-telltale-game-series/trailers/5740315' ,
29 'title' : 'Tales from the Borderlands - Finale: The Vault of the Traveler' ,
30 '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).' ,
35 def _real_extract ( self
, url
):
36 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
37 video_id
= mobj
. group ( 'id' )
38 webpage
= self
._ download
_ webpage
( url
, video_id
)
39 # The xml is not well formatted, there are raw '&'
40 info
= self
._ download
_ xml
( 'http://www.metacritic.com/video_data?video=' + video_id
,
41 video_id
, 'Downloading info xml' , transform_source
= fix_xml_ampersands
)
43 clip
= next ( c
for c
in info
. findall ( 'playList/clip' ) if c
. find ( 'id' ). text
== video_id
)
45 for videoFile
in clip
. findall ( 'httpURI/videoFile' ):
46 rate_str
= videoFile
. find ( 'rate' ). text
47 video_url
= videoFile
. find ( 'filePath' ). text
51 'format_id' : rate_str
,
54 self
._ sort
_ formats
( formats
)
56 description
= self
._ html
_ search
_ regex
( r
'<b>Description:</b>(.*?)</p>' ,
57 webpage
, 'description' , flags
= re
. DOTALL
)
61 'title' : clip
. find ( 'title' ). text
,
63 'description' : description
,
64 'duration' : int ( clip
. find ( 'duration' ). text
),