Skip to content

fix(site/hdsky): enhance torrent download link retrieval in firefox#1105

Merged
Rhilip merged 2 commits intopt-plugins:masterfrom
Rhilip:fix/i1098
Mar 16, 2026
Merged

fix(site/hdsky): enhance torrent download link retrieval in firefox#1105
Rhilip merged 2 commits intopt-plugins:masterfrom
Rhilip:fix/i1098

Conversation

@Rhilip
Copy link
Copy Markdown
Collaborator

@Rhilip Rhilip commented Mar 16, 2026

在原先的 link 获取过程中,由于 HDSKY 在 Firefox 环境中返回的链接格式为 /download.php?id=<tid>&passkey=<passkey>&sign=<sign> 导致 站点实例在执行 getTorrentDownloadLink 方法时,无法获取到 &t= 参数,进而导致导致可以下载的正确链接被错误的移除,随后回落到 NexusPHP 模板的 getTorrentDownloadLink 方法,导致错误的下载链接 /download.php?id=<tid> 被拼出。
至此, HDSKY 站点在符合: ①使用 Firefox 浏览器; ②在种子详情页使用助手推送 的情况下,无法获取到正确的下载链接。

closed: #1098

Summary by Sourcery

Bug Fixes:

  • Ensure Firefox retrieves stable HDSky torrent download links by prioritizing passkey-based URLs over time-limited ones.

Copilot AI review requested due to automatic review settings March 16, 2026 15:21
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 16, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Hdsky.getTorrentDownloadLink is updated to preferentially return permanent torrent download links containing a passkey, falling back to time-limited links only when no passkey is present, improving reliability in browsers like Firefox.

Class diagram for Hdsky torrent download link retrieval

classDiagram
  class NexusPHP {
  }

  class ITorrent {
    +string link
  }

  class Hdsky {
    +getTorrentDownloadLink(torrent ITorrent) Promise~string~
  }

  Hdsky --|> NexusPHP
  Hdsky ..> ITorrent : uses
Loading

Flow diagram for Hdsky.getTorrentDownloadLink decision logic

flowchart TD
  A[getTorrentDownloadLink called with torrent] --> B{torrent.link exists?}
  B -- No --> C[Call super.getTorrentDownloadLink or other logic]
  B -- Yes --> D[Evaluate hasPasskey using regex &passkey=]
  D --> E{hasPasskey?}
  E -- Yes --> F[Return torrent.link as permanent download link]
  E -- No --> G[Extract t query parameter via runQueryFilters]
  G --> H[Compute linkCreatedTime and currentTimestamp]
  H --> I[Validate time-limited link and return or refresh as needed]
Loading

File-Level Changes

Change Details Files
Prefer permanent passkey-based download links over time-limited timestamp-based links when resolving torrent download URLs.
  • Document the two HDSky download URL formats and their validity characteristics in a comment above getTorrentDownloadLink.
  • Detect whether the existing torrent link already includes a passkey query parameter.
  • Immediately return the link when it includes a passkey, skipping timestamp validation and expiry logic.
  • Retain existing logic that treats links without a passkey as time-limited and subject to timestamp-based checks.
src/packages/site/definitions/hdsky.ts

Assessment against linked issues

Issue Objective Addressed Explanation
#1098 Ensure that in Firefox (including the sidebar), HDSky torrent downloads and copied links use a complete, valid download URL (including passkey/sign or otherwise non-expiring parameters) so that torrents download successfully.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes HDSky torrent download link retrieval in Firefox by handling the passkey-based download URL format. In Firefox's sidebar, the download link was missing passkey/sign parameters, causing download failures.

Changes:

  • Added early return when the torrent link already contains a passkey parameter, skipping unnecessary timestamp-based expiration checks.
  • Added documentation comment explaining the two HDSky download link formats.

You can also share your feedback on Copilot code review. Take the survey.

@Rhilip Rhilip merged commit 6a47b80 into pt-plugins:master Mar 16, 2026
6 checks passed
@Rhilip Rhilip deleted the fix/i1098 branch April 5, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HDSky 在火狐侧边栏下载失败

2 participants