Skip to content

Recommendations policy - #7633

Open
immae wants to merge 2 commits into
Chocobozzz:developfrom
immae:recommendations
Open

Recommendations policy#7633
immae wants to merge 2 commits into
Chocobozzz:developfrom
immae:recommendations

Conversation

@immae

@immae immae commented May 28, 2026

Copy link
Copy Markdown
Contributor

Description

This commit adds a new option attached to a video, that allows to chose which kind of recommendation will appear below it in the viewer. It currently allows four setups:

  • Any video (same as currently)
  • Local videos only
  • Owner videos only
  • Same channel videos only

This allows the user who owns the video to restrict the recommendations associated to his videos.

AI disclaimer: Tests were written in big part with AI help. It also sketched me a draft of the feature implementation but no line of this draft remain in this PR, it helped mostly with providing indications and relevant code locations since I’m not familiar with the project.

Related issues

#1600

Has this been tested?

  • 👍 yes, I added tests to the test suite
  • 💭 no, because this PR is a draft and still needs work
  • 🙅 no, because this PR does not update server code
  • 🙋 no, because I need help

Screenshots

2026-05-28_15_52_42

@immae immae changed the title Recommendations Recommendations policy May 28, 2026
@immae
immae force-pushed the recommendations branch from 3c511a7 to 8570ff0 Compare May 28, 2026 14:43
immae added 2 commits May 29, 2026 10:48
This commit adds a new option attached to a video, that allows to chose
which kind of recommendation will appear below it in the viewer.
It currently allows four setups:
- Any video (same as currently)
- Local videos only
- Owner videos only
- Same channel videos only

This allows the user who owns the video to restrict the recommendations
associated to his videos.
Tests for the recommendation feature
@immae
immae force-pushed the recommendations branch from 8570ff0 to deb970c Compare May 29, 2026 08:48
@Chocobozzz

Copy link
Copy Markdown
Owner

Thank you. Before reviewing this PR in detail, please:

  • Prefer using a /api/v1/recommendations/videos route that accepts a strategy query param. strategy, for now, would accept a VideoRecommendationPolicy (that we can rename VideoRecommendationStrategy. We can imagine more recommendation strategies in the future, the client will decide
  • Allow the admin to specify a default recommendation strategy, like we already do for some video metadata (download enabled, etc.)
  • Add federation support so remote instances can also choose which recommendation strategy they need to choose

@immae

immae commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author
* Prefer using a `/api/v1/recommendations/videos` route that accepts a `strategy` query param. `strategy`, for now, would accept a `VideoRecommendationPolicy` (that we can rename `VideoRecommendationStrategy`. We can imagine more recommendation strategies in the future, the client will decide

Just to make sure I understand this point correctly: The current endpoint format (as I implemented it) is '/api/v1/videos/{uuid}/recommendations', and you are talking about '/api/v1/recommendations/videos', is it just an omission in your comment and you actually meant '/api/v1/videos/{uuid}/recommendations/videos'? (because we already have uuid-namespaced endpoints, so it made sense to me to namespace it in this case too).

Then: is your request an addition to what I implemented? so by default we would use the video (or admin) policy, unless a query param is specified in which case we use the query param? Or is it in place of it? (so I would need to pass the preference to the client and then the client decides the strategy when it queries the recommendation, and the endpoint itself would be actually "stateless"?)

@immae

immae commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Add federation support so remote instances can also choose which recommendation strategy they need to choose

Maybe I miss some federation feature, but I don’t see how this preference makes sense in a federation context, do you have an example scenario in mind?

@Chocobozzz

Copy link
Copy Markdown
Owner

is it just an omission in your comment

I would like to create a recommendation endpoint under /api/v1/recommendations/videos. This endpoint can be used, in the future, to also recommend videos to users based on their recent interactions (and so not related to a specific video ID).

Then: is your request an addition to what I implemented?

I suggest having a stateless REST API endpoint, accepting parameters to the client choose the recommendation algorithm it wants. Your PR implementation allows the uploader to decide the recommended algorithm, but we may envisage in the future that the viewer can also override the algorithm. It will be up to the client to decide which preference it wants to apply.
So yes:

  1. client fetch recommendation strategy (from video or from instance)
  2. sends the strategy + needed query params (like the video ID) to the REST API
  3. the REST API responds video objects according to strategy and query params

do you have an example scenario in mind?

You upload a video on peertube1.example.com and ask PeerTube to recommend only local videos to viewers. Viewers watching the video on peertube2.example.com should see videos of peertube1.example.com as recommendations

@immae

immae commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Understood, I’ll see how to do that

@Chocobozzz

Copy link
Copy Markdown
Owner

Any news on this PR?

@immae

immae commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Any news on this PR?

I’m lacking time to work on it for now, sorry.
If you don’t want to keep the MR open you may close it, I cannot give a timeline for when I’ll be back to it

(note: two weeks for the first review was a bit too long for me: I tried looking at the code after the review and since I’m not a regular contributor it was as if I saw it for the first time, so I gave up and didn’t have courage to go back to it since then)

@Chocobozzz

Copy link
Copy Markdown
Owner

(note: two weeks for the first review was a bit too long for me: I tried looking at the code after the review and since I’m not a regular contributor it was as if I saw it for the first time, so I gave up and didn’t have courage to go back to it since then)

I know and I'm sorry about that. I'll try to decrease review lag in the future (I was on holidays when you created the PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants