From cd2359c63419d88b294ddbc203ba077e862341cb Mon Sep 17 00:00:00 2001 From: danilo silva Date: Sun, 24 May 2020 21:01:58 +0000 Subject: [PATCH] fix: fixing seconds duration of audio --- lib/podcast_feed/provider/archive/parser.ex | 2 +- lib/podcast_feed_web/views/feed_view.ex | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/podcast_feed/provider/archive/parser.ex b/lib/podcast_feed/provider/archive/parser.ex index d6c78cf..927c34d 100644 --- a/lib/podcast_feed/provider/archive/parser.ex +++ b/lib/podcast_feed/provider/archive/parser.ex @@ -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 diff --git a/lib/podcast_feed_web/views/feed_view.ex b/lib/podcast_feed_web/views/feed_view.ex index bdb693c..2a2995d 100644 --- a/lib/podcast_feed_web/views/feed_view.ex +++ b/lib/podcast_feed_web/views/feed_view.ex @@ -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