]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/escapist.py
4 from .common
import InfoExtractor
13 class EscapistIE(InfoExtractor
):
14 _VALID_URL
= r
'^(https?://)?(www\.)?escapistmagazine\.com/videos/view/(?P<showname>[^/]+)/(?P<episode>[^/?]+)[/?]?.*$'
16 def _real_extract(self
, url
):
17 mobj
= re
.match(self
._VALID
_URL
, url
)
19 raise ExtractorError(u
'Invalid URL: %s' % url
)
20 showName
= mobj
.group('showname')
21 videoId
= mobj
.group('episode')
23 self
.report_extraction(videoId
)
24 webpage
= self
._download
_webpage
(url
, videoId
)
26 videoDesc
= self
._html
_search
_regex
('<meta name="description" content="([^"]*)"',
27 webpage
, u
'description', fatal
=False)
29 imgUrl
= self
._html
_search
_regex
('<meta property="og:image" content="([^"]*)"',
30 webpage
, u
'thumbnail', fatal
=False)
32 playerUrl
= self
._html
_search
_regex
('<meta property="og:video" content="([^"]*)"',
33 webpage
, u
'player url')
35 title
= self
._html
_search
_regex
('<meta name="title" content="([^"]*)"',
36 webpage
, u
'player url').split(' : ')[-1]
38 configUrl
= self
._search
_regex
('config=(.*)$', playerUrl
, u
'config url')
39 configUrl
= compat_urllib_parse
.unquote(configUrl
)
41 configJSON
= self
._download
_webpage
(configUrl
, videoId
,
42 u
'Downloading configuration',
43 u
'unable to download configuration')
45 # Technically, it's JavaScript, not JSON
46 configJSON
= configJSON
.replace("'", '"')
49 config
= json
.loads(configJSON
)
50 except (ValueError,) as err
:
51 raise ExtractorError(u
'Invalid JSON in configuration file: ' + compat_str(err
))
53 playlist
= config
['playlist']
54 videoUrl
= playlist
[1]['url']
64 'description': videoDesc
,
65 'player_url': playerUrl
,