   end
 
   defp format_to_series(kitsu_series) do
+    series =
     %Series{
       canon_title: kitsu_series["canonicalTitle"],
       titles: kitsu_series["titles"],

  	full_path = Application.get_env(:animu, :file_root) <> path
    if !(File.dir?(path)), do: File.mkdir_p!(full_path)
   	File.write!(full_path <> filename, body)
		path <> filename
	end

end

      kitsu_rating: kitsu_series["averageRating"],
      kitsu_id: kitsu_series["id"],

      started_airing_date: get_date(kitsu_series["startDate"]),
      finished_airing_date: get_date(kitsu_series["endDate"]),
    }
  end

  defp get_date(date) do
    case date do
      nil -> nil
      _ -> Date.from_iso8601!(date)
    end
  end

  def get_images(series = %Series{directory: nil}), do: series
  def get_images(series) do
		cover_image =
      get_map_images(series.cover_image, series.directory, @cover_path)

		poster_image =
      get_map_images(series.poster_image, series.directory, @poster_path)

		gallery =
      get_map_images(series.gallery, series.directory, @gallery_path)

    changes = %{gallery: gallery, cover_image: cover_image, poster_image: poster_image}
		Map.merge(series, changes)
  end

  defp get_map_images(nil, _, _), do: nil
  defp get_map_images(map, series_path, image_path) do
    Map.new(map, fn {k, v} ->
      filename =  "/" <> k <> ".jpg"
      path = series_path <> image_path
		 	v = image_path <> get_image(v, path, filename)
		 	{k, v}
    end)
  end
