Update Song with correct MP3 metadata

This commit fixes an issue where the title/artist information of
uploaded files isn't accurate when uploading mp3s. The MP3Stat module
seems to parse the mp3 correctly, but doesn't update the `artist` and
`title` when updating the `duration`, so in some cases the information
saved in the database for a song (and displayed in the UI) will be
incorrect or poorly formatted
This commit is contained in:
Cody Rogers 2022-07-27 18:42:56 -05:00
parent bb8f14cfe1
commit 8285063823

View file

@ -50,6 +50,8 @@ defmodule LiveBeats.MediaLibrary.Song do
changeset
|> put_duration(stat.duration)
|> Ecto.Changeset.put_change(:mp3_filesize, stat.size)
|> Ecto.Changeset.put_change(:artist, stat.artist)
|> Ecto.Changeset.put_change(:title, stat.title)
end
defp put_duration(%Ecto.Changeset{} = changeset, duration) when is_integer(duration) do