fix bugs
This commit is contained in:
parent
1c8e349bfc
commit
ab86eaf59a
@ -40,7 +40,7 @@ class _ChainBase(AbstractSingleton, metaclass=Singleton):
|
|||||||
else:
|
else:
|
||||||
return result is None
|
return result is None
|
||||||
|
|
||||||
logger.info(f"请求模块执行:{method} ...")
|
logger.debug(f"请求模块执行:{method} ...")
|
||||||
result = None
|
result = None
|
||||||
modules = self.modulemanager.get_modules(method)
|
modules = self.modulemanager.get_modules(method)
|
||||||
for module in modules:
|
for module in modules:
|
||||||
|
@ -50,6 +50,8 @@ class DoubanSyncChain(_ChainBase):
|
|||||||
title = result.get("title", "")[2:]
|
title = result.get("title", "")[2:]
|
||||||
if dtype not in ["想看"]:
|
if dtype not in ["想看"]:
|
||||||
continue
|
continue
|
||||||
|
if not result.get("link"):
|
||||||
|
continue
|
||||||
douban_id = result.get("link", "").split("/")[-2]
|
douban_id = result.get("link", "").split("/")[-2]
|
||||||
if not douban_id or douban_id in caches:
|
if not douban_id or douban_id in caches:
|
||||||
continue
|
continue
|
||||||
|
@ -57,6 +57,7 @@ class SearchChain(_ChainBase):
|
|||||||
# 过滤
|
# 过滤
|
||||||
if torrent_mediainfo.tmdb_id == mediainfo.tmdb_id \
|
if torrent_mediainfo.tmdb_id == mediainfo.tmdb_id \
|
||||||
and torrent_mediainfo.type == mediainfo.type:
|
and torrent_mediainfo.type == mediainfo.type:
|
||||||
|
logger.info(f'{mediainfo.title} 匹配到资源:{torrent.title}')
|
||||||
_match_torrents.append(torrent)
|
_match_torrents.append(torrent)
|
||||||
else:
|
else:
|
||||||
_match_torrents = torrents
|
_match_torrents = torrents
|
||||||
|
@ -53,7 +53,6 @@ class RssHelper:
|
|||||||
# 部分RSS只有link没有enclosure
|
# 部分RSS只有link没有enclosure
|
||||||
if not enclosure and link:
|
if not enclosure and link:
|
||||||
enclosure = link
|
enclosure = link
|
||||||
link = None
|
|
||||||
# 大小
|
# 大小
|
||||||
size = DomUtils.tag_value(item, "enclosure", "length", default=0)
|
size = DomUtils.tag_value(item, "enclosure", "length", default=0)
|
||||||
if size and str(size).isdigit():
|
if size and str(size).isdigit():
|
||||||
|
@ -41,6 +41,7 @@ class RuleParser:
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# 测试代码
|
# 测试代码
|
||||||
expression1 = "!BLU & (1080P | CN)"
|
expression = "!BLU & 4K & CN > !BLU & 1080P & CN > !BLU & 4K > !BLU & 1080P"
|
||||||
parsed_expr1 = RuleParser().parse(expression1)
|
for exp in expression.split('>'):
|
||||||
print(parsed_expr1.as_list())
|
parsed_expr = RuleParser().parse(exp)
|
||||||
|
print(parsed_expr.as_list())
|
||||||
|
@ -111,15 +111,18 @@ class FilterModule(_ModuleBase):
|
|||||||
if not isinstance(rule_group, list):
|
if not isinstance(rule_group, list):
|
||||||
# 不是列表,说明是规则名称
|
# 不是列表,说明是规则名称
|
||||||
return self.__match_rule(torrent, rule_group)
|
return self.__match_rule(torrent, rule_group)
|
||||||
if rule_group[0] == "not":
|
elif isinstance(rule_group, list) and len(rule_group) == 1:
|
||||||
|
# 只有一个规则项
|
||||||
|
return self.__match_rule(torrent, rule_group[0])
|
||||||
|
elif rule_group[0] == "not":
|
||||||
# 非操作
|
# 非操作
|
||||||
return not self.__match_group(torrent, rule_group[1])
|
return not self.__match_group(torrent, rule_group[1:])
|
||||||
elif rule_group[1] == "and":
|
elif rule_group[1] == "and":
|
||||||
# 与操作
|
# 与操作
|
||||||
return self.__match_group(torrent, rule_group[0]) and self.__match_group(torrent, rule_group[2])
|
return self.__match_group(torrent, rule_group[0]) and self.__match_group(torrent, rule_group[2:])
|
||||||
elif rule_group[1] == "or":
|
elif rule_group[1] == "or":
|
||||||
# 或操作
|
# 或操作
|
||||||
return self.__match_group(torrent, rule_group[0]) or self.__match_group(torrent, rule_group[2])
|
return self.__match_group(torrent, rule_group[0]) or self.__match_group(torrent, rule_group[2:])
|
||||||
|
|
||||||
def __match_rule(self, torrent: TorrentInfo, rule_name: str) -> bool:
|
def __match_rule(self, torrent: TorrentInfo, rule_name: str) -> bool:
|
||||||
"""
|
"""
|
||||||
|
@ -18,6 +18,8 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
_username: str = None
|
_username: str = None
|
||||||
_passowrd: str = None
|
_passowrd: str = None
|
||||||
|
|
||||||
|
qbc: Client = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
host = settings.QB_HOST
|
host = settings.QB_HOST
|
||||||
if host and host.find(":") != -1:
|
if host and host.find(":") != -1:
|
||||||
@ -44,7 +46,7 @@ class Qbittorrent(metaclass=Singleton):
|
|||||||
try:
|
try:
|
||||||
qbt.auth_log_in()
|
qbt.auth_log_in()
|
||||||
except qbittorrentapi.LoginFailed as e:
|
except qbittorrentapi.LoginFailed as e:
|
||||||
print(str(e))
|
logger.error(f"qbittorrent 登录失败:{e}")
|
||||||
return qbt
|
return qbt
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"qbittorrent 连接出错:{err}")
|
logger.error(f"qbittorrent 连接出错:{err}")
|
||||||
|
@ -16,6 +16,8 @@ class Transmission(metaclass=Singleton):
|
|||||||
_username: str = None
|
_username: str = None
|
||||||
_passowrd: str = None
|
_passowrd: str = None
|
||||||
|
|
||||||
|
trc: Optional[Client] = None
|
||||||
|
|
||||||
# 参考transmission web,仅查询需要的参数,加速种子搜索
|
# 参考transmission web,仅查询需要的参数,加速种子搜索
|
||||||
_trarg = ["id", "name", "status", "labels", "hashString", "totalSize", "percentDone", "addedDate", "trackerStats",
|
_trarg = ["id", "name", "status", "labels", "hashString", "totalSize", "percentDone", "addedDate", "trackerStats",
|
||||||
"leftUntilDone", "rateDownload", "rateUpload", "recheckProgress", "rateDownload", "rateUpload",
|
"leftUntilDone", "rateDownload", "rateUpload", "recheckProgress", "rateDownload", "rateUpload",
|
||||||
@ -46,7 +48,7 @@ class Transmission(metaclass=Singleton):
|
|||||||
timeout=60)
|
timeout=60)
|
||||||
return trt
|
return trt
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"连接出错:{err}")
|
logger.error(f"transmission 连接出错:{err}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_torrents(self, ids: Union[str, list] = None, status: Union[str, list] = None,
|
def get_torrents(self, ids: Union[str, list] = None, status: Union[str, list] = None,
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
from tests.test_cookiecloud import CookieCloudTest
|
||||||
|
from tests.test_doubansync import DoubanSyncTest
|
||||||
from tests.test_metainfo import MetaInfoTest
|
from tests.test_metainfo import MetaInfoTest
|
||||||
from tests.test_recognize import RecognizeTest
|
from tests.test_recognize import RecognizeTest
|
||||||
|
from tests.test_transfer import TransferTest
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
suite = unittest.TestSuite()
|
suite = unittest.TestSuite()
|
||||||
@ -9,6 +12,12 @@ if __name__ == '__main__':
|
|||||||
suite.addTest(MetaInfoTest('test_metainfo'))
|
suite.addTest(MetaInfoTest('test_metainfo'))
|
||||||
# 测试媒体识别
|
# 测试媒体识别
|
||||||
suite.addTest(RecognizeTest('test_recognize'))
|
suite.addTest(RecognizeTest('test_recognize'))
|
||||||
|
# 测试CookieCloud同步
|
||||||
|
suite.addTest(CookieCloudTest('test_cookiecloud'))
|
||||||
|
# 测试文件转移
|
||||||
|
suite.addTest(TransferTest('test_transfer'))
|
||||||
|
# 测试豆瓣同步
|
||||||
|
suite.addTest(DoubanSyncTest('test_doubansync'))
|
||||||
# 运行测试
|
# 运行测试
|
||||||
runner = unittest.TextTestRunner()
|
runner = unittest.TextTestRunner()
|
||||||
runner.run(suite)
|
runner.run(suite)
|
||||||
|
17
tests/test_cookiecloud.py
Normal file
17
tests/test_cookiecloud.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from app.chain.cookiecloud import CookieCloudChain
|
||||||
|
|
||||||
|
|
||||||
|
class CookieCloudTest(TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_cookiecloud(self):
|
||||||
|
result = CookieCloudChain().process()
|
||||||
|
self.assertEqual(result[0], True)
|
17
tests/test_doubansync.py
Normal file
17
tests/test_doubansync.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from app.chain.douban_sync import DoubanSyncChain
|
||||||
|
|
||||||
|
|
||||||
|
class DoubanSyncTest(TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_doubansync(self):
|
||||||
|
result = DoubanSyncChain().process()
|
||||||
|
self.assertEqual(result[0], True)
|
17
tests/test_transfer.py
Normal file
17
tests/test_transfer.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from app.chain.transfer import TransferChain
|
||||||
|
|
||||||
|
|
||||||
|
class TransferTest(TestCase):
|
||||||
|
def setUp(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def tearDown(self) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_transfer(self):
|
||||||
|
result = TransferChain().process()
|
||||||
|
self.assertEqual(result[0], True)
|
Loading…
x
Reference in New Issue
Block a user