mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-11-04 08:35:12 +00:00 
			
		
		
		
	[escapist] Add support for advertisements
This commit is contained in:
		@@ -52,6 +52,7 @@ class EscapistIE(InfoExtractor):
 | 
				
			|||||||
            webpage, 'config URL'))
 | 
					            webpage, 'config URL'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        formats = []
 | 
					        formats = []
 | 
				
			||||||
 | 
					        ad_formats = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def _add_format(name, cfgurl, quality):
 | 
					        def _add_format(name, cfgurl, quality):
 | 
				
			||||||
            config = self._download_json(
 | 
					            config = self._download_json(
 | 
				
			||||||
@@ -61,11 +62,16 @@ class EscapistIE(InfoExtractor):
 | 
				
			|||||||
                transform_source=js_to_json)
 | 
					                transform_source=js_to_json)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            playlist = config['playlist']
 | 
					            playlist = config['playlist']
 | 
				
			||||||
            video_url = next(
 | 
					            for p in playlist:
 | 
				
			||||||
                p['url'] for p in playlist
 | 
					                if p.get('eventCategory') == 'Video':
 | 
				
			||||||
                if p.get('eventCategory') == 'Video')
 | 
					                    ar = formats
 | 
				
			||||||
            formats.append({
 | 
					                elif p.get('eventCategory') == 'Video Postroll':
 | 
				
			||||||
                'url': video_url,
 | 
					                    ar = ad_formats
 | 
				
			||||||
 | 
					                else:
 | 
				
			||||||
 | 
					                    continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                ar.append({
 | 
				
			||||||
 | 
					                    'url': p['url'],
 | 
				
			||||||
                    'format_id': name,
 | 
					                    'format_id': name,
 | 
				
			||||||
                    'quality': quality,
 | 
					                    'quality': quality,
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
@@ -77,10 +83,9 @@ class EscapistIE(InfoExtractor):
 | 
				
			|||||||
            _add_format('hq', hq_url, quality=1)
 | 
					            _add_format('hq', hq_url, quality=1)
 | 
				
			||||||
        except ExtractorError:
 | 
					        except ExtractorError:
 | 
				
			||||||
            pass  # That's fine, we'll just use normal quality
 | 
					            pass  # That's fine, we'll just use normal quality
 | 
				
			||||||
 | 
					 | 
				
			||||||
        self._sort_formats(formats)
 | 
					        self._sort_formats(formats)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return {
 | 
					        res = {
 | 
				
			||||||
            'id': video_id,
 | 
					            'id': video_id,
 | 
				
			||||||
            'formats': formats,
 | 
					            'formats': formats,
 | 
				
			||||||
            'uploader': uploader,
 | 
					            'uploader': uploader,
 | 
				
			||||||
@@ -89,3 +94,19 @@ class EscapistIE(InfoExtractor):
 | 
				
			|||||||
            'thumbnail': self._og_search_thumbnail(webpage),
 | 
					            'thumbnail': self._og_search_thumbnail(webpage),
 | 
				
			||||||
            'description': description,
 | 
					            '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
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user