Skip to content

Commit

Permalink
Merge pull request NAStool#796 from pen1120/feature/brush_rule
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp authored Aug 25, 2022
2 parents 11e97a6 + 2e23e37 commit ffe4075
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 57 deletions.
20 changes: 15 additions & 5 deletions pt/brushtask.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
import time
import traceback
import functools
from datetime import datetime
from time import sleep

Expand Down Expand Up @@ -130,6 +131,7 @@ def check_task_rss(self, taskid):
else:
log.info("【BRUSH】%s RSS获取数据:%s" % (site_name, len(rss_result)))
success_count = 0

for res in rss_result:
try:
# 种子名
Expand Down Expand Up @@ -515,18 +517,26 @@ def __check_rss_rule(rss_rule, title, description, torrent_url, torrent_size, co
if re.search(r"%s" % rss_rule.get("exclude"), "%s %s" % (title, description), re.IGNORECASE):
return False

attr_type = Torrent.check_torrent_attr(torrent_url=torrent_url, cookie=cookie)

log.debug("【BRUSH】%s 解析详情, %s" % (title, attr_type))

# 检查免费状态
if rss_rule.get("free"):
attr_type = Torrent.check_torrent_attr(torrent_url=torrent_url, cookie=cookie)
if rss_rule.get("free") not in attr_type:
if not attr_type.is_free():
return False

# 检查HR状态
if rss_rule.get("hr"):
attr_type = Torrent.check_torrent_attr(torrent_url=torrent_url, cookie=cookie)
if rss_rule.get("hr") in attr_type:
if attr_type.is_hr():
return False

log.debug("【BRUSH】%s `判断做种数, 当前做种人数%s, 当前人数阈值%s" % (title, attr_type.peer_count, rss_rule.get("peercount")))
if rss_rule.get("peercount"):
if attr_type.peer_count > int(rss_rule.get("peercount")):
return False


except Exception as err:
log.console(str(err) + " - " + traceback.format_exc())

Expand Down Expand Up @@ -578,4 +588,4 @@ def __check_remove_rule(remove_rule, seeding_time=None, ratio=None, uploaded=Non
return True
except Exception as err:
log.console(str(err) + " - " + traceback.format_exc())
return False
return False
6 changes: 3 additions & 3 deletions pt/rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,13 @@ def __is_torrent_match_rss(media_info: MetaBase,
if site_parse:
# 检测Free
attr_type = Torrent.check_torrent_attr(torrent_url=media_info.page_url, cookie=site_cookie)
if "2XFREE" in attr_type:
if attr_type.is_free2x():
download_volume_factor = 0.0
upload_volume_factor = 2.0
elif "FREE" in attr_type:
elif attr_type.is_free():
download_volume_factor = 0.0
upload_volume_factor = 1.0
if "HR" in attr_type:
if attr_type.is_hr():
hit_and_run = True
# 设置属性
media_info.set_torrent_info(upload_volume_factor=upload_volume_factor,
Expand Down
117 changes: 78 additions & 39 deletions pt/siteconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,196 +11,235 @@
'pthome.net': {
'FREE': ["//font[@class='free']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'ptsbao.club': {
'FREE': ["//font[@class='free']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'totheglory.im': {
'FREE': ["//img[@class='topic'][contains(@src,'ico_free.gif')]"],
'2XFREE': [],
'HR': ["//img[@src='/pic/hit_run.gif']"]
'HR': ["//img[@src='/pic/hit_run.gif']"],
'PEER_COUNT': [],
},
'www.beitai.pt': {
'FREE': ["//font[@class='free']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'hdtime.org': {
'FREE': ["//font[@class='free']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
},
'www.haidan.video': {
'FREE': ["//img[@class='pro_free'][@title='免费']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'kp.m-team.cc': {
'FREE': ["//font[@class='free']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'lemonhd.org': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"]
},
'discfan.net': {
'FREE': ["//font[@class='free'][text()='免費']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
},
'pt.sjtu.edu.cn': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'nanyangpt.com': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'audiences.me': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': ["//img[@class='hitandrun']"]
'HR': ["//img[@class='hitandrun']"],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"]
},
'pterclub.com': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoupfree'][text()='2X免费']"],
'HR': []
'HR': [],
'PEER_COUNT': ["(//td[@align='left' and @class='rowfollow' and @valign='top']/b[1])[3]"]
},
'et8.org': {
'FREE': ["//font[@class='free']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'pt.keepfrds.com': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'www.pttime.org': {
'FREE': ["//font[@class='free']", "//font[@class='zeroupzerodown']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
},
'1ptba.com': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': [],
'HR': ["//img[@class='hitandrun']"]
'HR': ["//img[@class='hitandrun']"],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
},
'www.tjupt.org': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoup'][text()='2X']"],
'HR': ["//font[@color='red'][text()='Hit&Run']"]
'HR': ["//font[@color='red'][text()='Hit&Run']"],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
},
'hdhome.org': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoupfree'][text()='2X免费']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'hdsky.me': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoupfree'][text()='2X免费']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'hdcity.city': {
'FREE': ["//img[@class='pro_free']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'hdcity.leniter.org': {
'FREE': ["//img[@class='pro_free']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'hdcity.work': {
'FREE': ["//img[@class='pro_free']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'hdcity4.leniter.org': {
'FREE': ["//img[@class='pro_free']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'open.cd': {
'FREE': ["//img[@class='pro_free']"],
'2XFREE': ["//img[@class='pro_free2up']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'ourbits.club': {
'FREE': ["//font[@class='free']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'pt.btschool.club': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoupfree'][text()='2X免费']"],
'HR': []
'HR': [],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
},
'pt.eastgame.org': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoupfree'][text()='2X免费']"],
'HR': []
'HR': [],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
},
'pt.soulvoice.club': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': [],
'HR': ["//img[@class='hitandrun']"]
'HR': ["//img[@class='hitandrun']"],
'PEER_COUNT': [],
},
'springsunday.net': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoupfree'][text()='2X免费']"],
'HR': ["//img[@class='hitandrun']"]
'HR': ["//img[@class='hitandrun']"],
'PEER_COUNT': [],
},
'www.htpt.cc': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
},
'chdbits.co': {
'FREE': ["//img[@class='pro_free']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'hdchina.org': {
'FREE': ["//img[@class='pro_free']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
"ccfbits.org": {
'FREE': ["//font[@color='red'][text()='本种子不计下载量,只计上传量!']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'u2.dmhy.org': {
'FREE': ["//img[@class='pro_free']"],
'2XFREE': [],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'www.hdarea.co': {
'FREE': ["//img[@class='pro_free'][@title='免费']"],
'2XFREE': ["//img[@class='pro_free'][@title='2X免费']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'hdatmos.club': {
'FREE': ["//font[@class='free'][text()='免费']"],
'2XFREE': ["//font[@class='twoupfree'][text()='2X免费']"],
'HR': []
'HR': [],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
},
'avgv.cc': {
'FREE': ["//font[@class='free']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': [],
},
'hdfans.org': {
'FREE': ["//font[@class='free']"],
'2XFREE': ["//font[@class='twoupfree']"],
'HR': []
'HR': [],
'PEER_COUNT': ["//div[@id='peercount']/b[1]"],
}
}
Loading

0 comments on commit ffe4075

Please sign in to comment.