Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugins): add peertubeHelpers.loadWithFiles #6302

Merged

Conversation

kontrollanten
Copy link
Contributor

Description

Let plugin authors to load a video with all its files. This can be useful when a plugin want to switch video files based on the users capabilities.

Has this been tested?

  • 👍 yes, I added tests to the test suite

@Chocobozzz
Copy link
Owner

Chocobozzz commented Mar 29, 2024

getFiles helper don't do the job for your use case?

@kontrollanten
Copy link
Contributor Author

Yes, I need to call getHLSPlaylist() to get URL to master playlist and segments file.

@kontrollanten kontrollanten force-pushed the feat-plugin-load-files branch from f449bc9 to 924c9d9 Compare March 29, 2024 18:10
@Chocobozzz
Copy link
Owner

Yes, I need to call getHLSPlaylist() to get URL to master playlist and segments file.

Okay then, but getHLSPlaylist is not considered as a plugin API and can break at any moment.

Don't you prefer to create a dedicated plugin helper, like we did for video files, to fetch HLS playlist information?

@kontrollanten
Copy link
Contributor Author

Don't you prefer to create a dedicated plugin helper, like we did for video files, to fetch HLS playlist information?

That would be nice, but I think this use case is too niche to deserve its own plugin API. We use it like this:

      video.VideoStreamingPlaylists = video.VideoStreamingPlaylists.map((p) => {
        p.getMasterPlaylistUrl = () =>
          replacementVideoWithFiles.getHLSPlaylist().getMasterPlaylistUrl(replacementVideoWithFiles)

        p.getSha256SegmentsUrl = () =>
          replacementVideoWithFiles.getHLSPlaylist().getSha256SegmentsUrl(replacementVideoWithFiles)

        return p
      })

It's dirty but I guess the odds this (inofficial) API will frequently change is high. I'm not sure how a plugin API would look like, but maybe something like:

peertubeHelpers.video.setHLSPlaylist(video, peertubeHelpers.video.getHLSPlaylist(replacementVideoWithFiles))

The currently existing method setHLSPlaylist only change the filenames, not the whole URL, which means it needs to be rewritten to get it working accordingly. That's the reason why I think it's too niche to deserve these changes, but if you disagree I'd be happy to rewrite this PR.

@Chocobozzz
Copy link
Owner

That would be nice, but I think this use case is too niche to deserve its own plugin API. We use it like this:

Thanks! filter:api.video.get.result filter hook cannot be used to change HLS playlist URLs?

@kontrollanten
Copy link
Contributor Author

That would be nice, but I think this use case is too niche to deserve its own plugin API. We use it like this:

Thanks! filter:api.video.get.result filter hook cannot be used to change HLS playlist URLs?

It can, that's where we're running the code I pasted above. We return different playlists depending whether the user is a "premium user" or not.

@Chocobozzz Chocobozzz merged commit 6f6abca into Chocobozzz:develop Apr 4, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants