Fix ValueError with Unicode superscript characters in torrent title parsing #4713
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a
ValueErrorthat occurs when processing torrent titles containing Unicode superscript characters like '²', '³', '¹'.Problem
The error occurs in
app/core/meta/metavideo.pywhen the code usesisdigit()to check if a string contains only digits, then attempts to convert it withint():Issue:
str.isdigit()returnsTruefor Unicode digit characters including superscripts (²), butint()can only parse standard ASCII digits (0-9).Example failure:
Root Cause
When processing torrent titles like "E=mc² The Movie 2023", the parsing logic encounters the superscript '²' character. The
isdigit()method incorrectly identifies it as a digit, leading to a failedint()conversion.Solution
Replace
isdigit()withisdecimal()in all locations where the result is passed toint():str.isdecimal()only returnsTruefor characters that can form decimal numbers (0-9)str.isdigit()includes Unicode digit characters like superscriptsChanges Made
Fixed 3 locations in
app/core/meta/metavideo.py:Validation
Before fix:
After fix:
Normal digits continue to work exactly as before:
This is a minimal, surgical fix that prevents the crash while preserving all existing functionality.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.