fix: fixing seconds duration of audio

This commit is contained in:
danilo silva 2020-05-24 21:01:58 +00:00
parent a4cfdfcdf6
commit cd2359c634
2 changed files with 3 additions and 5 deletions

View file

@ -96,7 +96,7 @@ defmodule PodcastFeed.Provider.Archive.Parser do
description: "",
pubDate: file |> Map.get("mtime") |> Integer.parse() |> elem(0) |> DateTime.from_unix!(:second),
link: Format.compile(@download_url, identifier: identifier, filename: filename) |> URI.encode(),
length: (file |> Map.get("length") |> Float.parse() |> elem(0)) * 100 |> trunc(),
length: (file |> Map.get("length") |> Float.parse() |> elem(0)) |> trunc(),
size: file |> Map.get("size"),
summary: "",
# image: "", #FIXME:! take the image from other files

View file

@ -2,10 +2,8 @@ defmodule PodcastFeedWeb.FeedView do
use PodcastFeedWeb, :view
def format_length(length) do
length |> IO.inspect
parsed = length / 100 / 60
min = parsed |> trunc
sec = parsed - min |> Float.floor(2) |> Float.to_string() |> String.split(".") |> Enum.at(1)
min = length / 60 |> trunc()
sec = length - (min * 60)
"#{min}:#{sec}"
end
end