From d6202d029b6c7a1f61fc31e44a6b874c05dabcd7 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 24 Aug 2021 11:02:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=AB=99=E7=82=B9ptp=EF=BC=88=E7=9A=AE=EF=BC=89=E8=BE=85?= =?UTF-8?q?=E7=A7=8D=EF=BC=8C=E7=9A=AERSS=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/help.md | 14 ++++++++ public/page/setting/sites.html | 1 + src/Rss/ptpbd.php | 58 ++++++++++++++++++++++++++++++---- 3 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 docs/help.md diff --git a/docs/help.md b/docs/help.md new file mode 100644 index 0000000..d67dd9e --- /dev/null +++ b/docs/help.md @@ -0,0 +1,14 @@ +IYUUPlus安装篇--群晖docker +https://www.iyuu.cn/archives/426/ + +IYUUPlus安装篇--威联通docker +https://www.iyuu.cn/archives/447/ + +IYUUPlus安装篇--Arm平台命令行安装 +https://www.iyuu.cn/archives/427/ + +IYUUPlus安装篇--Windows +https://www.iyuu.cn/archives/429/ + +IYUUPlus使用篇-转移做种客户端 +https://www.iyuu.cn/archives/451/ \ No newline at end of file diff --git a/public/page/setting/sites.html b/public/page/setting/sites.html index a584d75..80cc8e8 100644 --- a/public/page/setting/sites.html +++ b/public/page/setting/sites.html @@ -232,6 +232,7 @@ break; case 'greatposterwall': case 'dicmusic': + case 'ptpbd': rule.passkey.visible = false; rule.torrent_pass.visible = true; rule.authkey.visible = true; diff --git a/src/Rss/ptpbd.php b/src/Rss/ptpbd.php index a3e2794..88aa969 100644 --- a/src/Rss/ptpbd.php +++ b/src/Rss/ptpbd.php @@ -2,6 +2,7 @@ namespace IYUU\Rss; use DOMDocument; +use Exception; class ptpbd extends AbstractRss { @@ -11,6 +12,42 @@ class ptpbd extends AbstractRss */ public $site = 'ptpbd'; + /** + * 用户必须自己配置rss地址 + * @var string + */ + public $rss_page = ''; + /** + * 抽象方法,在类中实现 + * 请求url,获取html页面 + * @param string $url + * @return string|null + */ + public function get($url = '') + { + // 1. 入口参数为准 + if ($url == '') { + $url = $this->rss_page; + } + + // 2. 读取配置 + if ($rss_page = self::$conf['urladdress'] ?? '') { + $url = $rss_page; + } + if (empty($url)) { + die('缺少 rss.page 配置'); + } + + echo $this->site." 正在请求RSS... {$url}". PHP_EOL; + $res = $this->curl->get($this->host . $url); + if ($res->http_status_code == 200) { + echo "RSS获取信息,成功! \n"; + return $res->response; + } + echo "RSS获取信息失败,请重试! \n"; + return null; + } + /** * 抽象方法,在类中实现 * 解码html为种子数组 @@ -31,8 +68,17 @@ class ptpbd extends AbstractRss $guid = $item->getElementsByTagName('guid')->item(0) != null ? md5($item->getElementsByTagName('guid')->item(0)->nodeValue) : md5($link); $details = $item->getElementsByTagName('comments')->item(0)->nodeValue; $time = strtotime($item->getElementsByTagName('pubDate')->item(0)->nodeValue); - // 提取id - $id = strrchr($details, '='); + // 提取种子id + if (preg_match('/id=(\d+)/i', $link, $match)) { + $id = $match[1]; + } else { + continue; + } + // 提取种子分组id + if (preg_match('/id=(\d+)/i', $details, $match)) { + $group_id = $match[1]; + $torrent['group_id'] = $group_id; + } $torrent['id'] = $id; $torrent['h1'] = $item->getElementsByTagName('title')->item(0)->nodeValue; $torrent['title'] = ''; @@ -44,11 +90,11 @@ class ptpbd extends AbstractRss $torrent['guid'] = $guid; $items[] = $torrent; } - #p($items); - #exit; + //p($items); + //exit; return $items; - } catch (\Exception $e) { - die('[AbstractRss ERROR] ' . $e->getMessage() . PHP_EOL); + } catch (Exception $e) { + die(__METHOD__ . ' [ERROR] ' . $e->getMessage() . PHP_EOL); } } }