feat: combine upload and Openverse into one import page
Adding music took two navigation items that each did half the job. The new Import page has both sources as tabs and one shared list of what was added in this session, with the reason for every failure and a link to the library. From computer: drop several MP3 or WAV files or pick them with a multi-select dialog. Files are imported one by one on a background thread with a progress bar, and a failing file does not stop the rest. Openverse: search and download show a progress ring with a status text. Results that are already in the library or have no duration are marked in their row and cannot be imported; a double-click imports. To detect duplicates, songs now store the Openverse result id. The repository adds the column to existing databases and a unique index keeps one song per Openverse result. Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a762a2f571
commit
0a0d8e1d4c
17 files changed
+582
-266
No files matched your search
@@ -9,11 +9,16 @@ public class OpenverseController(OpenverseClient client, SongRepository songs)
|
||||
public Task<IReadOnlyList<OpenverseTrack>> SearchAsync(string query, CancellationToken cancellationToken = default) =>
|
||||
client.SearchAsync(query, cancellationToken);
|
||||
|
||||
/// <summary>Ids of the Openverse results that are already in the library.</summary>
|
||||
public IReadOnlySet<string> ImportedIds() => songs.GetOpenverseIds();
|
||||
|
||||
/// <summary>Downloads the track and stores it as a song with its license and attribution.</summary>
|
||||
public async Task<Song> ImportAsync(OpenverseTrack track, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (track.Duration is not { } duration)
|
||||
throw new OpenverseException("This result has no duration and cannot be imported.");
|
||||
if (track.Id.Length > 0 && ImportedIds().Contains(track.Id))
|
||||
throw new OpenverseException($"\"{track.Title}\" is already in the library.");
|
||||
|
||||
var path = await client.DownloadAsync(track, cancellationToken);
|
||||
var song = new Song
|
||||
@@ -25,6 +30,7 @@ public class OpenverseController(OpenverseClient client, SongRepository songs)
|
||||
Source = SongSource.Openverse,
|
||||
License = track.LicenseName,
|
||||
Attribution = track.Attribution,
|
||||
OpenverseId = track.Id.Length > 0 ? track.Id : null,
|
||||
};
|
||||
try
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user