From 607f3bcb43e17e682cf2a2a5a440914dd2da287b Mon Sep 17 00:00:00 2001 From: Chris Fulljames Date: Thu, 24 Jul 2025 07:21:50 -0400 Subject: [PATCH] Remove mpck, always use ffmpeg --- .github/workflows/test-and-deploy.yml | 5 ----- README.md | 1 - src/littlesongplace/songs.py | 11 +---------- test/test_songs.py | 12 ++++++++---- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 906ca44..875565c 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -100,11 +100,6 @@ jobs: with: python-version: "3.11" - - name: Install mpck - run: | - wget https://github.com/Sjord/checkmate/releases/download/v0.21/mpck_0.21-1_amd64.deb - sudo dpkg --install mpck_0.21-1_amd64.deb - - name: Install Dependencies run: | python -m pip install --upgrade pip diff --git a/README.md b/README.md index 0a11fc9..8ac18c7 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ Important Places: ## Dependencies This project has some dependencies that need to be installed manually to your system PATH: - [Python 3.11](https://python.org) -- mpck from [Checkmate](https://github.com/Sjord/checkmate) - [ffmpeg](https://ffmpeg.org/) ## Environment Setup diff --git a/src/littlesongplace/songs.py b/src/littlesongplace/songs.py index eaffdaf..be04b46 100644 --- a/src/littlesongplace/songs.py +++ b/src/littlesongplace/songs.py @@ -476,16 +476,7 @@ def convert_song(tmp_file, request_file, yt_url): flash_and_log(f"Failed to import from YouTube URL: {yt_url}") return False - result = subprocess.run(["mpck", tmp_file.name], stdout=subprocess.PIPE) - res_stdout = result.stdout.decode() - current_app.logger.info(f"mpck result: \n {res_stdout}") - lines = res_stdout.split("\n") - lines = [l.strip().lower() for l in lines] - if any(l.startswith("result") and l.endswith("ok") for l in lines): - # Uploaded valid mp3 file - return True - - # Not a valid mp3, try to convert with ffmpeg + # Try to convert with ffmpeg with tempfile.NamedTemporaryFile(suffix=".mp3", delete=False) as out_file: out_file.close() os.remove(out_file.name) diff --git a/test/test_songs.py b/test/test_songs.py index 3fa526f..e0f79d4 100644 --- a/test/test_songs.py +++ b/test/test_songs.py @@ -110,8 +110,9 @@ def test_update_song_success(client): upload_song(client, b"Successfully updated 'song title'", filename=TEST_DATA/"sample-6s.mp3", songid=1) response = client.get("/song/1/1") assert response.status_code == 200 - with open(TEST_DATA/"sample-6s.mp3", "rb") as expected_file: - assert response.data == expected_file.read() + # File has been converted by ffmpeg, will not match byte-for-byte + # with open(TEST_DATA/"sample-6s.mp3", "rb") as expected_file: + # assert response.data == expected_file.read() @pytest.mark.yt def test_update_song_from_youtube(client): @@ -264,8 +265,11 @@ def test_delete_song_other_users_song(client): def test_get_song(client): create_user_and_song(client) response = client.get("/song/1/1") - with open(TEST_DATA/"sample-3s.mp3", "rb") as mp3file: - assert response.data == mp3file.read() + assert response.status_code == 200 + + # File has been converted by ffmpeg, will not match byte-for-byte + # with open(TEST_DATA/"sample-3s.mp3", "rb") as mp3file: + # assert response.data == mp3file.read() def test_get_song_invalid_song(client): create_user_and_song(client) -- 2.39.5