Development of referrer plugin

for context the referrer feature means that a user can add domains while uploading a video. And if this option is selected embedded videos will only play if the video is embedded in on of the domains added by the user.

I will be working on the « access through referrer » feature from now on. I have already spent some time getting familiar with the documentation and codebase of PeerTube. As suggested by you, in one of the emails, I am trying to implement this feature using a pluggin. I already have a general layout for the plugin that I think will work great for this feature. My general design involves an extra field added to the video-edit page where multiple domains/urls can be typed. These will be stored with the video and can be used on ‹ action:video-watch.init › to verify if the video should be loaded when comparing these stored domains to the current domain.

For the video-edit page I have already made the input field and stored the domains with the video. However I would like to add an extra option to the privacy dropdown to enable this feature. Something called « referrer ».

So my first question is how I can edit existing options within peertube using a plugin. All information I could find was about adding new fields not changing existing fields.

Besides this I am also having quite some trouble developing new features. I understand the usage of the hooks to trigger my own code but I am unsure how I should know what objects I have available at the time of the hook firing. So for example during « action:video-watch.player.loaded » there are at least these three objects (player, videojs, video) that can be used to influence peertubes behaviour. But so far I have been unable to find what objects are available for each hook or what objects even exists for this purpose. Should I be cross-referencing the peertube source code to find this out? Or am I missing something obvious?

Timo Boer

Simpliest way to know is to search the hook name in Peertube source code. You will easily find parameters.

And you can write your plugin in Typescript if you want some help with data types in your editor. To do that, you can for example start by cloning this plugin: GitHub - JohnXLivingston/peertube-plugin-quickstart-typescript: Fork of peertube-plugin-quickstart (See, with Typescript for front-end and backend, and linting.

For your feature, don’t forget that Peertube is federated. Your plugin will only work on the origin instance. If the video is federated, it will be possible to embed it from another instance.

1 Like

Hi T.Boer, as I’m not a developper, I don’t know if I clearly understand your need, but just to let you know that 2 plugins already exist (but maybe not up to date ?) :

If I’m right, then you could look at some suggestions I’ve made on how to improve them :

Thanks, Eric

Aha… thanks! i will have a look at those and see if they do what i need.