]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/escapist.py
b1242f6bc457a41a9c8413eb851671acd05cc8c0
4 from . common
import InfoExtractor
13 class EscapistIE ( InfoExtractor
):
14 _VALID_URL
= r
'^https?://?(www\.)?escapistmagazine\.com/videos/view/(?P<showname>[^/]+)/(?P<episode>[^/?]+)[/?]?.*$'
16 u
'url' : u
'http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate' ,
17 u
'file' : u
'6618-Breaking-Down-Baldurs-Gate.mp4' ,
18 u
'md5' : u
'ab3a706c681efca53f0a35f1415cf0d1' ,
20 u
"description" : u
"Baldur's Gate: Original, Modded or Enhanced Edition? I'll break down what you can expect from the new Baldur's Gate: Enhanced Edition." ,
21 u
"uploader" : u
"the-escapist-presents" ,
22 u
"title" : u
"Breaking Down Baldur's Gate"
26 def _real_extract ( self
, url
):
27 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
28 showName
= mobj
. group ( 'showname' )
29 videoId
= mobj
. group ( 'episode' )
31 self
. report_extraction ( videoId
)
32 webpage
= self
._ download
_ webpage
( url
, videoId
)
34 videoDesc
= self
._ html
_ search
_ regex
(
35 r
'<meta name="description" content="([^"]*)"' ,
36 webpage
, u
'description' , fatal
= False )
38 playerUrl
= self
._ og
_ search
_ video
_u rl
( webpage
, name
= u
'player URL' )
40 title
= self
._ html
_ search
_ regex
(
41 r
'<meta name="title" content="([^"]*)"' ,
42 webpage
, u
'title' ). split ( ' : ' )[- 1 ]
44 configUrl
= self
._ search
_ regex
( 'config=(.*)$' , playerUrl
, u
'config URL' )
45 configUrl
= compat_urllib_parse
. unquote ( configUrl
)
49 def _add_format ( name
, cfgurl
):
50 configJSON
= self
._ download
_ webpage
(
52 u
'Downloading ' + name
+ ' configuration' ,
53 u
'Unable to download ' + name
+ ' configuration' )
55 # Technically, it's JavaScript, not JSON
56 configJSON
= configJSON
. replace ( "'" , '"' )
59 config
= json
. loads ( configJSON
)
60 except ( ValueError ,) as err
:
61 raise ExtractorError ( u
'Invalid JSON in configuration file: ' + compat_str ( err
))
62 playlist
= config
[ 'playlist' ]
64 'url' : playlist
[ 1 ][ 'url' ],
68 _add_format ( u
'normal' , configUrl
)
70 ( '&hq=1' if '?' in configUrl
else configUrl
+ '?hq=1' ))
72 _add_format ( u
'hq' , hq_url
)
73 except ExtractorError
:
74 pass # That's fine, we'll just use normal quality
81 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
),
82 'description' : videoDesc
,
83 'player_url' : playerUrl
,