feat: sponsorblock support

This commit is contained in:
Tim Coombs 2023-02-03 14:17:02 +11:00 committed by Tim Coombs
parent 812fbc5f46
commit 932eb4caf4
1 changed files with 10 additions and 2 deletions

View File

@ -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: