Raw importer for all cover images
This commit is contained in:
@@ -69,6 +69,21 @@ defmodule MusicLibrary.Records.Importer do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def import_all_cover_images do
|
||||||
|
Rec
|
||||||
|
|> MusicLibrary.Repo.all()
|
||||||
|
|> Task.async_stream(
|
||||||
|
fn r ->
|
||||||
|
if r.image_data == nil do
|
||||||
|
import_cover_image(r)
|
||||||
|
IO.puts("Imported cover image for #{r.title}")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
timeout: 10_000
|
||||||
|
)
|
||||||
|
|> Stream.run()
|
||||||
|
end
|
||||||
|
|
||||||
def import_all do
|
def import_all do
|
||||||
Rec
|
Rec
|
||||||
|> MusicLibrary.Repo.all()
|
|> MusicLibrary.Repo.all()
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ defmodule MusicLibraryWeb.ImageController do
|
|||||||
alias MusicLibrary.Records
|
alias MusicLibrary.Records
|
||||||
|
|
||||||
def show(conn, %{"record_id" => record_id}) do
|
def show(conn, %{"record_id" => record_id}) do
|
||||||
|
# TODO: better error handling
|
||||||
|
# TODO: serve correct caching headers
|
||||||
{:ok, image_data} = Records.get_image!(record_id)
|
{:ok, image_data} = Records.get_image!(record_id)
|
||||||
|
|
||||||
if image_data do
|
if image_data do
|
||||||
|
|||||||
Reference in New Issue
Block a user