feat(metadata): implement single-track metadata editor page (§A7)
Replace the placeholder with a controlled form for title/artist/album/ year/genre/track number, an AcoustID "find matches" action showing ranked candidates with confidence, a diff/apply picker, a re-enrich button, and save via PUT /metadata. Adds matches/apply API endpoints, mappers, types, and en/ru i18n strings. Batch editor remains a placeholder (deferred).
This commit is contained in:
@@ -2,10 +2,12 @@ import { api } from '../index';
|
||||
import {
|
||||
toAlbum,
|
||||
toArtist,
|
||||
toMetadataMatch,
|
||||
toPage,
|
||||
toTrack,
|
||||
type RawAlbum,
|
||||
type RawArtist,
|
||||
type RawMetadataMatch,
|
||||
type RawPaged,
|
||||
type RawTrack,
|
||||
} from '../mappers';
|
||||
@@ -13,6 +15,8 @@ import type {
|
||||
Track,
|
||||
Album,
|
||||
Artist,
|
||||
MetadataEdit,
|
||||
MetadataMatch,
|
||||
PaginatedResponse,
|
||||
LibraryFilters,
|
||||
} from '../types';
|
||||
@@ -161,6 +165,41 @@ export const libraryApi = api.injectEndpoints({
|
||||
}),
|
||||
providesTags: ['Track', 'Album', 'Artist'],
|
||||
}),
|
||||
getMetadataMatches: build.query<MetadataMatch[], string>({
|
||||
query: (trackId) => `/tracks/${trackId}/metadata/matches`,
|
||||
transformResponse: (raw: { items: RawMetadataMatch[] }) =>
|
||||
raw.items.map(toMetadataMatch),
|
||||
}),
|
||||
applyMetadata: build.mutation<
|
||||
Track,
|
||||
{ trackId: string; edit: MetadataEdit }
|
||||
>({
|
||||
query: ({ trackId, edit }) => ({
|
||||
url: `/tracks/${trackId}/metadata`,
|
||||
method: 'PUT',
|
||||
body: {
|
||||
title: edit.title,
|
||||
artist_name: edit.artistName,
|
||||
album_title: edit.albumTitle,
|
||||
year: edit.year,
|
||||
genre: edit.genre,
|
||||
track_number: edit.trackNumber,
|
||||
},
|
||||
}),
|
||||
transformResponse: (raw: RawTrack) => toTrack(raw),
|
||||
invalidatesTags: (_r, _e, { trackId }) => [
|
||||
{ type: 'Track', id: trackId },
|
||||
'Album',
|
||||
'Artist',
|
||||
],
|
||||
}),
|
||||
enrichTrack: build.mutation<{ track_id: string; job_id: string }, string>({
|
||||
query: (trackId) => ({
|
||||
url: `/tracks/${trackId}/metadata/enrich`,
|
||||
method: 'POST',
|
||||
}),
|
||||
invalidatesTags: (_r, _e, trackId) => [{ type: 'Track', id: trackId }],
|
||||
}),
|
||||
}),
|
||||
overrideExisting: false,
|
||||
});
|
||||
@@ -176,4 +215,7 @@ export const {
|
||||
useGetArtistAlbumsQuery,
|
||||
useGetArtistTracksQuery,
|
||||
useSearchLibraryQuery,
|
||||
useLazyGetMetadataMatchesQuery,
|
||||
useApplyMetadataMutation,
|
||||
useEnrichTrackMutation,
|
||||
} = libraryApi;
|
||||
|
||||
Reference in New Issue
Block a user