From 9497cea867e95006f843d55fed3ef77be916057e Mon Sep 17 00:00:00 2001 From: david Date: Fri, 9 Jul 2021 18:22:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96URL=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E8=A7=84=E5=88=99=EF=BC=8C=E6=94=AF=E6=8C=81=E6=96=B0=E7=AB=99?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AutoReseed.php | 38 +++++++++++++++++++------------------- config/config.sample.php | 8 ++++++++ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/app/AutoReseed.php b/app/AutoReseed.php index f3490e0..7a6be71 100644 --- a/app/AutoReseed.php +++ b/app/AutoReseed.php @@ -525,7 +525,7 @@ class AutoReseed } $downloadUrl = $_url; } else { - $url = self::getTorrentUrl($siteName, $_url); + $url = self::getTorrentUrl($siteName, $sid, $_url); $downloadUrl = $url; } @@ -935,20 +935,29 @@ class AutoReseed /** * 获取站点种子的URL * @param string $site + * @param int $sid * @param string $url * @return string 带host的完整种子下载连接 */ - private static function getTorrentUrl($site = '', $url = '') + private static function getTorrentUrl($site = '', $sid = 0, $url = '') { global $configALL; - // 注入合作站种子的URL规则 - $url = self::getRecommendTorrentUrl($site, $url); - // 兼容旧配置,进行补全 - if (isset($configALL[$site]['passkey']) && $configALL[$site]['passkey']) { - if (empty($configALL[$site]['url_replace'])) { - $configALL[$site]['url_replace'] = array('{passkey}' => trim($configALL[$site]['passkey'])); + // 注入URL替换规则 + if (in_array($site, self::$recommend)) { + $url = self::getRecommendTorrentUrl($site, $url); + } else { + $reseed_check = self::$sites[$sid]['reseed_check']; + if ($reseed_check && is_array($reseed_check)) { + $replace = []; + foreach ($reseed_check as $value) { + $value = ($value === 'uid' ? 'id' : $value); // 兼容性处理 + $key = '{' . $value .'}'; + $replace[$key] = empty($configALL[$site][$value]) ? '' : $configALL[$site][$value]; + } + $configALL[$site]['url_replace'] = $replace; } } + // 通用操作:替换 if (isset($configALL[$site]['url_replace']) && $configALL[$site]['url_replace']) { $url = strtr($url, $configALL[$site]['url_replace']); @@ -971,24 +980,15 @@ class AutoReseed global $configALL; if (in_array($site, self::$recommend)) { $now = time(); - $uid = isset($configALL[$site]['id']) ? $configALL[$site]['id'] : $now; + $uid = isset($configALL[$site]['id']) ? $configALL[$site]['id'] : 0; $pk = isset($configALL[$site]['passkey']) ? trim($configALL[$site]['passkey']) : $now; $hash = md5(trim($pk)); $signString = self::getDownloadTorrentSign($site); // 检查签名有效期,如果过期获取新的签名 switch ($site) { - case 'pthome': - case 'hdhome': - case 'hddolby': - //兼容性处理:新旧规则 - if (isset($configALL[$site]['rss']) && $configALL[$site]['rss']) { - $url = str_replace('passkey={passkey}', 'uid={uid}&hash={hash}', $url); - $hash = $configALL[$site]['rss']; // 直接提交专用下载hash - } - break; case 'ourbits': // 兼容旧版本的IYUU - if (isset($configALL[$site]['id']) && $configALL[$site]['id']) { + if ($uid) { $url = str_replace('passkey={passkey}', 'uid={uid}&hash={hash}', $url); } // TODO... 注入流控规则 60S/20pcs、3600S/100pcs diff --git a/config/config.sample.php b/config/config.sample.php index 87ce2c2..8b1f0d2 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -678,5 +678,13 @@ return array( // 如果需要自动辅种,必须配置 'passkey' => '', ), + 'greatposterwall' => array( + // 如果需要用下载免费种脚本,须配置(只是自动辅种,可以不配置此项) + 'cookie' => '', + // 如果需要自动辅种,必须配置 + 'passkey' => '', // torrent_pass + 'torrent_pass' => '', // torrent_pass + 'authkey' => '', // authkey + ), // 配置结束,后面的一行不能删除,必须保留!!! );