]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/escapist.py
1 from __future__
import unicode_literals
3 from . common
import InfoExtractor
13 class EscapistIE ( InfoExtractor
):
14 _VALID_URL
= r
'https?://?(www\.)?escapistmagazine\.com/videos/view/[^/?#]+/(?P<id>[0-9]+)-[^/?#]*(?:$|[?#])'
16 'url' : 'http://www.escapistmagazine.com/videos/view/the-escapist-presents/6618-Breaking-Down-Baldurs-Gate' ,
17 'md5' : 'ab3a706c681efca53f0a35f1415cf0d1' ,
21 '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." ,
22 'uploader_id' : 'the-escapist-presents' ,
23 'uploader' : 'The Escapist Presents' ,
24 'title' : "Breaking Down Baldur's Gate" ,
25 'thumbnail' : 're:^https?://.*\.jpg$' ,
29 def _real_extract ( self
, url
):
30 video_id
= self
._ match
_ id
( url
)
31 webpage
= self
._ download
_ webpage
( url
, video_id
)
33 uploader_id
= self
._ html
_ search
_ regex
(
34 r
"<h1\s+class='headline'>\s*<a\s+href='/videos/view/(.*?)'" ,
35 webpage
, 'uploader ID' , fatal
= False )
36 uploader
= self
._ html
_ search
_ regex
(
37 r
"<h1\s+class='headline'>(.*?)</a>" ,
38 webpage
, 'uploader' , fatal
= False )
39 description
= self
._ html
_ search
_ meta
( 'description' , webpage
)
41 raw_title
= self
._ html
_ search
_ meta
( 'title' , webpage
, fatal
= True )
42 title
= raw_title
. partition ( ' : ' )[ 2 ]
44 config_url
= compat_urllib_parse
. unquote ( self
._ html
_ search
_ regex
(
47 <param\s+name="flashvars".*?\s+value="config=|
48 flashvars="config=
52 webpage
, 'config URL' ))
57 def _add_format ( name
, cfgurl
, quality
):
58 config
= self
._ download
_ json
(
60 'Downloading ' + name
+ ' configuration' ,
61 'Unable to download ' + name
+ ' configuration' ,
62 transform_source
= js_to_json
)
64 playlist
= config
[ 'playlist' ]
66 if p
. get ( 'eventCategory' ) == 'Video' :
68 elif p
. get ( 'eventCategory' ) == 'Video Postroll' :
79 _add_format ( 'normal' , config_url
, quality
= 0 )
80 hq_url
= ( config_url
+
81 ( '&hq=1' if '?' in config_url
else config_url
+ '?hq=1' ))
83 _add_format ( 'hq' , hq_url
, quality
= 1 )
84 except ExtractorError
:
85 pass # That's fine, we'll just use normal quality
86 self
._ sort
_ formats
( formats
)
92 'uploader_id' : uploader_id
,
94 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
),
95 'description' : description
,
98 if self
._ downloader
. params
. get ( 'include_ads' ) and ad_formats
:
99 self
._ sort
_ formats
( ad_formats
)
101 'id' : ' %s- ad' % video_id
,
102 'title' : ' %s (Postroll)' % title
,
103 'formats' : ad_formats
,
107 'entries' : [ res
, ad_res
],