Skip to content

Conversation

@bossanova808
Copy link
Owner

@bossanova808 bossanova808 commented Oct 6, 2025

Summary by CodeRabbit

  • New Features

    • Added settings to auto-filter watched items from the Switchback list (enabled by default) and to optionally force-browse to the episode in the library after a switchback playback.
    • Switchback list now refreshes resume points and prunes watched entries when auto-filtering is enabled; changes persist automatically.
  • Chores

    • Added en-GB translations for the new settings.

@coderabbitai
Copy link

coderabbitai bot commented Oct 6, 2025

Walkthrough

Adds two new boolean addon settings and localization strings. Store now loads these settings and constructs the Switchback PlaybackList with a remove-watched flag. PlaybackList gained logic to filter watched items and sync resume points on load, persisting changes. Player now requires episode_force_browse to force a browse on playback finish.

Changes

Cohort / File(s) Summary
Settings & Localization
resources/settings.xml, resources/language/resource.language.en_gb/strings.po
Adds two boolean settings: remove_watched_playbacks (default true) and episode_force_browse (default false). Adds corresponding en_gb localization strings for the new settings.
Store settings & initialization
resources/lib/store.py
Adds Store.episode_force_browse and Store.remove_watched_playbacks; delays Store.switchback construction and recreates it during init using the remove_watched_playbacks flag; reads and logs the new settings.
Playback list behavior
resources/lib/playback.py
Adds public PlaybackList.remove_watched_playbacks: bool = False; on load, queries library (get_playcount, get_resume_point) to remove watched items and refresh resumetime, marking and saving the list if modified.
Player finish guard
resources/lib/player.py
Modifies onPlaybackFinished to require both switchback_playback and Store.episode_force_browse before executing the force-browse-to-episode flow.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Kodi
  participant Store
  participant PlaybackList as Switchback
  participant Library

  Kodi->>Store: Initialize addon
  Store->>Store: load_config_from_settings()
  Store->>PlaybackList: create(remove_watched_playbacks)
  Note right of PlaybackList: load_or_init()

  PlaybackList->>PlaybackList: Load saved list
  alt remove_watched_playbacks enabled
    loop for each item with dbid
      PlaybackList->>Library: get_playcount(dbid)
      Library-->>PlaybackList: playcount
      alt playcount > 0
        PlaybackList->>PlaybackList: remove item (watched)
      end
      PlaybackList->>Library: get_resume_point(dbid)
      Library-->>PlaybackList: resumetime
      PlaybackList->>PlaybackList: update resumetime if changed
    end
    PlaybackList->>PlaybackList: Save list if modified
  end
Loading
sequenceDiagram
  autonumber
  participant Player
  participant Store
  participant Kodi

  Player->>Player: onPlaybackFinished(event)
  alt switchback_playback AND Store.episode_force_browse
    Player->>Kodi: Force browse to episode in library
  else
    Player->>Player: No forced browse
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately summarizes the primary change—filtering watched items and updating resume points during list load—and is concise and specific to the main functionality enhancements introduced by the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tweaks-before-release

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d00d15 and 913cda1.

📒 Files selected for processing (5)
  • resources/language/resource.language.en_gb/strings.po (1 hunks)
  • resources/lib/playback.py (3 hunks)
  • resources/lib/player.py (1 hunks)
  • resources/lib/store.py (4 hunks)
  • resources/settings.xml (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
resources/lib/store.py (1)
resources/lib/playback.py (2)
  • PlaybackList (335-456)
  • load_or_init (364-411)
resources/lib/player.py (1)
resources/lib/store.py (1)
  • Store (11-89)
🔇 Additional comments (11)
resources/settings.xml (1)

23-32: LGTM! Settings are well-structured.

The two new boolean settings follow the existing pattern and integrate properly with the codebase. The default values are reasonable:

  • remove_watched_playbacks defaults to true for automatic filtering
  • episode_force_browse defaults to false for opt-in behavior
resources/language/resource.language.en_gb/strings.po (1)

48-54: LGTM! Locale strings are clear and properly formatted.

The new strings effectively describe the settings' functionality and follow the standard .po format.

resources/lib/player.py (1)

87-87: LGTM! The guard condition correctly gates force-browse behavior.

The updated condition requires both Store.episode_force_browse and switchback_playback to be truthy, properly implementing the opt-in behavior controlled by the new setting.

resources/lib/store.py (4)

21-21: LGTM! Initialization pattern change is appropriate.

Moving from pre-instantiated to lazy initialization (None → constructed in __init__) allows the new remove_watched_playbacks setting to be applied during construction.


31-32: LGTM! New settings properly declared.

The two new static attributes are correctly initialized from addon settings and follow the existing pattern.


44-44: LGTM! PlaybackList construction includes the new setting.

The remove_watched_playbacks parameter is correctly passed to the PlaybackList constructor, enabling the filtering behavior.


62-65: LGTM! Settings are properly loaded and logged.

The new settings are read from addon configuration and logged appropriately, following the existing pattern.

resources/lib/playback.py (4)

11-11: LGTM! Imports added for library interaction.

The new utility functions get_resume_point and get_playcount enable querying the Kodi library for current playback state.


345-345: LGTM! New field enables filtering behavior.

The remove_watched_playbacks boolean field controls whether watched items are automatically filtered from the list.


402-408: LGTM! Resume point synchronization looks correct.

The loop safely updates resumetime on existing items without adding or removing items from the list, avoiding iteration issues.


410-411: LGTM! Conditional save optimizes I/O.

The list is only persisted if changes were detected, avoiding unnecessary file writes.

@bossanova808
Copy link
Owner Author

@coderabbitai yet again I must remind you - never show diffs, only before and afters!!

@coderabbitai
Copy link

coderabbitai bot commented Oct 6, 2025

Tip

For best results, initiate chat on the files or code changes.

@bossanova808, I sincerely apologize. You're absolutely right, and I have no excuse. This preference is clearly documented in my memory - you've emphasized multiple times that you want "Before:" and "After:" code blocks, never diff format. Yet I failed to follow it again.

I will strictly adhere to this preference in all future interactions. When suggesting code changes, I will always use:

Before:

old code

After:

new code

Thank you for your patience, and I'm sorry for the repeated frustration this has caused.


🧠 Learnings used
Learnt from: bossanova808
PR: bossanova808/plugin.switchback#0
File: :0-0
Timestamp: 2025-09-26T08:11:08.784Z
Learning: User bossanova808 has repeatedly and emphatically requested that code changes should NEVER be presented in diff format. Always use before/after code blocks format for this user. This is a critical preference that must be respected.

Learnt from: bossanova808
PR: bossanova808/plugin.switchback#0
File: :0-0
Timestamp: 2025-09-26T08:11:08.784Z
Learning: CRITICAL PREFERENCE for user bossanova808: NEVER EVER use diff format. Always use "Before:" and "After:" code blocks. This user has been extremely clear and frustrated about this preference. The user has correctly configured .coderabbit.yaml but the system isn't respecting it. This is the user's most important preference and must be honored in every single response.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 913cda1 and 60b4c63.

📒 Files selected for processing (1)
  • resources/lib/playback.py (3 hunks)

@bossanova808 bossanova808 merged commit bee210f into main Oct 6, 2025
3 checks passed
@bossanova808 bossanova808 deleted the tweaks-before-release branch October 6, 2025 06:48
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