   end
 
 
-  def unpause(id) do
-    Repo.get!(PanWeb.Podcast, id)
-    |> PanWeb.Podcast.changeset(%{update_paused: false})
+  def unpause_and_reset_failure_count(id) do
+    Repo.get(Podcast, id)
+    |> PanWeb.Podcast.changeset(%{update_paused: false,
+                                  failure_count: 0})
     |> Repo.update([force: true])
+  end
+
+
+  def increase_failure_count(id) do
+    podcast = Repo.get(Podcast, id)
+
+    Podcast.changeset(podcast, %{failure_count: (podcast.failure_count || 0) + 1})
+    |> Repo.update([force: true])
+
+    if podcast.failure_count == 9 do
+      Podcast.changeset(podcast, %{retired: true})
+      |> Repo.update([force: true])
+    end
   end
 
 

        delta_import(id)

      {:error, message} ->
        podcast = Repo.get(Podcast, id)

        Podcast.changeset(podcast, %{failure_count: (podcast.failure_count || 0) + 1})
        |> Repo.update([force: true])

        if podcast.failure_count == 9 do
          Podcast.changeset(podcast, %{retired: true})
          |> Repo.update([force: true])
        end

        {:error, message}
    end
  end

    case RssFeed.import_to_map(feed.self_link_url, id) do
      {:ok, map} ->
        Persistor.delta_import(map, id)
        unpause_and_reset_failure_count(id)
        {:ok, "Podcast importet"}

      {:redirect, redirect_target} ->
