-
-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: mark video as watched after a certain duration #5528
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
base: master
Are you sure you want to change the base?
Conversation
… page loads This will be handled at the front-end with JavaScript.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a feature to automatically mark videos as watched after the user has watched them for at least 30 seconds (or fully for videos shorter than 30 seconds). The feature is opt-in via a new user preference and uses client-side tracking to determine when to mark videos as watched. It also removes the previous server-side logic that marked videos as watched upon navigation to a video page, and fixes a bug preventing YouTube/Invidious link updates when seeking backwards.
Key changes:
- Added
mark_watched_after_durationpreference with default value offalseto avoid confusion for existing users - Implemented client-side tracking in player.js to monitor watch time and trigger mark-as-watched after thresholds are met
- Removed automatic server-side marking of videos as watched on page load
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/invidious/config.cr | Added mark_watched_after_duration property to default preferences config |
| src/invidious/user/preferences.cr | Added mark_watched_after_duration property to user preferences struct |
| src/invidious/videos/video_preferences.cr | Added processing and handling of mark_watched_after_duration parameter in video preferences |
| src/invidious/routes/preferences.cr | Added route handling to save the mark_watched_after_duration preference from form submission |
| src/invidious/routes/watch.cr | Removed server-side logic that automatically marked videos as watched on page navigation |
| src/invidious/views/user/preferences.ecr | Added checkbox UI for the new preference in the preferences page |
| src/invidious/views/template.ecr | Added hidden span to expose the preference value to client-side JavaScript (only for logged-in users) |
| locales/en-US.json | Added English translation for the preference label |
| assets/js/player.js | Implemented client-side watch time tracking and auto-mark-as-watched logic, also fixed backward seeking bug |
Comments suppressed due to low confidence (1)
assets/js/player.js:210
- Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).
time_watched += 1
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
I don't think that's a good thing because we still want to support non js users as long as possible. |
|
Apologies, that was supposed to be ignored only if this feature is enabled. - if watched && preferences.watch_history
+ if watched && preferences.watch_history && !preferences.mark_watched_after_duration
Invidious::Database::Users.mark_watched(user.as(User), id)
endIt should probably be mentioned under the checkbox in the preference page that the feature requires JavaScript though. |
This pull request marks videos as watched after watching them for a given amount of time and also indirectly fixes a bug that prevents YouTube/Invidious links from updating when seeking backwards for the video.
Closes #3794
Todo