## 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
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)
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):
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)