Skip to content

Conversation

@iamcza
Copy link

@iamcza iamcza commented Nov 15, 2025

Changed PAR normalization to use tolerance-based comparison (abs(par - 1.0) < 0.01) instead of strict equality checks. This prevents unintended scaling when PAR is within ±1% of 1.0, fixing common artifacts in WEB-DL content:

  • 1920x1040 no longer becomes 1924x1040
  • 1792x1080 no longer becomes 1799x1080

Still applies scaling for legitimate PAR variations in DVD and anamorphic content.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of pixel-aspect ratios near unity to prevent unintended resizing or distortion during screenshot capture; unity cases are now treated consistently across capture flows.
    • Corrected the service name mapping for Crunchyroll so lookups recognize the canonical name reliably.

✏️ Tip: You can customize this high-level summary in your review settings.

Changed PAR normalization to use tolerance-based comparison (abs(par - 1.0) < 0.01) instead of strict equality checks. This prevents unintended scaling when PAR is within ±1% of 1.0, fixing common artifacts in WEB-DL content:
- 1920x1040 no longer becomes 1924x1040
- 1792x1080 no longer becomes 1799x1080

Still applies scaling for legitimate PAR variations in DVD and anamorphic content.
@coderabbitai
Copy link

coderabbitai bot commented Nov 15, 2025

Walkthrough

Replaced exact PAR equality checks with a tolerance-based comparison (abs(par - 1.0) < 0.01) in screenshot capture paths in src/takescreens.py, and corrected the historical service key Crunchy RollCrunchyroll in src/region.py.

Changes

Cohort / File(s) Summary
PAR tolerance refactor
src/takescreens.py
Replaced strict par == 1 checks with abs(par - 1.0) < 0.01 in both screenshot capture flows (disc and DVD paths). When within tolerance, SAR / w_sar / h_sar are set to identity (1); otherwise existing scaling branches remain. Added explanatory comments near the tolerance logic.
Service name mapping correction
src/region.py
Updated service name key from Crunchy Roll to Crunchyroll in get_service mappings; associated value CR unchanged. No public signatures modified.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: implementing tolerance-based PAR comparison to fix screenshot resolution issues, which is the primary modification in src/takescreens.py.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d57c17 and 3a15272.

📒 Files selected for processing (2)
  • src/region.py
  • src/takescreens.py
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-14T00:20:21.219Z
Learnt from: Audionut
Repo: Audionut/Upload-Assistant PR: 1025
File: src/trackers/TVC.py:32-86
Timestamp: 2025-12-14T00:20:21.219Z
Learning: In src/trackers/TVC.py, the genres argument passed to get_cat_id() is a string (comma-separated) rather than a list or other type. Remove or avoid code paths that handle list inputs for this parameter; assume and validate string input, adjust type hints if present, and, if possible, add a unit test to ensure a string is passed.

Applied to files:

  • src/region.py
  • src/takescreens.py
🔇 Additional comments (3)
src/region.py (1)

94-94: LGTM! Service name correction.

The key change from 'Crunchy Roll' to 'Crunchyroll' correctly reflects the canonical brand name, improving service lookup consistency.

src/takescreens.py (2)

843-854: Tolerance-based PAR comparison looks good for WEB-DL content.

The abs(par - 1.0) < 0.01 threshold effectively prevents unintended scaling artifacts in WEB-DL content (e.g., 1920x1040 with PAR=1.002 staying as-is instead of becoming 1924x1040). The 1% tolerance is reasonable and won't affect legitimate DVD PAR values like ~1.09 (NTSC) or ~1.46 (PAL 16:9).

Note: See separate comment regarding DVD-specific handling based on previous review feedback.


457-470: Confirm whether uniform PAR tolerance for DVD is intentional.

The tolerance-based PAR comparison is currently applied identically in both dvd_screenshots() (line 459) and the general screenshots() function (line 845). This review references a previous comment suggesting DVDs should always scale when PAR differs from 1.0, but that context cannot be located. Clarify whether applying uniform tolerance across both DVD and non-DVD content is the intended behavior, or if DVD content should maintain stricter scaling without the 0.01 tolerance threshold.


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

🧹 Nitpick comments (1)
src/region.py (1)

93-93: Good correction to the official Crunchyroll brand name.

The change properly updates the service name mapping to use the correct spelling 'Crunchyroll' instead of 'Crunchy Roll'.

If backward compatibility is a concern for existing video files that may use the old 'Crunchy Roll' naming, you could optionally add it as an alias:

 'Crunchyroll': 'CR', 'Crave': 'CRAV', 'CRIT': 'CRIT', 'Criterion': 'CRIT', 'Chorki': 'CRKI', 'CRKI': 'CRKI', 'CRKL': 'CRKL', 'Crackle': 'CRKL',
+'Crunchy Roll': 'CR',

This follows the existing pattern where multiple keys map to the same service code (e.g., 'HBO' and 'HBO Go' both mapping to 'HBO').

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70f55e3 and 5347b9c.

📒 Files selected for processing (1)
  • src/region.py (1 hunks)

@iamcza iamcza closed this Nov 22, 2025
@iamcza iamcza reopened this Nov 22, 2025
@iamcza
Copy link
Author

iamcza commented Dec 1, 2025

news?

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

♻️ Duplicate comments (1)
src/takescreens.py (1)

457-469: DVD PAR tolerance changes previous “always scale” behavior

The new abs(par - 1.0) < 0.01 branch means DVDs with PAR very close to 1.0 will now skip any scaling (w_sar = h_sar = 1). Previously, this code path would always derive w_sar/h_sar from par/dar, effectively always applying DVD scaling.

Given the earlier review note that “dvd's should always have scaling applied”, please confirm whether you intentionally want DVDs with near‑unity PAR to bypass scaling now. If not, you might want to:

  • Keep this tolerance only in the non‑disc path (where WEB‑DLs are handled), or
  • Use a tighter/zero tolerance here and retain the old behavior for DVDs.

Separately, the 1920×1040 example in the comment is WEB‑DL‑centric; consider rewording or referencing discs more explicitly to avoid confusion in this DVD helper.

🧹 Nitpick comments (1)
src/takescreens.py (1)

843-854: Unity-PAR tolerance in main screenshot path looks correct

This tolerance block cleanly addresses the WEB‑DL rounding issue:

  • abs(par - 1.0) < 0.01 correctly treats near‑unity PAR (e.g., 1.002) as 1, so w_sar = h_sar = 1 and no unintended scaling occurs.
  • Existing par < 1 / else branches remain unchanged for real anamorphic cases.

If you want to fine‑tune later, you could centralize the PAR≈1 tolerance (e.g., a shared constant or helper) so both disc and non‑disc paths stay in sync, but as‑is this implementation is sound and matches the PR description.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c941237 and 4d57c17.

📒 Files selected for processing (1)
  • src/takescreens.py (2 hunks)

@Audionut
Copy link
Owner

Audionut commented Dec 9, 2025

Seems my review was ignored.

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