fix: batch song renamer and prepare for centralised song editing#783
Open
safepay wants to merge 8 commits intovicwomg:masterfrom
Open
fix: batch song renamer and prepare for centralised song editing#783safepay wants to merge 8 commits intovicwomg:masterfrom
safepay wants to merge 8 commits intovicwomg:masterfrom
Conversation
Keep branch's refactored batch renamer logic (caching, rate limiting, diacritics, case-only rename) while adopting master's flask-smorest Blueprint, Schema classes, and @bp.arguments() decorators. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dc27c6c to
f1480e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Batch song renamer fixes and metadata extraction groundwork
Preparatory work for the metadata extraction plan outlined in #779. Cleans up and correctly structures
batch_song_renamer.pyso that its logic can be extracted intopikaraoke/lib/metadata_parser.pyin a follow-up PR.What changed
Format detection: artist-title and title-artist both handled correctly
The renamer now detects whether a filename uses
Artist - TitleorTitle - Artistordering and preserves that format in the suggested rename. Previous tests had the assertions backwards — this branch corrects both the logic and the tests.Functions decomposed for testability
score_resultwas split into_score_query_matchand_score_penalties. Helpers for accent removal, format detection, artist deduplication, and name comparison were extracted as named functions. This makes the scoring and format-detection logic independently testable and directly extractable intometadata_parser.pywithout refactoring.Last.fm resilience
_last_api_request_time_RATE_LIMITEDsentinel distinguishes transient failures (don't cache) from genuine no-results (cache). Previously, timeouts and network errors were cached permanently asNone.lru_cacheto enforce this distinctionCase-only rename support
Two-step rename via a temp file handles case-insensitive filesystems (Windows, macOS) — e.g. renaming
abbatoABBAno longer silently fails.Route cleanup
browsesimplified to GET-onlyget_songs_to_renamequery paramsong-indexrenamed tosong_index(consistent with Python/schema conventions)Test coverage added
_detect_artist_firstcovering format detection edge casesPrepares for #779
The decomposed functions and plain-dict cache in this branch are the direct prerequisite for extracting them into
pikaraoke/lib/metadata_parser.py. The follow-up will addregex_tidy()(lightweight cleanup for YouTube-sourced files),has_youtube_id()(provenance detection), and server-side endpoints to replace the client-side Last.fm calls inedit.html.