tubesync
tubesync copied to clipboard
Use SponsorBlock API to remove sponsored segments and Endcards/Credits
Most videos have an Endcards (check 23:05 on this amazing Technology Connection video) or Raid Shitty Legend sponsorships.
The endcards have no purpose outside of youtube itself and break the flow between two videos when watching on a media server/not on youtube.
Sponsorships are understandable the first time you watch a recent video, but are just annoying when it's a 3 year old video you watched for the fifth time.
Those segments also add to the filesize and therefore require more diskspace.
- I'm not sure we can cut a video without reeencoding it :disappointed: research is needed
- In case it is not, including chapter markers with "sponsored segment" or "endcard" would suffice. In this case it would be good to make it human and machine readable in case someone come up with a plugin for Jellyfin or Plex for example.
Yes I've been looking into this myself for a while ever since I started downloading YouTube videos to watch on other devices. This would be provided by youtube-dl or similar upstream library as a feature and not something I would code into TubeSync directly. It doesn't look like youtube-dl supports sponsor cutting itself at all. There are some forks of youtube-dl like yt-dlc ( https://github.com/blackjack4494/yt-dlc ) which do say they support it in their feature set, however:
- I'm not entirely sure how comfortable I'd be basing TubeSync on a much smaller (in terms of dev support and popularity) core upstream library
- It would introduce a dependency to query some external database for sponsorship start and end times, I assume some API queries, per downloaded video, which could introduce a bunch of other issues (unobvious privacy concerns, if the API breaks does TubeSync break etc.)
I agree this would be a great feature, but it likely requires a bunch of testing and fiddling first. I'll put it on the future wishlist for now.
@meeb I just found out that yt-dlp have SponsorBlock integration :)
Might save a lot of time. Could have a simple config - Off, On - Mark only, On - Remove: --no-sponskrub Do not use sponskrub --sponskrub-cut Cut out the sponsor sections instead of simply marking them --no-sponskrub-cut Simply mark the sponsor sections, not cut them out (default)
And yt-dlp does have other very nice features too!
Yeah I've seen it. I covered it (well, yt-dlc not yt-dlp, similar libraries) in my response above as well. I'm considering it, but there's a bunch of potential downsides. I'm looking at making it an opt-in feature rather than replace youtube-dl entirely at the moment.
So now that Tubesync is using yt-dlp this should be even more likely, I've been using yt-dlp and the --sponsorblock-remove and --sponsorblock-mark options in a terminal for awhile now, I say yeah make them opt in for people who want to use them.
I'd also love to help get this implemented if I can.
I would like to add this, however I don't believe yt-dlp has sponsorblock options exposed over the embedded API yet. If or when this gets implemented in yt-dlp I'll definitely look at adding it to TubeSync.
Looking at the yt-dlp code there is a postprocessor
{ 'key': 'SponsorBlock', 'categories': sponsorblock_query, 'api': opts.sponsorblock_api, 'when': 'after_filter' }
opts.sponsorblock_api defaults to https://sponsor.ajay.app sponsorblock_query is what you put after sponsorblock-mark
https://github.com/yt-dlp/yt-dlp/blob/c4a62b99f682bac966ede4a58d1b20f0f3f49f1e/yt_dlp/init.py#L521
If you need an example how to use the postprocessors: https://github.com/Cycor/ytdl-tg-bot/blob/be1981ead33bb0e60687659fc814aa30507a655b/bot.py#L110
Interesting, thanks @Cycor I'll certainly give that a test.
This is definitely of interest to me :D
I was able to get sponsorblock working as a post processor.
This enables chapter support, english subtitle support, and sponsorblock support. You can adjust the categories/remove_sponsor_segments accordingly. There is a full list of categories here: https://github.com/yt-dlp/yt-dlp/blob/14f25df2b6233553e968df023430ca96c0b1df9f/yt_dlp/postprocessor/sponsorblock.py
One thing to note I did need to upgrade my version of ffmpeg to get this to work https://github.com/yt-dlp/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz
sync\youtube.py changes at line 94
opts = get_yt_opts()
opts.update({
'format': media_format,
'merge_output_format': extension,
'outtmpl': output_file,
'quiet': True,
'progress_hooks': [hook],
'writeinfojson': info_json,
'sponsorblock_remove': True,
'nocheckcertificate': True,
'writesubtitles': True,
'writeautomaticsub': False,
'subtitleslangs': ["en", "-live_chat"],
'postprocessors': [{
'key': 'SponsorBlock',
'categories': ['sponsor','selfpromo','interaction']
}, {
'key': 'FFmpegSubtitlesConvertor',
'format': 'srt'
}, {
'key': 'FFmpegThumbnailsConvertor',
'format': 'jpg',
'when': 'before_dl'
}, {
'key': 'EmbedThumbnail',
'already_have_thumbnail': True
}, {
'key': 'FFmpegEmbedSubtitle',
'already_have_subtitle': False
}, {
'key': 'ModifyChapters',
'remove_sponsor_segments': ['sponsor','selfpromo','interaction']
}, {
'key': 'FFmpegMetadata',
'add_chapters': True,
'add_metadata': True
}
]
})
Nice work, thanks! I'll give this a test and if it works I'll bundle it into the next release. Cheers for the contribution!
This is in :latest.