mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-05-13 23:16:47 +00:00
Merge pull request #133 from lingjiameng/main
This commit is contained in:
@@ -186,7 +186,7 @@
|
||||
"CrossSeed": {
|
||||
"name": "青蛙辅种助手",
|
||||
"description": "参考ReseedPuppy和IYUU辅种插件实现自动辅种,支持站点:青蛙【已验证】, AGSVPT, 麒麟, UBits, 聆音 等",
|
||||
"version": "1.4",
|
||||
"version": "1.5",
|
||||
"icon": "qingwa.png",
|
||||
"author": "233@qingwa",
|
||||
"level": 2
|
||||
|
||||
@@ -36,7 +36,7 @@ class CrossSeed(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "qingwa.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.4"
|
||||
plugin_version = "1.5"
|
||||
# 插件作者
|
||||
plugin_author = "233@qingwa"
|
||||
# 作者主页
|
||||
@@ -559,7 +559,6 @@ class CrossSeed(_PluginBase):
|
||||
logger.info(f"下载器 {downloader} 没有已完成种子")
|
||||
continue
|
||||
hash_strs = []
|
||||
torrent_site_pieces_hashes = set()
|
||||
for torrent in torrents:
|
||||
if self._event.is_set():
|
||||
logger.info(f"辅种服务停止")
|
||||
@@ -856,7 +855,7 @@ class CrossSeed(_PluginBase):
|
||||
return False
|
||||
|
||||
# 添加任务前查询校验一次,避免重复添加,导致暂停的任务被重新开始
|
||||
tmp_tor_info, err_msg = TorInfo.from_file(content)
|
||||
tmp_tor_info, err_msg = TorInfo.from_data(content)
|
||||
if tmp_tor_info and tmp_tor_info.info_hash:
|
||||
tors, msg = self.__get_downloader(downloader).get_torrents(ids=[tmp_tor_info.info_hash])
|
||||
if tors:
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import hashlib
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import List, Self
|
||||
from typing import Self
|
||||
|
||||
import bencodepy
|
||||
import requests
|
||||
from bencode import decode, encode
|
||||
|
||||
|
||||
class CSSiteConfig(object):
|
||||
@@ -18,6 +17,8 @@ class CSSiteConfig(object):
|
||||
self.passkey = site_passkey
|
||||
|
||||
def get_api_url(self):
|
||||
if self.name == "憨憨":
|
||||
return f"{self.url}/npapi/pieces-hash"
|
||||
return f"{self.url}/api/pieces-hash"
|
||||
|
||||
def get_torrent_url(self, torrent_id: str):
|
||||
@@ -57,18 +58,17 @@ class TorInfo:
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_file(data: bytes) -> tuple[Self, str]:
|
||||
def from_data(data: bytes) -> tuple[Self, str]:
|
||||
try:
|
||||
torrent = bencodepy.decode(data)
|
||||
info = torrent[b"info"]
|
||||
pieces = info[b"pieces"]
|
||||
info_hash = hashlib.sha1(bencodepy.encode(info)).hexdigest()
|
||||
torrent = decode(data)
|
||||
info = torrent["info"]
|
||||
pieces = info["pieces"]
|
||||
info_hash = hashlib.sha1(encode(info)).hexdigest()
|
||||
pieces_hash = hashlib.sha1(pieces).hexdigest()
|
||||
local_tor = TorInfo(info_hash=info_hash, pieces_hash=pieces_hash)
|
||||
#从种子中获取 announce, qb可能存在获取不到的情况,会存在于fastresume文件中
|
||||
if b"announce" in torrent:
|
||||
announce: bytes = torrent[b"announce"]
|
||||
local_tor.torrent_announce = announce.decode(encoding="utf-8")
|
||||
if "announce" in torrent:
|
||||
local_tor.torrent_announce = torrent["announce"]
|
||||
return local_tor, None
|
||||
except Exception as err:
|
||||
return None, err
|
||||
@@ -80,7 +80,7 @@ class TorInfo:
|
||||
return f"{self.site_name}:{self.pieces_hash}"
|
||||
|
||||
class CrossSeedHelper(object):
|
||||
_version = "0.1.0"
|
||||
_version = "0.2.0"
|
||||
|
||||
def get_local_torrent_info(self, torrent_path: Path | str) -> tuple[TorInfo, str]:
|
||||
try:
|
||||
@@ -90,17 +90,10 @@ class CrossSeedHelper(object):
|
||||
else:
|
||||
with open(torrent_path, "rb") as f:
|
||||
torrent_data = f.read()
|
||||
torrent = bencodepy.decode(torrent_data)
|
||||
info = torrent[b"info"]
|
||||
pieces = info[b"pieces"]
|
||||
|
||||
info_hash = hashlib.sha1(bencodepy.encode(info)).hexdigest()
|
||||
pieces_hash = hashlib.sha1(pieces).hexdigest()
|
||||
local_tor = TorInfo.local(str(torrent_path), info_hash, pieces_hash)
|
||||
# 对于 transmission 可以从种子中补充 announce
|
||||
if b"announce" in torrent:
|
||||
announce: bytes = torrent[b"announce"]
|
||||
local_tor.torrent_announce = announce.decode(encoding="utf-8")
|
||||
local_tor, err = TorInfo.from_data(torrent_data)
|
||||
if not local_tor:
|
||||
return None, err
|
||||
local_tor.torrent_path = str(torrent_path)
|
||||
return local_tor, ""
|
||||
except Exception as err:
|
||||
return None, err
|
||||
@@ -133,4 +126,3 @@ class CrossSeedHelper(object):
|
||||
TorInfo.remote(site.name, pieces_hash, torrent_id)
|
||||
)
|
||||
return remote_torrent_infos, None
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
bencode.py==4.0.0
|
||||
Reference in New Issue
Block a user