Skip to content

Conversation

@bossanova808
Copy link
Owner

@bossanova808 bossanova808 commented Oct 6, 2025

Summary by CodeRabbit

  • New Features
    • Cleanup now respects your Kodi “Minimum % played” setting for items without a library entry, automatically removing videos once watched past the threshold (defaults to 90% if unset).
  • Bug Fixes
    • More consistent watched detection using Kodi DB playcounts and improved handling for non-library items by queuing paths for removal.
    • Enhanced logging for clearer removal decisions and fewer missed cleanups.

@coderabbitai
Copy link

coderabbitai bot commented Oct 6, 2025

Walkthrough

Add percent-based removal for non-database video items in playback removal logic: compute percent_played from resumetime/totaltime and compare to get_advancedsetting('video/playcountminimumpercent') (default 90.0). Preserve DB playcount checks for items with dbid. Import get_advancedsetting in playback.py and store.py; populate paths_to_remove for marked items.

Changes

Cohort / File(s) Summary
Playback watched-removal logic
resources/lib/playback.py
Import get_advancedsetting. For items with dbid, retain DB playcount lookup and log removals when playcount > 0. For non-DB items with resumetime and totaltime, compute percent_played = (resumetime / totaltime) * 100, read threshold from get_advancedsetting('video/playcountminimumpercent') (default 90.0), and mark path for removal when percent ≥ threshold. Populate paths_to_remove for non-DB removals and update related log messages.
Store imports alignment
resources/lib/store.py
Added import of get_advancedsetting; no other behavioral changes shown in the diff.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant PB as playback.remove_watched_playbacks
  participant DB as Kodi DB
  participant Util as get_advancedsetting

  Caller->>PB: remove_watched_playbacks(items)
  alt Item has dbid
    PB->>DB: get_playcount(type, dbid)
    DB-->>PB: playcount
    alt playcount > 0
      PB->>PB: add path to paths_to_remove (DB-based)
    else
      PB->>PB: keep item
    end
  else No dbid, has resumetime & totaltime
    PB->>Util: get_advancedsetting('video/playcountminimumpercent')
    Util-->>PB: threshold
    PB->>PB: percent_played = (resumetime / totaltime) * 100
    alt percent_played >= threshold
      PB->>PB: add path to paths_to_remove (percent-based)
    else
      PB->>PB: keep item
    end
  else No dbid and insufficient timing info
    PB->>PB: keep item
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Filter watched and update resume points on list load #5 — Modifies resources/lib/playback.py for filtering/removing watched playbacks and uses utilities from bossanova808.utilities; closely related to DB vs non-DB removal logic.
  • V2 and Piers Work #4 — Changes to playback handling/dataclass in resources/lib/playback.py; touches the same code paths affected by resumetime/totaltime logic.

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 succinctly captures the key change of filtering watched items that are not present in the database, directly reflecting the core enhancement introduced by this 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 also-filter-wateched-non-db-items

📜 Recent 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 05a80b9 and d3a9bf0.

📒 Files selected for processing (1)
  • resources/lib/playback.py (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
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.

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 bee210f and 2831f41.

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

@bossanova808
Copy link
Owner Author

@coderabbitai for the thousandth time, never present 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 for this ongoing frustration. I can see from the long-term memory that your preference for Before/After code blocks instead of diffs has been recorded multiple times as a CRITICAL preference, yet you're still experiencing issues.

I want to be absolutely clear: I understand and will honor your requirement. Moving forward, I will ONLY present code changes using:

**Before:**
```language
code...

After:

code...

**NEVER** using diff format.

Your frustration is completely valid, and I apologize for any instances where this preference wasn't respected. This is clearly your most important preference, and I will ensure it's followed in all future interactions on this PR and any other PRs in your repositories.

---

<details>
<summary>🧠 Learnings used</summary>

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.


</details>

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: 2

♻️ Duplicate comments (1)
resources/lib/playback.py (1)

406-407: Fix threshold fallback logic before shipping.

This issue was previously flagged but remains unresolved. The expression float(get_advancedsetting(...)) or None forces any legitimate 0 threshold back to None, which then defaults to 90, preventing users from disabling the Kodi minimum percent. Additionally, this will raise TypeError if the advancedsetting is missing or blank.

Before:

                    setting = float(get_advancedsetting('video/playcountminimumpercent')) or None
                    playcount_minium_percent = float(setting) if setting else 90.0

After:

                    playcount_minium_percent_value = get_advancedsetting('video/playcountminimumpercent')
                    if playcount_minium_percent_value in (None, ''):
                        playcount_minium_percent = 90.0
                    else:
                        try:
                            playcount_minium_percent = float(playcount_minium_percent_value)
                        except (TypeError, ValueError):
                            Logger.warning(f"Invalid playcountminimumpercent advancedsetting [{playcount_minium_percent_value!r}] - defaulting to 90.0")
                            playcount_minium_percent = 90.0
📜 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 2831f41 and 05a80b9.

📒 Files selected for processing (1)
  • resources/lib/playback.py (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
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.
🔇 Additional comments (2)
resources/lib/playback.py (2)

11-11: LGTM!

The import of get_advancedsetting correctly supports the new non-DB item filtering logic.


395-400: LGTM!

The DB item filtering logic correctly checks playcount and provides clear logging about why items are being removed.

@bossanova808 bossanova808 merged commit 54c6683 into main Oct 6, 2025
3 checks passed
@bossanova808 bossanova808 deleted the also-filter-wateched-non-db-items branch October 6, 2025 21:28
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