]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/escapist.py
1 from __future__
import unicode_literals
5 from . common
import InfoExtractor
6 from .. compat
import compat_urllib_request
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' : 'c6793dbda81388f4264c1ba18684a74d' ,
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$' ,
52 'url' : 'http://www.escapistmagazine.com/videos/view/zero-punctuation/10044-Evolve-One-vs-Multiplayer' ,
53 'md5' : 'cf8842a8a46444d241f9a9980d7874f2' ,
57 'description' : 'This week, Zero Punctuation reviews Evolve.' ,
58 'title' : 'Evolve - One vs Multiplayer' ,
59 'thumbnail' : 're:^https?://.*\.jpg$' ,
64 def _real_extract ( self
, url
):
65 video_id
= self
._ match
_ id
( url
)
66 webpage
= self
._ download
_ webpage
( url
, video_id
)
68 imsVideo
= self
._ parse
_ json
(
70 r
'imsVideo\.play\(( {.+?} )\);' , webpage
, 'imsVideo' ),
72 video_id
= imsVideo
[ 'videoID' ]
73 key
= imsVideo
[ 'hash' ]
75 quality
= qualities ([ 'lq' , 'hq' , 'hd' ])
78 for q
in [ 'lq' , 'hq' , 'hd' ]:
79 config_req
= compat_urllib_request
. Request (
80 'http://www.escapistmagazine.com/videos/'
81 'vidconfig.php?videoID= %s &hash= %s &quality= %s ' % ( video_id
, key
, 'mp4_' + q
))
82 config_req
. add_header ( 'Referer' , url
)
83 config
= self
._ download
_ webpage
( config_req
, video_id
, 'Downloading video config ' + q
. upper ())
85 data
= json
. loads ( _decrypt_config ( key
, config
))
87 title
= clean_html ( data
[ 'videoData' ][ 'title' ])
88 duration
= data
[ 'videoData' ][ 'duration' ] / 1000
90 for i
, v
in enumerate ( data
[ 'files' ][ 'videos' ]):
94 'format_id' : determine_ext ( v
) + '_' + q
+ str ( i
),
95 'quality' : quality ( q
),
102 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
),
103 'description' : self
._ og
_ search
_ description
( webpage
),
104 'duration' : duration
,