From c913be5ca211846bc36e86632dbc0440d037a0e8 Mon Sep 17 00:00:00 2001 From: kikootwo Date: Mon, 2 Feb 2026 12:51:06 -0500 Subject: [PATCH] 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. --- src/app/admin/components/RequestActionsDropdown.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app/admin/components/RequestActionsDropdown.tsx b/src/app/admin/components/RequestActionsDropdown.tsx index face4fe..884d867 100644 --- a/src/app/admin/components/RequestActionsDropdown.tsx +++ b/src/app/admin/components/RequestActionsDropdown.tsx @@ -52,11 +52,12 @@ export function RequestActionsDropdown({ const canDelete = true; // Admins can always delete // 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; if (isEbook && request.torrentUrl) { - // torrentUrl for ebooks is JSON array of slow download URLs - // Extract MD5 from URL pattern: /slow_download/[md5]/... + // torrentUrl for ebooks can be: + // 1. JSON array of slow download URLs (Anna's Archive) - extract MD5 + // 2. Plain URL string (indexer source) - use directly try { const urls = JSON.parse(request.torrentUrl); if (Array.isArray(urls) && urls.length > 0) { @@ -66,7 +67,11 @@ export function RequestActionsDropdown({ } } } 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:')) { viewSourceUrl = request.torrentUrl;