Expose chapters through an API
B0pol opened this issue · 2 comments
Third-party applications such as NewPipe, but also yt-dlp and other PeerTube apps can’t access pluginData API:
{
chapters: [
// chapter
{
start: float,
end: float,
name: String,
tags: {
sponsor: bool,
selfPromotion: bool,
interactionReminder: bool,
intro: bool,
intermission: bool,
outro: bool,
credits: bool,
nonMusic: bool,
},
}
],
}
As said in #5, we can access chapters via internal router and we get a WebVTT file.
But it’s not ideal:
- it has plugin version in the URL so it will break every update
- it requires parsing WebVTT whereas the pluginData API is close to perfect (e.g. maybe an enum instead of lots of booleans would be better)
An API would guarantee stability (i.e. same URL for across plugin version, no breaking changes if possible, a way to check version if not possible), remove the need to parse WebVTT, and also come with documentation so that it’s easy to implement.
Somehow I missed in the documentation that the version can be omitted, so no changes need there.
I've added /plugins/chapters/router/videos/:uuid.json
which will provide an object in the format of the example you posted. It accepts uuid.json, shortuuid.json, id.json, uuid.vtt, etc. This change is committed, but not published.
Yeah, the tags is probably better as an enum. I originally was thinking a chapter could have multiple tags, but it doesn't make sense to combine any of the current options. I think I'll change it to
skip_tag: null | 'sponsor' | 'selfpromo' | 'interaction' | 'intro' | 'filler' | 'outro' | 'music_offtopic'
Where the names are changed to match those used by SponsorBlock, and credits
and outro
are merged.
I don't think I can get to this until the weekend after this one, but I can hopefully make the thumbnails work at that point as well.
Hmm... a bit later than I predicted, sorry, but it's implemented in the latest update now. An example is at https://peertube-demo.samli.ch/plugins/chapters/router/api/v1/videos/2Sf37VnzwF9biJ9LTTmQbx.json and the format is described in the readme.