diff --git a/internal/service/site_adapter_nexusphp.go b/internal/service/site_adapter_nexusphp.go index af630fa..dd403c3 100644 --- a/internal/service/site_adapter_nexusphp.go +++ b/internal/service/site_adapter_nexusphp.go @@ -217,14 +217,14 @@ func nexusPHPTorrentRows(pageHTML string) []string { } func firstNexusPHPLink(row, path string) *nexusPHPLink { - pattern := regexp.MustCompile(`(?is)]*href\s*=\s*["']([^"']*` + regexp.QuoteMeta(path) + `[^"']*)["'][^>]*)>(.*?)`) + pattern := regexp.MustCompile(`(?is)]*href\s*=\s*["']([^"']*)["'][^>]*)>(.*?)`) for _, match := range pattern.FindAllStringSubmatch(row, -1) { if len(match) < 4 { continue } href := html.UnescapeString(strings.TrimSpace(match[2])) parsed, err := url.Parse(href) - if err != nil { + if err != nil || !nexusPHPLinkPathMatches(parsed, path) { continue } return &nexusPHPLink{ @@ -237,6 +237,22 @@ func firstNexusPHPLink(row, path string) *nexusPHPLink { return nil } +func nexusPHPLinkPathMatches(parsed *url.URL, want string) bool { + if parsed == nil { + return false + } + path := strings.TrimSpace(parsed.Path) + if path == "" { + path = strings.TrimSpace(parsed.Opaque) + } + path = strings.Trim(strings.ToLower(path), "/") + want = strings.Trim(strings.ToLower(strings.TrimSpace(want)), "/") + if path == "" || want == "" { + return false + } + return path == want || strings.HasSuffix(path, "/"+want) +} + func nexusPHPTitleFromLink(link nexusPHPLink) string { for _, attr := range []string{"title", "data-title"} { if value := htmlAttr(link.attrs, attr); value != "" { diff --git a/internal/service/site_adapter_test.go b/internal/service/site_adapter_test.go index 6b4a03d..1152c30 100644 --- a/internal/service/site_adapter_test.go +++ b/internal/service/site_adapter_test.go @@ -247,6 +247,24 @@ func TestParseNexusPHPHTMLModernRows(t *testing.T) { } } +func TestParseNexusPHPHTMLIgnoresUserDetailsLinks(t *testing.T) { + page := ` +
| shukBeta | 15.5 GiB |
| 问心下载 | 1.5 GiB |
{library.path}
++ {displayPath} +
- {library.path} · {preview.total.toLocaleString()} 个条目 · 最新 {cards.length} 部 + {displayPath} · {preview.total.toLocaleString()} 个条目 · 最新 {cards.length} 部
diff --git a/web/src/pages/LibraryPageHeader.tsx b/web/src/pages/LibraryPageHeader.tsx index 765f200..3784267 100644 --- a/web/src/pages/LibraryPageHeader.tsx +++ b/web/src/pages/LibraryPageHeader.tsx @@ -1,5 +1,6 @@ import type { Library } from '../types' import { EpisodeArtworkToggle } from '../components/EpisodeArtworkToggle' +import { libraryDisplayPath } from './libraryDisplayModel' type LibraryPageHeaderProps = { library: Library | null @@ -32,6 +33,8 @@ export function LibraryPageHeader({ onScrape, onRepairRescrape, }: LibraryPageHeaderProps) { + const displayPath = library ? libraryDisplayPath(library.path) : '' + return ({library.type} · {library.path}
} + {library &&{library.type} · {displayPath}
} {loadingAllText &&{loadingAllText}
} {scanProgress &&{scanProgress}
}