Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2自动删种插件 #597

Open
whc95800 opened this issue Dec 9, 2024 · 3 comments
Open

v2自动删种插件 #597

whc95800 opened this issue Dec 9, 2024 · 3 comments

Comments

@whc95800
Copy link

whc95800 commented Dec 9, 2024

标签这一项如果你只填写一个标签没问题,但是用逗号分隔多个标签的话它默认是这个种子必须有这些标签,而不是只要这个种子含有这个标签。逻辑是and而不是or的意思。

@whc95800
Copy link
Author

whc95800 commented Dec 9, 2024

查询种子

torrents = []
for tag in tags:
current_torrents, error_flag = downloader_obj.get_torrents(tags=[tag] or None)
if error_flag:
return []
torrents.extend(current_torrents)

@whc95800
Copy link
Author

whc95800 commented Dec 9, 2024

如果可以的话 这里设计成,是and逻辑 |是or逻辑么?

@whc95800
Copy link
Author

whc95800 commented Dec 9, 2024

用ai写的凑合着看

标题

and_tags = []
or_tags = []

if self._labels:
for tag_group in self._labels.split(','):
if '&' in tag_group:
# 如果包含 &,按 & 分割并归类到 and_tags
and_tags.extend(tag_group.split('&'))
elif '|' in tag_group:
# 如果包含 |,按 | 分割并归类到 or_tags
or_tags.extend(tag_group.split('|'))
else:
# 没有逻辑符的单独标签默认归类到 or_tags
or_tags.append(tag_group)

if self._mponly:
# 如果 _mponly 开启,将特殊标签加入 and_tags
and_tags.append(settings.TORRENT_TAG)

查询种子

torrents = []

使用 AND 逻辑的查询

if and_tags:
and_torrents, error_flag = downloader_obj.get_torrents(tags=and_tags or None)
if error_flag:
return []
torrents.extend(and_torrents)

使用 OR 逻辑的查询

if or_tags:
for tag in or_tags:
or_torrents, error_flag = downloader_obj.get_torrents(tags=[tag] or None)
if error_flag:
return []
torrents.extend(or_torrents)

去重处理

torrents = list({torrent.hash: torrent for torrent in torrents}.values())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant