Skip to content
This repository was archived by the owner on Jun 14, 2026. It is now read-only.

feat(trackers/spd): handle staff reservations - #1387

Open
HichamLL04 wants to merge 3 commits into
Audionut:masterfrom
HichamLL04:feat/spd_reservations
Open

feat(trackers/spd): handle staff reservations#1387
HichamLL04 wants to merge 3 commits into
Audionut:masterfrom
HichamLL04:feat/spd_reservations

Conversation

@HichamLL04

@HichamLL04 HichamLL04 commented Jun 6, 2026

Copy link
Copy Markdown

#1246

Summary by CodeRabbit

  • New Features
    • SPD tracker now verifies claims by querying reservation data directly for more accurate detection of claimed releases.
  • Bug Fixes
    • Improved handling of missing or invalid tracker responses to avoid false negatives and reduce incorrect claim results.

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

Thanks for taking the time to contribute to this project. Upload Assistant is currently in a complete rewrite, and no new development is being conducted on this python source at this time.

If you have come this far, please feel free to leave open, any pull requests regarding new sites being added to the source, as these can serve as the baseline for later conversion.

If your pull request relates to a critical bug, this will be addressed in this code base, and a new release published as needed.

If your pull request only addresses a quite minor bug, it is not likely to be addressed in this code base.

Details for the new code base will follow at a later date.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7b23fc9c-e765-4865-a501-115ca61aac56

📥 Commits

Reviewing files that changed from the base of the PR and between 1e03d82 and e501331.

📒 Files selected for processing (1)
  • src/trackers/SPD.py

📝 Walkthrough

Walkthrough

Adds SPD.get_claims(meta) to query SpeedApp’s /api/reservation and match reservations against the edited SPD name; TRACKER_SETUP.get_torrent_claims now initializes the tracker and directly returns tracker_instance.get_claims(meta) for SPD when available.

Changes

SPD Claims API Integration

Layer / File(s) Summary
SPD get_claims API method
src/trackers/SPD.py
New async method queries /api/reservation with the instance HTTP session and API key, validates a list response, normalizes the edited SPD name and reservation names (alphanumeric-only, lowercase), skips uploaded reservations, returns True on first match, False if none match, and None for missing key, 403, non-200/unexpected formats, or exceptions (with optional debug logs).
Tracker setup SPD integration
src/trackersetup.py
get_torrent_claims now constructs the tracker instance first, returns None if creation fails, and for SPD calls await tracker_instance.get_claims(meta) when present, bypassing the claimed-releases file pagination path.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped to SpeedApp on a lark,
Keys in paw, names folded dark,
I checked each reservation, skipped the done,
Found a match — then danced in the sun,
Hooray for claims, and code that’s sharp!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for handling staff reservations in the SPD tracker by implementing the get_claims method to query reservations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/trackers/SPD.py`:
- Around line 55-68: The reservation normalization must use the same
Unicode/ASCII-folding as edit_name() so API names match; update the
normalized_res_name logic to apply the same folding routine used by edit_name()
(or call that helper if one exists) before stripping non-alphanumerics and
lowercasing. Concretely, where normalized_res_name is computed from
reservation.get('name'), first pass res_name through the same
ASCII-fold/Unicode-normalize function used by edit_name() (or reuse edit_name's
helper), then run the re.sub(r'[^a-zA-Z0-9]', '', ...) and .lower() so
normalized_spd_name and normalized_res_name use identical normalization. Ensure
you only change the normalization step for normalized_res_name and keep the
existing type checks for reservation.

In `@src/trackersetup.py`:
- Around line 430-433: The SPD tracker must not treat verification failures as
"not claimed": change the SPD implementation (the SPD.get_claims method) to
return None for configuration/API/transport failures (only True for claimed,
False for explicitly not claimed), and keep trackersetup.py's branch (where
tracker_instance.get_claims is awaited) returning the raw result
(None/True/False) unchanged so the later logic that builds local_tracker_status
can distinguish None (verification failure) from False (explicitly not claimed)
when computing local_tracker_status['skipped'].
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a821d05d-d527-4d9e-8c84-844b19dbceb6

📥 Commits

Reviewing files that changed from the base of the PR and between 1a5242a and 1e03d82.

📒 Files selected for processing (2)
  • src/trackers/SPD.py
  • src/trackersetup.py

Comment thread src/trackers/SPD.py Outdated
Comment thread src/trackersetup.py
Comment on lines +430 to +433
if tracker.upper() == "SPD":
if hasattr(tracker_instance, 'get_claims'):
return await tracker_instance.get_claims(meta)
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Don't treat “claims check failed” as “not claimed”.

This branch returns SPD's raw boolean straight into the normal claims flow. In src/trackerstatus.py:94-105, that result is collapsed into local_tracker_status['skipped'] = bool(claimed), so the False returned by SPD.get_claims() on missing API keys, 403s, and transport errors becomes “safe to upload”. That makes the new staff-reservation guard fail open whenever the API cannot be verified.

🛡️ Suggested contract change
         if tracker.upper() == "SPD":
             if hasattr(tracker_instance, 'get_claims'):
-                return await tracker_instance.get_claims(meta)
+                claimed = await tracker_instance.get_claims(meta)
+                if claimed is None:
+                    meta['tracker_status'].setdefault(tracker, {})['skip_upload'] = True
+                    return True
+                return claimed
             return None

And have SPD.get_claims() return None for configuration/API failures instead of False.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/trackersetup.py` around lines 430 - 433, The SPD tracker must not treat
verification failures as "not claimed": change the SPD implementation (the
SPD.get_claims method) to return None for configuration/API/transport failures
(only True for claimed, False for explicitly not claimed), and keep
trackersetup.py's branch (where tracker_instance.get_claims is awaited)
returning the raw result (None/True/False) unchanged so the later logic that
builds local_tracker_status can distinguish None (verification failure) from
False (explicitly not claimed) when computing local_tracker_status['skipped'].

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant