feat: import with verification, and a Wanted view of its own (M502 #5522)
release / govulncheck (push) Successful in 14s
release / web (push) Failing after 15s
release / go (push) Failing after 1m16s
release / integration (push) Failing after 4m49s
release / android (push) Successful in 4m59s
release / Build signed APK (releases and dev) (push) Successful in 5m14s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped

A finished download is checked against MusicBrainz before anything is
filed: the files are paired with an edition's tracks by position or path,
and AcoustID, tag ids, lengths and titles say whether it is the album.
What is the album is copied into the library as
Artist/Album (Year)/Artist - Album - NN - Title, tagged with Picard's
MusicBrainz ids, and scanned; the download keeps seeding. What is not is
refused: set aside, removed from the client, and the album searched for
again. A download the check cannot settle waits for a person, who imports
it anyway or refuses it. Tracks the library already holds are skipped.

The wanted list leaves Admin for a top-level Wanted view, admin-only and
web-only, with tabs for Wanted, Activity (downloads and their imports,
the ones needing a person first), Missing files, Held, Following (with the
release-type profiles, moved off Integrations) and Blocked. The search
settings gain "File new music into" when the library has several folders.

The search pass logs why each failed search failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 10:36:21 -04:00
co-authored by Claude Opus 5.5
parent 77081f1cef
commit ebbc49b902
63 changed files with 4892 additions and 555 deletions
+3
View File
@@ -48,6 +48,9 @@ export const qk = {
// Search and grab (M502 #5521).
wantCandidates: (wantId: string) => ['wantCandidates', wantId] as const,
searchSettings: () => ['searchSettings'] as const,
// The Wanted view's Activity and Blocked tabs (#5522).
downloads: () => ['adminWants', 'downloads'] as const,
releaseBlocks: () => ['adminWants', 'releaseBlocks'] as const,
myQuarantine: () => ['myQuarantine'] as const,
adminQuarantine: () => ['adminQuarantine'] as const,
adminQuarantineActions: (limit?: number) =>
+90 -1
View File
@@ -606,11 +606,32 @@ export type WantSearch = {
error: string;
};
// What an import made of a finished download (M502 #5522).
export type ImportState =
| ''
| 'downloading'
| 'waiting'
| 'importing'
| 'imported'
| 'refused'
| 'review'
| 'held'
| 'failed';
// A want's latest download, running or ended.
export type WantGrab = {
id: string;
name: string;
grabbed_at: string;
origin: 'schedule' | 'operator';
quality: string;
live: boolean;
end_reason: string;
progress: number;
import_state: ImportState;
import_reason: string;
imported_at: string | null;
imported_files: number;
};
// Search and grab (M502 #5521) ----------------------------------------------
@@ -685,9 +706,77 @@ export type SearchSettings = {
tiers: QualityTier[];
last_pass_at: string | null;
last_pass: SearchPass;
// The library folder new music is filed into ("" = the first of
// scan_paths), and the library's folders (#5522).
import_root: string;
scan_paths: string[];
};
export type WantCounts = { wanted: number; missing: number; held: number; following: number };
export type WantCounts = {
wanted: number;
missing: number;
held: number;
following: number;
// Downloads running, those of them waiting on a person, releases set aside.
activity: number;
attention: number;
blocked: number;
};
// What an import's check counted (#5522).
export type ImportEvidence = {
files: number;
tracks: number;
identified: number;
recordings: number;
lengths: number;
titles: number;
group_tag?: string;
album_tag?: string;
fingerprinted: boolean;
};
// One download on the Activity tab.
export type Download = {
id: string;
want_id: string | null;
want_title: string;
want_artist: string;
name: string;
indexer: string;
client: string;
quality: string;
origin: 'schedule' | 'operator';
grabbed_at: string;
ended_at: string | null;
end_reason: string;
progress: number;
import_state: ImportState;
import_reason: string;
imported_at: string | null;
imported_files: number;
destination: string;
edition?: string;
evidence?: ImportEvidence;
files: string[];
skipped: number;
rehomed_from?: string;
};
export type DownloadsPage = { items: Download[]; limit: number; offset: number };
// A release set aside: by a person, by its files, or by an import's check.
export type ReleaseBlock = {
info_hash: string;
name: string;
reason: 'operator' | 'files' | 'import';
detail: string;
blocked_at: string;
want_title: string;
want_artist: string;
};
export type ReleaseBlocksPage = { items: ReleaseBlock[]; limit: number; offset: number };
export type WantsPage = Page<Want> & { counts: WantCounts };
+52
View File
@@ -3,7 +3,9 @@ import { api } from './client';
import { qk } from './queries';
import type {
Candidate,
DownloadsPage,
Follow,
ReleaseBlocksPage,
FollowState,
ReleaseProfile,
ReleaseProfileInput,
@@ -157,6 +159,56 @@ export async function putSearchSettings(body: {
auto_grab: boolean;
search_interval_hours: number;
allowed_qualities: string[];
import_root: string;
}): Promise<SearchSettings> {
return api.put<SearchSettings>('/api/admin/acquisition/settings', body);
}
// Downloads and their imports (M502 #5522) ----------------------------------
// A page holding fewer than it asked for is the last.
function nextOffset(last: { items: unknown[]; limit: number; offset: number }): number | undefined {
return last.items.length < last.limit ? undefined : last.offset + last.items.length;
}
export async function listDownloads(offset: number = 0): Promise<DownloadsPage> {
return api.get<DownloadsPage>(`/api/admin/downloads?offset=${offset}`);
}
// Running downloads first; refreshed every few seconds while one runs.
export function createDownloadsQuery() {
return createInfiniteQuery({
queryKey: qk.downloads(),
queryFn: ({ pageParam }) => listDownloads(pageParam as number),
initialPageParam: 0,
getNextPageParam: nextOffset,
refetchInterval: (q) =>
q.state.data?.pages[0]?.items.some((d) => !d.ended_at) ? 5_000 : false
});
}
export async function importAnyway(id: string): Promise<void> {
await api.post(`/api/admin/downloads/${id}/import`, {});
}
export async function retryImport(id: string): Promise<void> {
await api.post(`/api/admin/downloads/${id}/retry`, {});
}
export async function refuseDownload(id: string): Promise<void> {
await api.post(`/api/admin/downloads/${id}/refuse`, {});
}
export async function listReleaseBlocks(offset: number = 0): Promise<ReleaseBlocksPage> {
return api.get<ReleaseBlocksPage>(`/api/admin/release-blocks?offset=${offset}`);
}
export function createReleaseBlocksQuery() {
return createInfiniteQuery({
queryKey: qk.releaseBlocks(),
queryFn: ({ pageParam }) => listReleaseBlocks(pageParam as number),
initialPageParam: 0,
getNextPageParam: nextOffset,
staleTime: 30_000
});
}