Support plain indexer URLs for ebook source

Update RequestActionsDropdown to handle ebook torrentUrl values that are plain indexer URLs in addition to JSON arrays of slow-download URLs. Clarify comment about audiobooks and indexer-sourced ebooks, and on JSON parse failure use the plain URL directly (unless it's a magnet: link) to build the view source URL.
This commit is contained in:
kikootwo
2026-02-02 12:51:06 -05:00
parent 9dd09ec836
commit c913be5ca2
@@ -52,11 +52,12 @@ export function RequestActionsDropdown({
const canDelete = true; // Admins can always delete const canDelete = true; // Admins can always delete
// View Source: For ebooks, extract MD5 from slow download URL and link to Anna's Archive // View Source: For ebooks, extract MD5 from slow download URL and link to Anna's Archive
// For audiobooks, show indexer page URL (not magnet links) // For audiobooks and indexer-sourced ebooks, show indexer page URL (not magnet links)
let viewSourceUrl: string | null = null; let viewSourceUrl: string | null = null;
if (isEbook && request.torrentUrl) { if (isEbook && request.torrentUrl) {
// torrentUrl for ebooks is JSON array of slow download URLs // torrentUrl for ebooks can be:
// Extract MD5 from URL pattern: /slow_download/[md5]/... // 1. JSON array of slow download URLs (Anna's Archive) - extract MD5
// 2. Plain URL string (indexer source) - use directly
try { try {
const urls = JSON.parse(request.torrentUrl); const urls = JSON.parse(request.torrentUrl);
if (Array.isArray(urls) && urls.length > 0) { if (Array.isArray(urls) && urls.length > 0) {
@@ -66,7 +67,11 @@ export function RequestActionsDropdown({
} }
} }
} catch { } catch {
// Not JSON, ignore // Not JSON - it's a plain URL from indexer source
// Use it directly if it's not a magnet link
if (!request.torrentUrl.startsWith('magnet:')) {
viewSourceUrl = request.torrentUrl;
}
} }
} else if (request.torrentUrl && !request.torrentUrl.startsWith('magnet:')) { } else if (request.torrentUrl && !request.torrentUrl.startsWith('magnet:')) {
viewSourceUrl = request.torrentUrl; viewSourceUrl = request.torrentUrl;