]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/escapist.py
a3d7bbbcb3f45a4c098397d0622fc59324412fcc
1 from __future__
import unicode_literals
5 from . common
import InfoExtractor
15 def _decrypt_config ( key
, string
):
20 while len ( a
) < ( len ( string
) / 2 ):
23 a
= a
[ 0 : int ( len ( string
) / 2 )]
26 while t
< len ( string
):
27 i
+= chr ( int ( string
[ t
] + string
[ t
+ 1 ], 16 ))
32 for t
, c
in enumerate ( a
):
33 r
+= chr ( ord ( c
) ^
ord ( icko
[ t
]))
38 class EscapistIE ( InfoExtractor
):
39 _VALID_URL
= r
'https?://?(?:www\.)?escapistmagazine\.com/videos/view/[^/?#]+/(?P<id>[0-9]+)-[^/?#]*(?:$|[?#])'
41 'url' : 'http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate' ,
42 'md5' : 'ab3a706c681efca53f0a35f1415cf0d1' ,
46 'description' : "Baldur's Gate: Original, Modded or Enhanced Edition? I'll break down what you can expect from the new Baldur's Gate: Enhanced Edition." ,
47 'title' : "Breaking Down Baldur's Gate" ,
48 'thumbnail' : 're:^https?://.*\.jpg$' ,
50 'uploader' : 'The Escapist' ,
53 'url' : 'http://www.escapistmagazine.com/videos/view/zero-punctuation/10044-Evolve-One-vs-Multiplayer' ,
54 'md5' : '9e8c437b0dbb0387d3bd3255ca77f6bf' ,
58 'description' : 'This week, Zero Punctuation reviews Evolve.' ,
59 'title' : 'Evolve - One vs Multiplayer' ,
60 'thumbnail' : 're:^https?://.*\.jpg$' ,
62 'uploader' : 'The Escapist' ,
66 def _real_extract ( self
, url
):
67 video_id
= self
._ match
_ id
( url
)
68 webpage
= self
._ download
_ webpage
( url
, video_id
)
70 ims_video
= self
._ parse
_ json
(
72 r
'imsVideo\.play\(({.+?})\);' , webpage
, 'imsVideo' ),
74 video_id
= ims_video
[ 'videoID' ]
75 key
= ims_video
[ 'hash' ]
77 config_req
= sanitized_Request (
78 'http://www.escapistmagazine.com/videos/'
79 'vidconfig.php?videoID= %s &hash= %s ' % ( video_id
, key
))
80 config_req
. add_header ( 'Referer' , url
)
81 config
= self
._ download
_ webpage
( config_req
, video_id
, 'Downloading video config' )
83 data
= json
. loads ( _decrypt_config ( key
, config
))
85 video_data
= data
[ 'videoData' ]
87 title
= clean_html ( video_data
[ 'title' ])
88 duration
= float_or_none ( video_data
. get ( 'duration' ), 1000 )
89 uploader
= video_data
. get ( 'publisher' )
93 'format_id' : ' %s-%s p' % ( determine_ext ( video
[ 'src' ]), video
[ 'res' ]),
94 'height' : int_or_none ( video
. get ( 'res' )),
95 } for video
in data
[ 'files' ][ 'videos' ]]
96 self
._ sort
_ formats
( formats
)
102 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
),
103 'description' : self
._ og
_ search
_ description
( webpage
),
104 'duration' : duration
,
105 'uploader' : uploader
,