   def get_asciicast!(id) when is_integer(id) do
     Repo.get!(Asciicast, id)
   end
+
   def get_asciicast!(thing) when is_binary(thing) do
-    q = if String.length(thing) == 25 do
-      from a in Asciicast, where: a.secret_token == ^thing
-    else
-      case Integer.parse(thing) do
-        {id, ""} ->
-          from a in Asciicast, where: a.private == false and a.id == ^id
-        _ ->
-          from a in Asciicast, where: false
+    q =
+      if String.length(thing) == 25 do
+        from(a in Asciicast, where: a.secret_token == ^thing)
+      else
+        case Integer.parse(thing) do
+          {id, ""} ->
+            from(a in Asciicast, where: a.private == false and a.id == ^id)
+
+          _ ->
+            from(a in Asciicast, where: false)
+        end
       end
-    end
 
     Repo.one!(q)
   end

      ["{" <> _, _] ->
        asciicast =
          asciicast_file_path
          |> File.read!
          |> Poison.decode!

        1 = asciicast["version"]


  defp extract_v2_metadata(path) do
    with {:ok, line} when is_binary(line) <- File.open(path, fn f -> IO.read(f, :line) end),
         {:ok, %{"version" => 2} = header} <- decode_json(line) do
      metadata = %{
        version: 2,
        terminal_columns: header["width"],
        terminal_lines: header["height"],
        terminal_type: get_in(header, ["env", "TERM"]),
        command: header["command"],
        duration: get_v2_duration(path),
        recorded_at: header["timestamp"] && Timex.from_unix(header["timestamp"]),
        title: header["title"],
        theme_fg: get_in(header, ["theme", "fg"]),
        theme_bg: get_in(header, ["theme", "bg"]),
        theme_palette: get_in(header, ["theme", "palette"]),
        idle_time_limit: header["idle_time_limit"],
        shell: get_in(header, ["env", "SHELL"])
      }

      {:ok, metadata}
    else
      {:ok, :eof} ->
        {:error, :unknown_format}

      {:ok, %{"version" => version}} ->
        {:error, {:unsupported_format, version}}

      {:error, :invalid} ->
        {:error, :unknown_format}
    end
