Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions apps/web/src/api/schema.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 57 additions & 8 deletions apps/web/src/components/CollectionReview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ const filesFor = (entry: Entry, recording: string) => {
export default function CollectionReview({
searchId,
resultId,
source,
close,
}: {
searchId: string;
resultId: string;
source?: string;
close: () => void;
}) {
const cache = useQueryClient();
Expand All @@ -42,6 +44,15 @@ export default function CollectionReview({
const key = useRef(randomUUID());
const [recordings, setRecordings] = useState<Record<string, string>>({});
const [artifactId, setArtifactId] = useState<string>();
const [metadataDownloader, setMetadataDownloader] = useState("");
const metadataClients = useQuery({
queryKey: ["downloaders"],
enabled: source === "prowlarr",
queryFn: async () => result(await api.GET("/api/downloaders")),
});
const metadataDownloaders = (metadataClients.data || []).filter(
(client) => client.enabled && client.kind === "qbittorrent",
);
const [choices, setChoices] = useState<Record<string, Choice>>({});
const [catalogChoices, setCatalogChoices] = useState<Record<string, string>>(
{},
Expand All @@ -51,11 +62,19 @@ export default function CollectionReview({
result(
await api.POST(
"/api/source-searches/{search_id}/results/{result_id}/artifact",
{ params: { path: { search_id: searchId, result_id: resultId } } },
{
params: { path: { search_id: searchId, result_id: resultId } },
body: metadataDownloader
? { downloader_id: metadataDownloader }
: undefined,
},
),
),
onSuccess: (artifact) => setArtifactId(artifact.id),
});
const needsMagnetResolver =
source === "prowlarr" &&
!!inspect.error?.message.includes("redirects to a magnet");
const started = useRef(false);
useEffect(() => {
if (!started.current) {
Expand Down Expand Up @@ -423,13 +442,43 @@ export default function CollectionReview({
{!data ? (
<div className="collection-loading">
{inspect.isError || preview.isError ? (
<button
onClick={() =>
artifactId ? preview.refetch() : inspect.mutate()
}
>
Try matching again
</button>
<>
{needsMagnetResolver && (
<div className="source-magnet-resolver">
<label>
qBittorrent for magnet inspection
<select
value={metadataDownloader}
onChange={(event) =>
setMetadataDownloader(event.target.value)
}
disabled={inspect.isPending}
>
<option value="">Choose a qBittorrent connection</option>
{metadataDownloaders.map((client) => (
<option key={client.id} value={client.id}>
{client.name}
</option>
))}
</select>
</label>
{!metadataDownloaders.length && (
<p className="muted">
Enable a qBittorrent connection in{" "}
<Link to="/settings#downloaders">Download settings</Link>.
</p>
)}
</div>
)}
<button
disabled={needsMagnetResolver && !metadataDownloader}
onClick={() =>
artifactId ? preview.refetch() : inspect.mutate()
}
>
{inspect.isError ? "Retry inspection" : "Try matching again"}
</button>
</>
) : (
<>
<Loading />
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/components/SourceReleaseDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default function SourceReleaseDetails({
reviewContext={reviewContext}
searchId={searchId}
resultId={item.id}
source={original.source}
title={release.title}
disabled={disabled}
download={item.download}
Expand Down
59 changes: 56 additions & 3 deletions apps/web/src/components/SourceReleaseDownload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const labels: Record<SavedDownload["state"], string> = {
export default function SourceReleaseDownload({
searchId,
resultId,
source,
title,
disabled,
disabledReason,
Expand All @@ -36,6 +37,7 @@ export default function SourceReleaseDownload({
}: {
searchId: string;
resultId: string;
source?: string;
title: string;
disabled: boolean;
disabledReason?: string;
Expand All @@ -57,6 +59,15 @@ export default function SourceReleaseDownload({
});
const [operationId, setOperationId] = useState<string>();
const [useWedge, setUseWedge] = useState(false);
const [metadataDownloader, setMetadataDownloader] = useState("");
const metadataClients = useQuery({
queryKey: ["downloaders"],
enabled: source === "prowlarr",
queryFn: async () => result(await api.GET("/api/downloaders")),
});
const metadataDownloaders = (metadataClients.data || []).filter(
(client) => client.enabled && client.kind === "qbittorrent",
);
const inspect = useMutation({
mutationFn: async () =>
result(
Expand All @@ -67,6 +78,9 @@ export default function SourceReleaseDownload({
path: { search_id: searchId, result_id: resultId },
query: offerWedge && useWedge ? { use_wedge: true } : {},
},
body: metadataDownloader
? { downloader_id: metadataDownloader }
: undefined,
},
),
),
Expand All @@ -83,6 +97,9 @@ export default function SourceReleaseDownload({
});
},
});
const needsMagnetResolver =
source === "prowlarr" &&
!!inspect.error?.message.includes("redirects to a magnet");
const start = useMutation({
mutationFn: async (spendWedge: boolean) =>
result(
Expand Down Expand Up @@ -275,6 +292,7 @@ export default function SourceReleaseDownload({
<CollectionReview
searchId={searchId}
resultId={resultId}
source={source}
close={() => setReviewCollection(false)}
/>
</Suspense>
Expand Down Expand Up @@ -320,9 +338,44 @@ export default function SourceReleaseDownload({
</p>
)}
{inspect.error && (
<p className="error" role="alert">
{inspect.error.message}
</p>
<div className="source-magnet-resolver">
<p className="error" role="alert">
{inspect.error.message}
</p>
{needsMagnetResolver && (
<>
<label>
qBittorrent for magnet inspection
<select
value={metadataDownloader}
onChange={(event) =>
setMetadataDownloader(event.target.value)
}
disabled={inspect.isPending}
>
<option value="">Choose a qBittorrent connection</option>
{metadataDownloaders.map((client) => (
<option key={client.id} value={client.id}>
{client.name}
</option>
))}
</select>
</label>
<button
disabled={!metadataDownloader || inspect.isPending}
onClick={() => inspect.mutate()}
>
Retry inspection
</button>
{!metadataDownloaders.length && (
<p className="muted">
Enable a qBittorrent connection in{" "}
<Link to="/settings#downloaders">Download settings</Link>.
</p>
)}
</>
)}
</div>
)}
</>
);
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/pages/BookSources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ function Results({
key={item.download?.operation_id || "unselected"}
searchId={data.id}
resultId={item.id}
source={item.release.source}
title={item.release.title}
download={item.download}
offerWedge={
Expand Down
24 changes: 24 additions & 0 deletions apps/web/src/pages/PreferenceFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,30 @@ export default function PreferenceFields({
</div>
{origin("allow_unknown_seeders")}
</div>
<div className="setting-inline-option">
<label className="check-label">
<input
type="checkbox"
checked={effective.allow_incomplete_release_metadata ?? false}
onChange={(event) =>
onChange({
...overrides,
allow_incomplete_release_metadata: event.target.checked,
})
}
/>
Allow incomplete release metadata
</label>
<div className="setting-help-row">
<SettingHelp label="download preferences">
Off by default. When enabled, releases with incomplete title,
author or medium details can proceed to the existing file and
import checks. Known mismatches, unsupported formats and partial
content remain blocked.
</SettingHelp>
</div>
{origin("allow_incomplete_release_metadata")}
</div>
<div className="setting-inline-option">
<label className="check-label">
<input
Expand Down
49 changes: 42 additions & 7 deletions apps/web/src/pages/ProwlarrSources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function ProwlarrSources({
const [medium, setMedium] = useState<Search["medium"]>("all");
const [omitted, setOmitted] = useState<number[]>([]);
const [batches, setBatches] = useState<Batch[]>([]);
const [downloader, setDownloader] = useState("");
const [submitted, setSubmitted] = useState({ q: "", medium });
const navigate = useNavigate();
const cache = useQueryClient();
Expand All @@ -44,6 +45,13 @@ export default function ProwlarrSources({
queryFn: async () =>
result(await api.GET("/api/sources/prowlarr/indexers")),
});
const clients = useQuery({
queryKey: ["downloaders"],
queryFn: async () => result(await api.GET("/api/downloaders")),
});
const qbitClients = (clients.data || []).filter(
(client) => client.enabled && client.kind === "qbittorrent",
);
const eligible = (indexers.data || []).filter(
(i) => i.enabled && i.supports_search && !i.excluded,
);
Expand Down Expand Up @@ -117,6 +125,7 @@ export default function ProwlarrSources({
result(
await api.POST("/api/sources/prowlarr/results/{result_id}/artifact", {
params: { path: { result_id: id } },
body: downloader ? { downloader_id: downloader } : undefined,
}),
),
onSuccess: (artifact) =>
Expand All @@ -143,7 +152,7 @@ export default function ProwlarrSources({
Source settings →
</Link>
)}
<Notice error={indexers.error} />
<Notice error={indexers.error || clients.error} />
<Notice error={inspect.error} />
<form
className="panel editor"
Expand Down Expand Up @@ -211,12 +220,38 @@ export default function ProwlarrSources({
{search.isPending ? "Searching sources…" : "Search sources"}
</button>
</form>
<p className="muted">
Catalog identity, narrator, language and file format stay unknown when
an indexer does not supply them. Torrent files go to qBittorrent and NZB
files go to SABnzbd or NZBGet. Magnet-only and direct links are not
supported.
</p>
<div className="panel editor">
<label htmlFor="prowlarr-magnet-downloader">
qBittorrent for magnet inspection (optional)
</label>
<select
id="prowlarr-magnet-downloader"
value={downloader}
onChange={(event) => setDownloader(event.target.value)}
disabled={busy}
>
<option value="">
Choose only if a result redirects to a magnet
</option>
{qbitClients.map((client) => (
<option key={client.id} value={client.id}>
{client.name}
</option>
))}
</select>
<p className="muted">
Catalog identity, narrator, language and file format stay unknown when
an indexer does not supply them. Torrent and NZB files use their
configured downloaders. Magnet redirects require qBittorrent for
metadata inspection; direct HTTP(S) links remain supported.
</p>
{!qbitClients.length && (
<p className="muted">
No enabled qBittorrent connection is available.{" "}
<Link to="/settings#downloaders">Configure a downloader</Link>.
</p>
)}
</div>
<div aria-live="polite">
{batches.map((batch) => (
<section
Expand Down
Loading