Erstelle NyaaLinkFixer
This commit is contained in:
32
xNyaaLinkFixer/extension.php
Normal file
32
xNyaaLinkFixer/extension.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class NyaaLinkFixerExtension extends Minz_Extension
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
8
xNyaaLinkFixer/metadata.json
Normal file
8
xNyaaLinkFixer/metadata.json
Normal file
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user