feat: search and grab — music release names, a quality ladder, a paced search schedule and one live grab per want (M502 #5521)
release / govulncheck (push) Successful in 21s
release / go (push) Failing after 33s
release / web (push) Successful in 56s
release / integration (push) Failing after 4m48s
release / android (push) Successful in 5m6s
release / Build signed APK (releases and dev) (push) Successful in 5m16s
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
release / govulncheck (push) Successful in 21s
release / go (push) Failing after 33s
release / web (push) Successful in 56s
release / integration (push) Failing after 4m48s
release / android (push) Successful in 5m6s
release / Build signed APK (releases and dev) (push) Successful in 5m16s
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
- internal/release: reads a release name (format, bitrate, bit depth and sample rate, source, year, video, discography) and judges it against the album wanted: the artist and title must be in it; video rips, discographies, other versions (drumless, instrumental, karaoke, remix, live unless the album is live…) and singles or EPs for an album are refused. Quality tiers on Lidarr's ladder; a .torrent's file list is read for format, video files and a track count short of the album. - internal/acquire: fan-out across every search source with a narrowed search kept, a process-wide pacer per source, every candidate judged and kept with its reasons, and the grab: one live grab per want, tie-broken (a person's grab beats the schedule's; a better release replaces a worse one unless it is nearly done). Each download lands in its own folder under the client's downloads folder. - internal/wanted: the search schedule, every ten minutes, never-searched first, then requests, missing files and followed artists, taking the best release when auto-grab is on (the default). - Migration 0082: acquisition_settings (auto-grab, interval, allowed qualities seeded from Lidarr's "Any"), want search columns, want_candidates, grabs, release_blocks. - Web: the Wanted page shows each want's last search, a Search button and every release found with its verdict (Grab, Grab anyway, Never this one, Allow again). Integrations gains "Searching and grabbing". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,9 @@ export const qk = {
|
||||
adminFollows: () => ['adminFollows'] as const,
|
||||
adminFollow: (artistMbid: string) => ['adminFollow', artistMbid] as const,
|
||||
releaseProfiles: () => ['releaseProfiles'] as const,
|
||||
// Search and grab (M502 #5521).
|
||||
wantCandidates: (wantId: string) => ['wantCandidates', wantId] as const,
|
||||
searchSettings: () => ['searchSettings'] as const,
|
||||
myQuarantine: () => ['myQuarantine'] as const,
|
||||
adminQuarantine: () => ['adminQuarantine'] as const,
|
||||
adminQuarantineActions: (limit?: number) =>
|
||||
|
||||
@@ -590,6 +590,101 @@ export type Want = {
|
||||
wanted_at: string;
|
||||
held_at: string | null;
|
||||
image_url: string;
|
||||
// The search schedule's last look, and the download running (#5521).
|
||||
search?: WantSearch | null;
|
||||
grab?: WantGrab | null;
|
||||
};
|
||||
|
||||
export type SearchOutcome = 'grabbed' | 'waiting' | 'nothing' | 'error';
|
||||
|
||||
export type WantSearch = {
|
||||
searched_at: string;
|
||||
outcome: SearchOutcome;
|
||||
considered: number;
|
||||
best_release: string;
|
||||
best_verdict: string;
|
||||
error: string;
|
||||
};
|
||||
|
||||
export type WantGrab = {
|
||||
name: string;
|
||||
grabbed_at: string;
|
||||
origin: 'schedule' | 'operator';
|
||||
quality: string;
|
||||
};
|
||||
|
||||
// Search and grab (M502 #5521) ----------------------------------------------
|
||||
|
||||
export type CandidateVerdict = 'grab' | 'review' | 'refused' | 'rejected' | 'blocked';
|
||||
|
||||
// One release a want's last search found, with what was decided about it.
|
||||
export type Candidate = {
|
||||
key: string;
|
||||
name: string;
|
||||
info_hash: string;
|
||||
indexer: string;
|
||||
size_bytes: number;
|
||||
seeders: number;
|
||||
files_count: number;
|
||||
format: string;
|
||||
quality: string;
|
||||
year: number;
|
||||
verdict: CandidateVerdict;
|
||||
reason: string;
|
||||
reasons: { kind: 'hard' | 'soft'; code: string; text: string }[];
|
||||
folded_from: string[];
|
||||
searched_at: string;
|
||||
downloading: boolean;
|
||||
};
|
||||
|
||||
export type Narrowing = { source: string; label: string; reason: string };
|
||||
|
||||
export type SearchResult = {
|
||||
outcome: SearchOutcome;
|
||||
considered: number;
|
||||
best_release: string;
|
||||
best_verdict: string;
|
||||
grabbed?: string;
|
||||
narrowed: Narrowing[];
|
||||
error?: string;
|
||||
};
|
||||
|
||||
export type GrabResult = {
|
||||
added: boolean;
|
||||
refused: boolean;
|
||||
gone: boolean;
|
||||
unconfigured: boolean;
|
||||
missing?: string;
|
||||
kept: boolean;
|
||||
replaced: boolean;
|
||||
verdict?: CandidateVerdict;
|
||||
reason?: string;
|
||||
error?: string;
|
||||
};
|
||||
|
||||
export type QualityTier = { tier: string; label: string; what: string };
|
||||
|
||||
// The last scheduled pass; empty before the first.
|
||||
export type SearchPass = {
|
||||
looked?: number;
|
||||
grabbed?: number;
|
||||
waiting?: number;
|
||||
nothing?: number;
|
||||
failed?: number;
|
||||
paced?: boolean;
|
||||
off?: boolean;
|
||||
unconfigured?: boolean;
|
||||
auto_grab?: boolean;
|
||||
error?: string;
|
||||
};
|
||||
|
||||
export type SearchSettings = {
|
||||
auto_grab: boolean;
|
||||
search_interval_hours: number;
|
||||
allowed_qualities: string[];
|
||||
tiers: QualityTier[];
|
||||
last_pass_at: string | null;
|
||||
last_pass: SearchPass;
|
||||
};
|
||||
|
||||
export type WantCounts = { wanted: number; missing: number; held: number; following: number };
|
||||
|
||||
@@ -2,11 +2,15 @@ import { createInfiniteQuery, createQuery } from '@tanstack/svelte-query';
|
||||
import { api } from './client';
|
||||
import { qk } from './queries';
|
||||
import type {
|
||||
Candidate,
|
||||
Follow,
|
||||
FollowState,
|
||||
ReleaseProfile,
|
||||
ReleaseProfileInput,
|
||||
ReleaseProfilesResponse,
|
||||
GrabResult,
|
||||
SearchResult,
|
||||
SearchSettings,
|
||||
WantState,
|
||||
WantsPage
|
||||
} from './types';
|
||||
@@ -100,3 +104,59 @@ export async function updateReleaseProfile(id: string, body: ReleaseProfileInput
|
||||
export async function deleteReleaseProfile(id: string): Promise<void> {
|
||||
await api.del(`/api/admin/release-profiles/${id}`);
|
||||
}
|
||||
|
||||
// Search and grab (M502 #5521): each want's last search, a person's Search,
|
||||
// Grab and "never this one", and the schedule's settings.
|
||||
|
||||
export async function listCandidates(wantId: string): Promise<Candidate[]> {
|
||||
const res = await api.get<{ items: Candidate[] }>(`/api/admin/wanted/${wantId}/candidates`);
|
||||
return res.items;
|
||||
}
|
||||
|
||||
export function createCandidatesQuery(wantId: string) {
|
||||
return createQuery({
|
||||
queryKey: qk.wantCandidates(wantId),
|
||||
queryFn: () => listCandidates(wantId),
|
||||
staleTime: 30_000
|
||||
});
|
||||
}
|
||||
|
||||
// Searches now, as the schedule would: takes the best release when
|
||||
// auto-grab is on. Can take most of a minute.
|
||||
export async function searchWant(wantId: string): Promise<SearchResult> {
|
||||
return api.post<SearchResult>(`/api/admin/wanted/${wantId}/search`, {});
|
||||
}
|
||||
|
||||
// Takes the release named by key; force takes what the verdict would not.
|
||||
export async function grabCandidate(wantId: string, key: string, force: boolean): Promise<GrabResult> {
|
||||
return api.post<GrabResult>(`/api/admin/wanted/${wantId}/grab`, { key, force });
|
||||
}
|
||||
|
||||
// Never takes this release again, for any want.
|
||||
export async function blockCandidate(wantId: string, key: string): Promise<void> {
|
||||
await api.post(`/api/admin/wanted/${wantId}/block`, { key });
|
||||
}
|
||||
|
||||
export async function unblockRelease(infoHash: string): Promise<void> {
|
||||
await api.del(`/api/admin/release-blocks/${infoHash}`);
|
||||
}
|
||||
|
||||
export async function getSearchSettings(): Promise<SearchSettings> {
|
||||
return api.get<SearchSettings>('/api/admin/acquisition/settings');
|
||||
}
|
||||
|
||||
export function createSearchSettingsQuery() {
|
||||
return createQuery({
|
||||
queryKey: qk.searchSettings(),
|
||||
queryFn: getSearchSettings,
|
||||
staleTime: 30_000
|
||||
});
|
||||
}
|
||||
|
||||
export async function putSearchSettings(body: {
|
||||
auto_grab: boolean;
|
||||
search_interval_hours: number;
|
||||
allowed_qualities: string[];
|
||||
}): Promise<SearchSettings> {
|
||||
return api.put<SearchSettings>('/api/admin/acquisition/settings', body);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user