fix: strip leading dot from extension when checking audio format on upload#555
Open
octo-patch wants to merge 1 commit intoHuanshere:mainfrom
Open
fix: strip leading dot from extension when checking audio format on upload#555octo-patch wants to merge 1 commit intoHuanshere:mainfrom
octo-patch wants to merge 1 commit intoHuanshere:mainfrom
Conversation
…ormats (fixes Huanshere#553) os.path.splitext returns the extension with a leading dot (e.g. '.mp3'), but allowed_audio_formats entries have no dot (e.g. 'mp3'). The comparison always evaluated to False, so audio files (MP3, WAV, etc.) were never converted to a video container and the UI got stuck in a reload loop. Strip the leading dot with [1:], consistent with how find_video_files() already handles extensions. Co-Authored-By: Octopus <liyuan851277048@icloud.com>
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.
Fixes #553
Problem
When a user uploads an MP3 or WAV file, the upload handler gets stuck in a
reload loop and the audio is never processed.
Root cause:
os.path.splitext()returns the file extension with a leadingdot (e.g.
'.mp3'), butallowed_audio_formatsinconfig.yamlstoresvalues without the dot (e.g.
'mp3'). The comparisonalways evaluates to
False, soconvert_audio_to_video()is never called.The audio file is saved to the output folder but
find_video_files()ignoresit (it only matches video extensions), so the UI loops endlessly on the upload
widget.
This also explains why renaming the file to
.mp4"works" — the video-formatbranch is hit instead and
find_video_files()picks it up.Solution
Strip the leading dot with
[1:]before the membership test, consistent withhow
find_video_files()already handles extensions:Testing
.mp3file: the UI now callsconvert_audio_to_video, createsblack_screen.mp4, removes the original audio file, and re-renders showingthe video player as expected.
.wav,.flac,.m4afiles: same behaviour..mp4file: unaffected, works as before.