From 133f66481e17ba8baa6e906c4340467f46227068 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Tue, 14 Oct 2025 13:22:18 +0200 Subject: [PATCH] Erstelle NyaaLinkFixer --- README.md | 57 ++++++++++++++++++++++++++++++++++++ xNyaaLinkFixer/extension.php | 32 ++++++++++++++++++++ xNyaaLinkFixer/metadata.json | 8 +++++ 3 files changed, 97 insertions(+) create mode 100644 README.md create mode 100644 xNyaaLinkFixer/extension.php create mode 100644 xNyaaLinkFixer/metadata.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..8a15f65 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# xNyaaLinkFixer - FreshRSS Plugin + +Ein FreshRSS-Plugin, das automatisch Nyaa.si Download-Links in View-Links umwandelt. + +## Funktionalität + +Das Plugin konvertiert Links von: +``` +https://nyaa.si/download/1234567.torrent +``` + +zu: +``` +https://nyaa.si/view/1234567 +``` + +Dies ermöglicht es, direkt zur Detailseite des Torrents zu gelangen, anstatt die Torrent-Datei herunterzuladen. + +## Installation + +1. Navigieren Sie zu Ihrem FreshRSS-Installationsverzeichnis: + ```bash + cd /path/to/FreshRSS/extensions + ``` + +2. Kopieren Sie den Plugin-Ordner: + ```bash + cp -r xNyaaLinkFixer /path/to/FreshRSS/extensions/ + ``` + +3. Setzen Sie die korrekten Berechtigungen: + ```bash + chown -R www-data:www-data /path/to/FreshRSS/extensions/xNyaaLinkFixer + ``` + +4. Loggen Sie sich in FreshRSS ein und gehen Sie zu: + - Einstellungen → Erweiterungen + - Aktivieren Sie "Nyaa Link Fixer" + +## Funktionsweise + +Das Plugin registriert sich für zwei Hooks: +- `entry_before_insert`: Korrigiert Links beim Importieren neuer Feed-Einträge +- `entry_before_display`: Korrigiert Links beim Anzeigen von Einträgen + +Dadurch werden sowohl neue als auch bereits existierende Links konvertiert. + +## Technische Details + +- **Name**: Nyaa Link Fixer +- **Version**: 1.0 +- **Typ**: System-Extension +- **Kompatibilität**: FreshRSS 1.x + +## Lizenz + +Frei verfügbar zur Verwendung und Modifikation. diff --git a/xNyaaLinkFixer/extension.php b/xNyaaLinkFixer/extension.php new file mode 100644 index 0000000..a561d5c --- /dev/null +++ b/xNyaaLinkFixer/extension.php @@ -0,0 +1,32 @@ +registerHook('entry_before_insert', [$this, 'fixNyaaLink']); + $this->registerHook('entry_before_display', [$this, 'fixNyaaLink']); + } + + /** + * Fix Nyaa.si download links to view links + * Converts: https://nyaa.si/download/1234567.torrent + * To: https://nyaa.si/view/123457 + * + * @param FreshRSS_Entry $entry + * @return FreshRSS_Entry + */ + public function fixNyaaLink($entry) + { + $link = $entry->link(); + + // Check if the link is a Nyaa.si download link + if (preg_match('#^https?://nyaa\.si/download/(\d+)\.torrent$#i', $link, $matches)) { + $torrentId = $matches[1]; + $newLink = "https://nyaa.si/view/{$torrentId}"; + $entry->_link($newLink); + } + + return $entry; + } +} diff --git a/xNyaaLinkFixer/metadata.json b/xNyaaLinkFixer/metadata.json new file mode 100644 index 0000000..498e640 --- /dev/null +++ b/xNyaaLinkFixer/metadata.json @@ -0,0 +1,8 @@ +{ + "name": "Nyaa Link Fixer", + "author": "Akamaru", + "description": "Converts Nyaa.si download links to view links in RSS feeds", + "version": "1.0.0", + "entrypoint": "NyaaLinkFixer", + "type": "system" +}