     end
   end
 
-  def create_asciicast(user, %{"meta" => meta,
-                               "stdout" => %Plug.Upload{} = data,
-                               "stdout_timing" => %Plug.Upload{} = timing}, overrides) do
+  def create_asciicast(
+        user,
+        %{
+          "meta" => meta,
+          "stdout" => %Plug.Upload{} = data,
+          "stdout_timing" => %Plug.Upload{} = timing
+        },
+        overrides
+      ) do
     {:ok, attrs} = extract_metadata(meta)
 
-    header = %{version: 2,
-               width: attrs[:terminal_columns],
-               height: attrs[:terminal_lines],
-               title: attrs[:title],
-               command: attrs[:command],
-               env: %{"SHELL" => attrs[:shell],
-                      "TERM" => attrs[:terminal_type]}}
+    header = %{
+      version: 2,
+      width: attrs[:terminal_columns],
+      height: attrs[:terminal_lines],
+      title: attrs[:title],
+      command: attrs[:command],
+      env: %{"SHELL" => attrs[:shell], "TERM" => attrs[:terminal_type]}
+    }
 
     header =
       header
       |> Enum.filter(fn {_k, v} -> v end)
       |> Enum.into(%{})
 
-    overrides = if uname = attrs[:uname] do
-      overrides
-      |> Map.put(:uname, uname)
-      |> Map.drop([:user_agent])
-    else
-      Map.put(overrides, :uname, uname)
-    end
+    overrides =
+      if uname = attrs[:uname] do
+        overrides
+        |> Map.put(:uname, uname)
+        |> Map.drop([:user_agent])
+      else
+        Map.put(overrides, :uname, uname)
+      end
 
     {:ok, tmp_path} = Briefly.create()
 

    :ok = FileStore.download_file(store_data_path, local_data_path)
    stdout_stream({local_timing_path, local_data_path})
  end
  def stdout_stream(%Asciicast{} = asciicast) do
    {:ok, local_path} = Briefly.create()
    store_path = Asciicast.file_store_path(asciicast, :file)
    :ok = FileStore.download_file(store_path, local_path)
    stdout_stream(local_path)
  end
  def stdout_stream(asciicast_file_path) when is_binary(asciicast_file_path) do
    first_two_lines =
      asciicast_file_path
      |> File.stream!([], :line)
      |> Stream.take(2)
      |> Enum.to_list

    case first_two_lines do
      ["{" <> _ = header_line, "[" <> _] ->

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

        1 = asciicast["version"]

