 
   def insert_contributors(episodes_map, podcast) do
     for {_, episode_map} <- episodes_map do
-      if episode_map[:enclosures] do
-        first_enclosure = episode_map[:enclosures] |> Map.to_list |> List.first |> elem(1)
-        fallback_url = if episode_map[:link], do: episode_map[:link], else: first_enclosure[:url]
+      if episode_map.enclosures do
+        first_enclosure = episode_map.enclosures |> Map.to_list |> List.first |> elem(1)
+        fallback_url = if episode_map.link, do: episode_map.link, else: first_enclosure.url
 
-        plain_episode_map = Map.drop(episode_map, [:chapters, :enclosures, :contributors])
-                            |> Map.put_new(:guid, fallback_url)
+        plain_episode_map = episode_map
+        |> Map.drop([:chapters, :enclosures, :contributors])
+        |> Map.put_new(:guid, fallback_url)
 
         case get(plain_episode_map, podcast.id) do
           {:exists, episode} ->
-            Contributor.persist_many(episode_map[:contributors], episode)
+            Contributor.persist_many(episode_map.contributors, episode)
             Logger.info "\n\e[33m === Updating contributors for episode: #{episode.title} ===\e[0m"
 
           {:error, "not_found"} ->

  require Logger

  def get_or_insert(episode_map, podcast_id) do
    case Repo.get_by(PanWeb.Episode, guid: episode_map[:guid], podcast_id: podcast_id) do
      nil ->
        if episode_map[:guid] do
          insert(episode_map, podcast_id)
        else
          case Repo.get_by(PanWeb.Episode, title: episode_map[:title] || episode_map[:subtitle],
                                           podcast_id: podcast_id) do
            nil ->
              insert(episode_map, podcast_id)

    episodes = Repo.all(PanWeb.Episode)

    for episode <- episodes do
      episode
      |> PanWeb.Episode.changeset(
        %{description: HtmlSanitizeEx2.basic_html_reduced(episode.description),
          summary:     HtmlSanitizeEx2.basic_html_reduced(episode.summary)}
      )
      |> Repo.update()
    end
  end
end
