     end
   end
 
-  def iframe(conn, %{"id" => id}) do
-    asciicast = Asciicasts.get_asciicast!(id)
+  def iframe(conn, _params) do
+    url = asciicast_file_url(conn, conn.assigns.asciicast)
 
     conn
     |> put_layout("iframe.html")
     |> delete_resp_header("x-frame-options")
-    |> render("iframe.html", file_url: asciicast_file_url(conn, asciicast))
-  end
-
-  def embed(conn, %{"id" => id} = params) do
-    asciicast = Asciicasts.get_asciicast!(id)
+    |> render_asciicast("iframe.html", file_url: url)
+  end
+
+  def embed(conn, params) do
     opts = Asciicasts.PlaybackOpts.parse(params)
 
     conn
     |> put_layout("embed.html")
     |> delete_resp_header("x-frame-options")
-    |> render("embed.html",
-      asciicast: asciicast,
-      playback_options: opts
-    )
+    |> render_asciicast("embed.html", playback_options: opts)
   end
 
   def example(conn, _params) do

  end

  defp load_asciicast(conn, _) do
    asciicast = Asciicasts.get_asciicast!(conn.params["id"])

    if asciicast.archived_at do
      case get_format(conn) do
        "html" ->
          conn
          |> put_status(410)
          |> render("archived.html")
          |> halt()

         _ ->
          conn
          |> send_resp(410, "")
          |> halt()
      end
    else
      assign(conn, :asciicast, asciicast)
    end
  end

  defp count_view(conn, asciicast) do

  end

  def show(conn, _params) do
    asciicast = conn.assigns.asciicast

    if asciicast.archived_at do
      render_archived(conn)
    else
      do_show(conn, get_format(conn), asciicast)
    end
  end

  def do_show(conn, "html", asciicast) do
