aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/escapist.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube_dl/extractor/escapist.py')
-rw-r--r--youtube_dl/extractor/escapist.py54
1 files changed, 41 insertions, 13 deletions
diff --git a/youtube_dl/extractor/escapist.py b/youtube_dl/extractor/escapist.py
index 6b693b3b6..b45c1dbd0 100644
--- a/youtube_dl/extractor/escapist.py
+++ b/youtube_dl/extractor/escapist.py
@@ -31,10 +31,10 @@ class EscapistIE(InfoExtractor):
webpage = self._download_webpage(url, video_id)
uploader_id = self._html_search_regex(
- r"<h1 class='headline'><a href='/videos/view/(.*?)'",
+ r"<h1\s+class='headline'>\s*<a\s+href='/videos/view/(.*?)'",
webpage, 'uploader ID', fatal=False)
uploader = self._html_search_regex(
- r"<h1 class='headline'>(.*?)</a>",
+ r"<h1\s+class='headline'>(.*?)</a>",
webpage, 'uploader', fatal=False)
description = self._html_search_meta('description', webpage)
@@ -42,9 +42,17 @@ class EscapistIE(InfoExtractor):
title = raw_title.partition(' : ')[2]
config_url = compat_urllib_parse.unquote(self._html_search_regex(
- r'<param name="flashvars" value="config=([^"&]+)', webpage, 'config URL'))
+ r'''(?x)
+ (?:
+ <param\s+name="flashvars".*?\s+value="config=|
+ flashvars=&quot;config=
+ )
+ (https?://[^"&]+)
+ ''',
+ webpage, 'config URL'))
formats = []
+ ad_formats = []
def _add_format(name, cfgurl, quality):
config = self._download_json(
@@ -54,14 +62,19 @@ class EscapistIE(InfoExtractor):
transform_source=js_to_json)
playlist = config['playlist']
- video_url = next(
- p['url'] for p in playlist
- if p.get('eventCategory') == 'Video')
- formats.append({
- 'url': video_url,
- 'format_id': name,
- 'quality': quality,
- })
+ for p in playlist:
+ if p.get('eventCategory') == 'Video':
+ ar = formats
+ elif p.get('eventCategory') == 'Video Postroll':
+ ar = ad_formats
+ else:
+ continue
+
+ ar.append({
+ 'url': p['url'],
+ 'format_id': name,
+ 'quality': quality,
+ })
_add_format('normal', config_url, quality=0)
hq_url = (config_url +
@@ -70,10 +83,9 @@ class EscapistIE(InfoExtractor):
_add_format('hq', hq_url, quality=1)
except ExtractorError:
pass # That's fine, we'll just use normal quality
-
self._sort_formats(formats)
- return {
+ res = {
'id': video_id,
'formats': formats,
'uploader': uploader,
@@ -82,3 +94,19 @@ class EscapistIE(InfoExtractor):
'thumbnail': self._og_search_thumbnail(webpage),
'description': description,
}
+
+ if self._downloader.params.get('include_ads') and ad_formats:
+ self._sort_formats(ad_formats)
+ ad_res = {
+ 'id': '%s-ad' % video_id,
+ 'title': '%s (Postroll)' % title,
+ 'formats': ad_formats,
+ }
+ return {
+ '_type': 'playlist',
+ 'entries': [res, ad_res],
+ 'title': title,
+ 'id': video_id,
+ }
+
+ return res