fix: using defaults data when the json metadata file is missing
This commit is contained in:
parent
9a39d89ce8
commit
b2f88145c7
1 changed files with 17 additions and 6 deletions
|
@ -13,9 +13,21 @@ defmodule PodcastFeed.Provider.Archive.Parser do
|
|||
|
||||
defp fetch_extra_metadata(identifier) do
|
||||
extra_metadata_url = Format.compile(@extra_metadata_url, identifier: identifier)
|
||||
{:ok, 200, _headers, client_ref} = :hackney.get(extra_metadata_url, [], "", [follow_redirect: true])
|
||||
case :hackney.get(extra_metadata_url, [], "", [follow_redirect: true]) do
|
||||
{:ok, 200, _headers, client_ref} ->
|
||||
{:ok, extra_metadata_json} = :hackney.body(client_ref)
|
||||
extra_metadata_json |> String.split("\n") |> Enum.join() |> Poison.decode!()
|
||||
_ -> %{
|
||||
"link" => "",
|
||||
"image" => %{
|
||||
"url" => "",
|
||||
"title" => "",
|
||||
"link" => "",
|
||||
},
|
||||
"category" => "",
|
||||
"explicit" => "",
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
defp fetch_metadata(identifier) do
|
||||
|
@ -27,12 +39,11 @@ defmodule PodcastFeed.Provider.Archive.Parser do
|
|||
end
|
||||
|
||||
def parse(identifier, %{"metadata" => metadata, "files" => files}, extra) do
|
||||
_image = files |> fetch_image(identifier)
|
||||
|
||||
# cover = files |> fetch_cover(identifier)
|
||||
%{podcast: podcast_data(metadata, extra), items: items_data(files, identifier)}
|
||||
end
|
||||
|
||||
defp fetch_image(files, identifier) do
|
||||
defp fetch_cover(files, identifier) do
|
||||
filename = files
|
||||
|> Enum.filter(fn f -> f["source"] == "original" end)
|
||||
|> Enum.filter(fn f -> f["format"] == "JPEG" end) #FIXME:! jpg, png, gif
|
||||
|
|
Loading…
Reference in a new issue