fix(site): fix broken subTitle selectors for HDArea and PTHome - #1315
Merged
Conversation
HDArea: subtitle is in a sibling div (div:nth-child(2)) of the title div,
not after a <br> tag. Added a custom elementProcess that uses
element.closest("td > div") to find the title div and reads the
next sibling div as the subtitle.
PTHome: subtitle is wrapped in a <span> element after <br>. The default
NexusPHP handler removes all span elements which strips the subtitle
content. Changed removeSelectors to ["a", "img"] so that extractContent()
can still retrieve the text from the subtitle span.
Replace `as HTMLElement` type assertion with `instanceof HTMLElement` check for better type safety when reading the subtitle sibling div.
Copilot
AI
changed the title
[WIP] Fix subtitle selector for HDArea and PTHome
fix(site): fix broken subTitle selectors for HDArea and PTHome
Jun 14, 2026
Rhilip
marked this pull request as ready for review
June 18, 2026 09:45
Reviewer's GuideAdjusts site-specific subtitle extraction for HDArea and PTHome to handle their non-standard HTML structures, and performs minor formatting changes in HDArea metadata processing methods. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes subtitle extraction for two NexusPHP-based sites whose HTML structures don’t work with the default subTitleRemoveExtraElement() behavior, improving search result parsing consistency across the extension’s site modules.
Changes:
- PTHome: override
search.selectors.subTitleto avoid removing<span>so subtitle text isn’t stripped. - HDArea: override
search.selectors.subTitle.elementProcessto read subtitle from a sibling<div>rather than relying on<br>splitting.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/packages/site/definitions/pthome.ts |
Adds a site-specific subTitle handler to preserve subtitle text wrapped in a <span>. |
src/packages/site/definitions/hdarea.ts |
Adds a site-specific subTitle handler that reads subtitle from the next sibling <div> of the title container. |
Comment on lines
+125
to
+137
| subTitle: { | ||
| // PTHome wraps its subtitle in a <span> element. The default NexusPHP handler removes | ||
| // all span elements, which strips the subtitle text. We only remove <a> and <img> | ||
| // so that extractContent() can still get the text content from the subtitle span. | ||
| text: "", | ||
| selector: [ | ||
| "a[href^='details.php?id='][title]:has(b)", | ||
| "a[href*='details.php?id='][href*='hit']", | ||
| "a[href*='hit'][title]", | ||
| "a[href*='hit']:has(b)", | ||
| ], | ||
| elementProcess: subTitleRemoveExtraElement(["a", "img"], true), | ||
| }, |
Comment on lines
+146
to
+164
| subTitle: { | ||
| text: "", | ||
| selector: [ | ||
| "a[href^='details.php?id='][title]:has(b)", | ||
| "a[href*='details.php?id='][href*='hit']", | ||
| "a[href*='hit'][title]", | ||
| "a[href*='hit']:has(b)", | ||
| ], | ||
| // HDArea places the subtitle in a sibling div of the title div, | ||
| // rather than after a <br> tag, so we look at the next sibling element. | ||
| elementProcess: (element: HTMLElement) => { | ||
| const titleDiv = element.closest("td > div"); | ||
| const subtitleEl = titleDiv?.nextElementSibling; | ||
| if (subtitleEl instanceof HTMLElement && subtitleEl.tagName === "DIV") { | ||
| return subtitleEl.textContent?.trim() ?? ""; | ||
| } | ||
| return ""; | ||
| }, | ||
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both HDArea and PTHome have non-standard subtitle HTML structures that break the default NexusPHP
subTitleRemoveExtraElementhandler (which splits parentinnerHTMLon<br>and stripsa, span, img).HDArea
Subtitle lives in
div:nth-child(2)— a sibling div of the title div — not after a<br>tag. The<br>-split yields nothing.PTHome
Subtitle is wrapped in
<span style="padding: 2px;line-height: 20px;">…</span>after<br>. The defaultremoveSelectors: ["a, span, img"]removes the span entirely, taking the subtitle text with it.Fix: override
subTitlewithsubTitleRemoveExtraElement(["a", "img"], true)— drops anchors/images but leaves the subtitle span forextractContent()to unwrap.Summary by Sourcery
Fix subtitle extraction for HDArea and PTHome torrent search results to align with their non-standard HTML structures.
Bug Fixes:
Enhancements: