Merge pull request #320 from ticoombs/main
feat: initial sponsorblock support
This commit is contained in:
		
						commit
						b8434ff444
					
				| 
						 | 
					@ -64,7 +64,7 @@ def get_media_info(url):
 | 
				
			||||||
    return response
 | 
					    return response
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def download_media(url, media_format, extension, output_file, info_json):
 | 
					def download_media(url, media_format, extension, output_file, info_json, sponsor_categories="all"):
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
        Downloads a YouTube URL to a file on disk.
 | 
					        Downloads a YouTube URL to a file on disk.
 | 
				
			||||||
    '''
 | 
					    '''
 | 
				
			||||||
| 
						 | 
					@ -108,7 +108,15 @@ def download_media(url, media_format, extension, output_file, info_json):
 | 
				
			||||||
        'outtmpl': output_file,
 | 
					        'outtmpl': output_file,
 | 
				
			||||||
        'quiet': True,
 | 
					        'quiet': True,
 | 
				
			||||||
        'progress_hooks': [hook],
 | 
					        'progress_hooks': [hook],
 | 
				
			||||||
        'writeinfojson': info_json
 | 
					        'writeinfojson': info_json,
 | 
				
			||||||
 | 
					        'postprocessors': [{
 | 
				
			||||||
 | 
					            'key': 'SponsorBlock',
 | 
				
			||||||
 | 
					            'categories': [sponsor_categories]
 | 
				
			||||||
 | 
					        },{
 | 
				
			||||||
 | 
					            'key': 'FFmpegMetadata',
 | 
				
			||||||
 | 
					            'add_chapters': True,
 | 
				
			||||||
 | 
					            'add_metadata': True
 | 
				
			||||||
 | 
					        }]
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    with yt_dlp.YoutubeDL(opts) as y:
 | 
					    with yt_dlp.YoutubeDL(opts) as y:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue