Repository navigation
Replace audio from a file; downloads keep hand-replaced files - #587
Merged
henriquesebastiao merged 1 commit intoNov 14, 2026
Merged
henriquesebastiao merged 1 commit into
henriquesebastiao merged 1 commit into
Conversation
Replace audio can now take an audio file from the admin's own device (a CD rip, a Soulseek download): same format is used as it is, another is converted to the track's format, so the path never changes. Tags, date and the staging/verification of the existing flow are reused. Every replacement (YouTube, SoundCloud or file) is remembered by path (downtify/hand_replaced.py). With "Download again if the file exists" on, a download that would land on such a file counts it as already downloaded instead, and Library upgrade's audio replacement skips it. The dialog shows it and can lift it. Refs henriquesebastiao#582 (ideas 4 and 5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Merging this PR will not alter performance1 warning
Comparing |
henriquesebastiao
approved these changes
Nov 14, 2026
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.
Covers ideas 4 and 5 of #582: Replace audio from a file, and downloads leave a replaced file alone.
Why
#582's One Dance case: the automatic match picked a parody, the user put the right file in by hand, and it came back. #584 fixed the part where a deleted duplicate is downloaded again. This PR fixes the other two parts:
What it does
(A local test instance in Docker; the files are generated tones.)
From a file.
POST /api/library/replace/upload?file=&name=. The body is the raw file, not multipart, like the cookies and artist-image uploads, so nopython-multipart.<name>.downtify-upgrade.upload.<ext>), up to 400 MB.ffmpeg -xerrordecodes it to the end, so a renamed non-audio file or a truncated one is refused..mp3 .flac .m4a .ogg .opus .wav .aiff .aac .webm) is converted to the track's format at the chosen bitrate. Either way the path doesn't change, so there's nothing to relink.copy_tags,os.replace, the modification time kept,_after_replacement(metadata cache, listing, track index, owners rekey).library_onlynow lists/api/library/replace/candidatesandPOST /api/library/replaceinstead of the whole prefix.Kept from downloads.
downtify/hand_replaced.pykeeps ahand_replaced_filestable in the library db.overwrite_existing_filesis on. With it off, nothing existing is overwritten anyway.DELETE /api/library/replace/protected.GET /api/library/replace/protectedgives the status.Not in this PR
Idea 6 of #582, remembering a rejected source. Replacing a file now protects it, which covers the case where the rejected video would come back over the same file. Remembering a rejected video per song goes further, and I'd like your view on #582 before doing that.
Tests
tests/test_hand_replaced.py, 15 tests:mainon my Windows/Docker setup. ruff check passes;ruff format --checkonly flagstests/test_slskd_poll_backoff.py, which is already onmain.replace-audio.mdtranslations pass. The one failure iszh-CN/features/doctor.md, which already fails onmainsince docs: complete Simplified Chinese feature translations and fix iOS links #585 (it predates Doctor: merge duplicate songs, keep both, listen before deciding #584's link).Strings are in all 12 locales. Docs:
features/replace-audio.md, with two new sections in English and the 10 translated pages, and the API reference.🤖 Generated with Claude Code