fix: improve private tracker compatibility and session settings#2239
fix: improve private tracker compatibility and session settings#2239nathanlgn62 wants to merge 7 commits into
Conversation
- Enhanced the torrent session configuration in `main.py` with advanced settings for private trackers. - Updated the `TorrentDownloader` class to exclude public trackers when a private tracker is detected, improving download management.
chubbygrannychaser
left a comment
There was a problem hiding this comment.
Thanks for the PR — the private-tracker compatibility goal makes sense, but I found two blocking regressions that should be fixed before merge:
python_rpc/torrent_downloader.py:235now callsself._run_selective_logic(...), but that helper is not defined anywhere in the class/file. This will break selective torrent downloads at runtime whenfile_indicesis provided.python_rpc/torrent_downloader.py:375treats&tr=andx.pe=as signals that a magnet is private. Those are standard optional magnet parameters, so this will misclassify many normal/public magnets as private and skip Hydra's fallback public tracker list.
Non-blocking: .env.example also appears to have been deleted as part of this PR, which looks unrelated unless that cleanup was intentional.
|
|
||
| self.selected_file_indices = sanitized_indices | ||
| self.selected_size_bytes = sum(files_storage.file_size(index) for index in sanitized_indices) | ||
| self._run_selective_logic(file_indices, wait_timeout_seconds) |
There was a problem hiding this comment.
This now calls _run_selective_logic(...), but that helper is not defined anywhere in the class/file. Selective downloads use this path when file_indices is provided, so this becomes a runtime AttributeError.
| Determines whether to include public trackers. | ||
| We check the default magnet link to avoid adding 80 trackers to a private torrent. | ||
| """ | ||
| is_private_magnet = "x.pe=" in magnet or "&priv=1" in magnet.lower() or "&tr=" in magnet.lower() |
There was a problem hiding this comment.
Using &tr= or x.pe= as a proxy for “private magnet” is too broad. Both are standard optional magnet params, so this will classify many normal/public magnets as private and return [] here, disabling the fallback public tracker list.
| @@ -1,7 +0,0 @@ | |||
| MAIN_VITE_API_URL= | |||
There was a problem hiding this comment.
This file was removed in this PR. Was that intentional? It looks unrelated to the tracker/session changes.
- Removed unnecessary comments and streamlined the logic for handling public and private trackers. - Enhanced error logging during download initialization to provide clearer insights into issues. - Updated the handling of selected file indices to ensure proper management based on user input. - Cleaned up the code for better readability and maintainability.
- Removed unnecessary comments and improved the handling of public and private trackers. - Enhanced error logging during download initialization for better issue tracking. - Updated the logic for managing selected file indices based on user input. - Cleaned up code for improved readability and maintainability.
|
Thanks for the feedback! I've just pushed the fixes for the reported regressions. Fixed Regressions: Missing Helper: The _run_selective_logic method has been properly implemented. It now centralizes metadata waiting and file priority management, ensuring selective downloads work as expected. Private Detection Logic: I’ve completely removed the unreliable string-based detection (&tr=, x.pe=) from the magnet URL. We now rely on torrent_info.priv(), which is only available after metadata is fetched. This ensures 100% accuracy: fallback trackers are injected for public torrents and strictly ignored for private ones. .env.example: This was a mistake. The file has been restored. Note on Performance: Ready for another look!" |
|
Thanks for pushing a follow-up — the two original blockers do look addressed (
Once those are fixed, I'm happy to take another pass. |
|
Sorry, I'm making some big careless mistakes, everything should be fine now. |
|



PR Description
Summary:
This PR improves the integration and stability of private trackers within Hydra's Python RPC downloader. By aligning the libtorrent session settings and tracker management with industry standards (like qBittorrent), it resolves issues where private trackers would intermittently reject connections or fail to announce due to incorrect client identification or "leakage" to public trackers.
Changes:
Session Optimization (main.py): * Added a legitimate user_agent and peer_fingerprint (matching qBittorrent) to avoid being flagged as an "unknown client" by private trackers.
Explicitly disabled anonymous_mode (which is often a cause for instant bans on private trackers as it hides the user's IP/Ratio).
Disabled validate_https_trackers to handle trackers with specific SSL certificate configurations more gracefully.
Smart Tracker Management (torrent_downloader.py):
Implemented a check on magnet URI structures to detect private flags (&priv=1 or x.pe=).
When a private magnet is detected, the hardcoded list of ~80 public trackers is excluded. This prevents "hammering" the session with unnecessary requests and follows the BitTorrent protocol's private flag requirements.
Improved logging for better debugging of tracker-related events.
Why this is valuable:
Users of private trackers (like C411, YGG, etc.) currently experience "Tracker Error" status in Hydra while the same torrents work perfectly in standalone clients like qBittorrent. These changes bridge that gap, making Hydra's built-in downloader reliable for all types of sources.
When submitting this pull request, I confirm the following (please check the boxes):