From 8285063823e7fbe9cae52902c0c37057ac02b665 Mon Sep 17 00:00:00 2001 From: Cody Rogers Date: Wed, 27 Jul 2022 18:42:56 -0500 Subject: [PATCH] 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 --- lib/live_beats/media_library/song.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/live_beats/media_library/song.ex b/lib/live_beats/media_library/song.ex index ac68750..32c616b 100644 --- a/lib/live_beats/media_library/song.ex +++ b/lib/live_beats/media_library/song.ex @@ -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