Remove shallow color wrapper

This commit is contained in:
Claudio Ortolina
2026-02-10 19:30:25 +00:00
parent 4ef09b47f4
commit 29b1c04433
3 changed files with 9 additions and 14 deletions
-1
View File
@@ -22,7 +22,6 @@ defmodule MusicLibrary do
- `MusicLibrary.ScrobbleRules` - Rules system for normalizing scrobbled track metadata - `MusicLibrary.ScrobbleRules` - Rules system for normalizing scrobbled track metadata
### Content and Metadata Management ### Content and Metadata Management
- `MusicLibrary.Colors` - Color extraction from album artwork using fast or slow algorithms
- `MusicLibrary.OnlineStoreTemplates` - Configurable templates for generating online store URLs - `MusicLibrary.OnlineStoreTemplates` - Configurable templates for generating online store URLs
- `MusicLibrary.Secrets` - Encrypted storage for API keys and sensitive configuration - `MusicLibrary.Secrets` - Encrypted storage for API keys and sensitive configuration
""" """
-11
View File
@@ -1,11 +0,0 @@
defmodule MusicLibrary.Colors do
alias MusicLibrary.Colors.{ColorFrequencyExtractor, EdgeWeightedExtractor}
def extract_colors(image_data, :fast) do
ColorFrequencyExtractor.extract_dominant_colors(image_data)
end
def extract_colors(image_data, :slow) do
EdgeWeightedExtractor.extract_dominant_colors(image_data)
end
end
+9 -2
View File
@@ -1,7 +1,8 @@
defmodule MusicLibrary.Worker.ExtractColors do defmodule MusicLibrary.Worker.ExtractColors do
use Oban.Worker, queue: :heavy_writes, max_attempts: 3 use Oban.Worker, queue: :heavy_writes, max_attempts: 3
alias MusicLibrary.{Assets, Colors, Records} alias MusicLibrary.{Assets, Records}
alias MusicLibrary.Colors.{ColorFrequencyExtractor, EdgeWeightedExtractor}
@impl Oban.Worker @impl Oban.Worker
def perform(%Oban.Job{args: %{"id" => record_id, "method" => method}}) do def perform(%Oban.Job{args: %{"id" => record_id, "method" => method}}) do
@@ -9,9 +10,15 @@ defmodule MusicLibrary.Worker.ExtractColors do
asset = Assets.get!(record.cover_hash) asset = Assets.get!(record.cover_hash)
method = String.to_existing_atom(method) method = String.to_existing_atom(method)
with {:ok, colors} <- Colors.extract_colors(asset.content, method), with {:ok, colors} <- extract_colors(asset.content, method),
{:ok, updated_record} <- Records.update_record(record, %{dominant_colors: colors}) do {:ok, updated_record} <- Records.update_record(record, %{dominant_colors: colors}) do
MusicLibrary.Records.notify_update(updated_record) MusicLibrary.Records.notify_update(updated_record)
end end
end end
defp extract_colors(image_data, :fast),
do: ColorFrequencyExtractor.extract_dominant_colors(image_data)
defp extract_colors(image_data, :slow),
do: EdgeWeightedExtractor.extract_dominant_colors(image_data)
end end