Browse Source

fix: fixing seconds duration of audio

danilo silva 4 years ago
parent
commit
cd2359c634

+ 1 - 1
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

+ 2 - 4
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