Fix API collection record cover URLs
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
defmodule MusicLibraryWeb.CollectionJSON do
|
defmodule MusicLibraryWeb.CollectionJSON do
|
||||||
use MusicLibraryWeb, :json
|
use MusicLibraryWeb, :json
|
||||||
|
|
||||||
|
alias MusicLibrary.Assets.Transform
|
||||||
|
|
||||||
def show(%{record: record}) do
|
def show(%{record: record}) do
|
||||||
record(record)
|
record(record)
|
||||||
end
|
end
|
||||||
@@ -19,8 +21,8 @@ defmodule MusicLibraryWeb.CollectionJSON do
|
|||||||
id: record.id,
|
id: record.id,
|
||||||
artists: Enum.map(record.artists, & &1.name),
|
artists: Enum.map(record.artists, & &1.name),
|
||||||
title: record.title,
|
title: record.title,
|
||||||
cover_url: url(~p"/api/covers/#{record.cover_hash}"),
|
cover_url: url(~p"/api/covers/#{%Transform{hash: record.cover_hash}}"),
|
||||||
thumb_url: url(~p"/api/covers/#{record.cover_hash}?#{[size: 480]}")
|
thumb_url: url(~p"/api/covers/#{%Transform{hash: record.cover_hash, width: 480}}")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ defmodule MusicLibraryWeb.Router do
|
|||||||
get "/collection/latest", CollectionController, :latest
|
get "/collection/latest", CollectionController, :latest
|
||||||
get "/collection/random", CollectionController, :random
|
get "/collection/random", CollectionController, :random
|
||||||
get "/collection", CollectionController, :index
|
get "/collection", CollectionController, :index
|
||||||
get "/covers/:hash", CoverController, :show
|
get "/covers/:transform_payload", CoverController, :show
|
||||||
get "/backup", ArchiveController, :backup
|
get "/backup", ArchiveController, :backup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ defmodule MusicLibraryWeb.CollectionControllerTest do
|
|||||||
"id" => record.id,
|
"id" => record.id,
|
||||||
"artists" => ["Steven Wilson"],
|
"artists" => ["Steven Wilson"],
|
||||||
"title" => record.title,
|
"title" => record.title,
|
||||||
"cover_url" => "http://localhost:4002/api/covers/#{record.cover_hash}",
|
"cover_url" =>
|
||||||
"thumb_url" => "http://localhost:4002/api/covers/#{record.cover_hash}?size=480"
|
"http://localhost:4002/api/covers/eyJoYXNoIjoiNTk5NDA3RERGNjk5MDdENEE2MEZFMTNDQ0FBODI0RDI1Q0YwOERDMTI0RkQ2QUEzRThFN0VDRDk4Qzg4NUZGRSIsIndpZHRoIjpudWxsfQ",
|
||||||
|
"thumb_url" =>
|
||||||
|
"http://localhost:4002/api/covers/eyJoYXNoIjoiNTk5NDA3RERGNjk5MDdENEE2MEZFMTNDQ0FBODI0RDI1Q0YwOERDMTI0RkQ2QUEzRThFN0VDRDk4Qzg4NUZGRSIsIndpZHRoIjo0ODB9"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -57,8 +59,10 @@ defmodule MusicLibraryWeb.CollectionControllerTest do
|
|||||||
"id" => record.id,
|
"id" => record.id,
|
||||||
"artists" => ["Steven Wilson"],
|
"artists" => ["Steven Wilson"],
|
||||||
"title" => record.title,
|
"title" => record.title,
|
||||||
"cover_url" => "http://localhost:4002/api/covers/#{record.cover_hash}",
|
"cover_url" =>
|
||||||
"thumb_url" => "http://localhost:4002/api/covers/#{record.cover_hash}?size=480"
|
"http://localhost:4002/api/covers/eyJoYXNoIjoiNTk5NDA3RERGNjk5MDdENEE2MEZFMTNDQ0FBODI0RDI1Q0YwOERDMTI0RkQ2QUEzRThFN0VDRDk4Qzg4NUZGRSIsIndpZHRoIjpudWxsfQ",
|
||||||
|
"thumb_url" =>
|
||||||
|
"http://localhost:4002/api/covers/eyJoYXNoIjoiNTk5NDA3RERGNjk5MDdENEE2MEZFMTNDQ0FBODI0RDI1Q0YwOERDMTI0RkQ2QUEzRThFN0VDRDk4Qzg4NUZGRSIsIndpZHRoIjo0ODB9"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -87,8 +91,10 @@ defmodule MusicLibraryWeb.CollectionControllerTest do
|
|||||||
"id" => record.id,
|
"id" => record.id,
|
||||||
"artists" => ["Steven Wilson"],
|
"artists" => ["Steven Wilson"],
|
||||||
"title" => record.title,
|
"title" => record.title,
|
||||||
"cover_url" => "http://localhost:4002/api/covers/#{record.cover_hash}",
|
"cover_url" =>
|
||||||
"thumb_url" => "http://localhost:4002/api/covers/#{record.cover_hash}?size=480"
|
"http://localhost:4002/api/covers/eyJoYXNoIjoiNTk5NDA3RERGNjk5MDdENEE2MEZFMTNDQ0FBODI0RDI1Q0YwOERDMTI0RkQ2QUEzRThFN0VDRDk4Qzg4NUZGRSIsIndpZHRoIjpudWxsfQ",
|
||||||
|
"thumb_url" =>
|
||||||
|
"http://localhost:4002/api/covers/eyJoYXNoIjoiNTk5NDA3RERGNjk5MDdENEE2MEZFMTNDQ0FBODI0RDI1Q0YwOERDMTI0RkQ2QUEzRThFN0VDRDk4Qzg4NUZGRSIsIndpZHRoIjo0ODB9"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user