mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
1. 增加系统消息提醒功能,检测到新消息直接发送通知
2. 更新红豆饭个人信息获取规则
This commit is contained in:
File diff suppressed because it is too large
Load Diff
30
pt.json
30
pt.json
@@ -728,10 +728,10 @@
|
||||
"pk": 10,
|
||||
"fields": {
|
||||
"created_at": "2022-07-20T10:07:13.505",
|
||||
"updated_at": "2022-08-28T20:13:23.796",
|
||||
"updated_at": "2022-09-05T13:48:54.105",
|
||||
"url": "https://hdfans.org/",
|
||||
"name": "红豆饭",
|
||||
"logo": "favicon.ico",
|
||||
"logo": "http://favicon.ico",
|
||||
"sign_in_support": true,
|
||||
"get_torrent_support": true,
|
||||
"get_userinfo_support": true,
|
||||
@@ -778,21 +778,21 @@
|
||||
"viewpeerlist_rule": ".//tr/td[9]/nobr/text()",
|
||||
"peer_speed_rule": ".//tr/td[5]/nobr/text()",
|
||||
"remark": "",
|
||||
"invitation_rule": "//table/tr[2]/td[2]/a/text()",
|
||||
"time_join_rule": "//table/tr[4]/td[2]/span/@title",
|
||||
"latest_active_rule": "//table/tr[5]/td[2]/span/@title",
|
||||
"uploaded_rule": "//tr[8]/td[2]/table/tr[2]/td[1]/text()",
|
||||
"downloaded_rule": "//tr[8]/td[2]//table/tr[2]/td[2]/text()",
|
||||
"ratio_rule": "//tr[8]/td[2]/table/tr/td[1]/font/text()",
|
||||
"my_sp_rule": "//tr[14]/td[2]/text()",
|
||||
"hour_sp_rule": "//div[contains(text(),\"每小时\")]/text()[1]",
|
||||
"my_bonus_rule": "//tr[15]/td[2]/text()",
|
||||
"my_level_rule": "//tr/td/span/span/a/@class",
|
||||
"my_hr_rule": "//table/tr[114]/td[2]/text()",
|
||||
"invitation_rule": "//a[contains(@href,\"invite.php?id=\")]/following-sibling::text()[1]",
|
||||
"time_join_rule": "//td[contains(text(),\"加入\")]/following-sibling::td[1]//span/@title",
|
||||
"latest_active_rule": "//td[contains(text(),\"最近动向\")]/following-sibling::td[1]//span/@title",
|
||||
"uploaded_rule": "//font[@class=\"color_uploaded\"]/following-sibling::text()[1]",
|
||||
"downloaded_rule": "//font[@class=\"color_downloaded\"]/following-sibling::text()[1]",
|
||||
"ratio_rule": "//font[@class=\"color_ratio\"][1]/following-sibling::text()[1]",
|
||||
"my_sp_rule": "//a[@href=\"mybonus.php\"]/following-sibling::text()[1]",
|
||||
"hour_sp_rule": "//div[contains(text(),\"每小时能获取\")]/text()[1]",
|
||||
"my_bonus_rule": "//font[@class=\"color_bonus\" and contains(text(),\"积分\")]/following-sibling::text()[1]",
|
||||
"my_level_rule": "//span[@class=\"medium\"]/span[@class=\"nowrap\"][1]/a[contains(@class,\"_Name\")]/@class",
|
||||
"my_hr_rule": "//a[@href=\"myhr.php\"]/text()",
|
||||
"leech_rule": "//img[@class=\"arrowdown\"][1]/following-sibling::text()[1]",
|
||||
"seed_rule": "/html/body/b/text()",
|
||||
"seed_rule": "//img[@class=\"arrowup\"][1]/following-sibling::text()[1]",
|
||||
"record_count_rule": "/html/body/b/text()",
|
||||
"seed_vol_rule": "//tr/td[3]",
|
||||
"seed_vol_rule": "//tr/td[4]",
|
||||
"mailbox_rule": "//a[@href=\"messages.php\"]/following-sibling::text()[1]",
|
||||
"hash_rule": "//tr[13]/td[2]/table/tbody/tr/td[1]/text()"
|
||||
}
|
||||
|
||||
@@ -828,6 +828,22 @@ class PtSpider:
|
||||
list2 = ''.join(list1).split('=', 1)[1]
|
||||
return list2.strip(';').strip('"')
|
||||
|
||||
@staticmethod
|
||||
def parse_message_num(messages: str):
|
||||
"""
|
||||
|
||||
:param messages:
|
||||
:return:
|
||||
"""
|
||||
list1 = messages.split('(')
|
||||
if len(list1) > 1:
|
||||
count = re.sub(u"([^(\u0030-\u0039])", "", list1[1])
|
||||
elif len(list1) == 1:
|
||||
count = messages
|
||||
else:
|
||||
count = 0
|
||||
return int(count)
|
||||
|
||||
def parse_status_html(self, my_site: MySite, result: dict):
|
||||
"""解析个人状态"""
|
||||
with lock:
|
||||
@@ -841,15 +857,15 @@ class PtSpider:
|
||||
seed_vol_list = seeding_html.xpath(site.seed_vol_rule)
|
||||
if len(seed_vol_list) > 0:
|
||||
seed_vol_list.pop(0)
|
||||
print('seeding_vol', len(seed_vol_list))
|
||||
# 做种体积
|
||||
seed_vol_all = 0
|
||||
for seed_vol in seed_vol_list:
|
||||
# print(etree.tostring(seed_vol))
|
||||
vol = ''.join(seed_vol.xpath('.//text()'))
|
||||
# print(vol)
|
||||
if not len(vol) <= 0:
|
||||
seed_vol_all += FileSizeConvert.parse_2_byte(vol)
|
||||
print('seeding_vol', len(seed_vol_list))
|
||||
# 做种体积
|
||||
seed_vol_all = 0
|
||||
for seed_vol in seed_vol_list:
|
||||
# print(etree.tostring(seed_vol))
|
||||
vol = ''.join(seed_vol.xpath('.//text()'))
|
||||
# print(vol)
|
||||
if not len(vol) <= 0:
|
||||
seed_vol_all += FileSizeConvert.parse_2_byte(vol)
|
||||
else:
|
||||
seed_vol_all = 0
|
||||
print('做种体积:', FileSizeConvert.parse_2_file_size(seed_vol_all))
|
||||
@@ -965,6 +981,11 @@ class PtSpider:
|
||||
# print('上传数:', seed)
|
||||
# print('下载数:', leech)
|
||||
try:
|
||||
mail_str = ''.join(details_html.xpath(site.mailbox_rule))
|
||||
mail_count = re.findall('\d', mail_str)[-1]
|
||||
if int(mail_count) > 0:
|
||||
template = '### <font color="red">{} 有{}条新短消息,请注意及时查收!</font>'
|
||||
self.send_text(template.format(site.name, mail_count))
|
||||
res_sp_hour = self.get_hour_sp(my_site=my_site)
|
||||
if res_sp_hour.code != StatusCodeEnum.OK.code:
|
||||
logging.error(my_site.site.name + res_sp_hour.msg)
|
||||
@@ -990,7 +1011,7 @@ class PtSpider:
|
||||
except Exception as e:
|
||||
message = my_site.site.name + '解析个人主页信息:失败!原因:' + str(e)
|
||||
logging.error(message)
|
||||
# raise
|
||||
raise
|
||||
self.send_text(site.name + '解析个人主页信息:失败!原因:' + str(e))
|
||||
return CommonResponse.error(msg=message)
|
||||
|
||||
|
||||
@@ -141,21 +141,21 @@ class SiteAdmin(ImportExportModelAdmin): # instead of ModelAdmin
|
||||
['站点信息规则', {
|
||||
'classes': ('collapse',), # CSS
|
||||
'fields': (
|
||||
'invitation_rule',
|
||||
'time_join_rule',
|
||||
'latest_active_rule',
|
||||
'ratio_rule',
|
||||
'uploaded_rule',
|
||||
'downloaded_rule',
|
||||
'seed_vol_rule',
|
||||
'my_level_rule',
|
||||
'ratio_rule',
|
||||
'my_sp_rule',
|
||||
'hour_sp_rule',
|
||||
'my_bonus_rule',
|
||||
'my_hr_rule',
|
||||
'invitation_rule',
|
||||
'uploaded_rule',
|
||||
'downloaded_rule',
|
||||
'seed_rule',
|
||||
'leech_rule',
|
||||
'seed_vol_rule',
|
||||
'my_hr_rule',
|
||||
'mailbox_rule',
|
||||
'time_join_rule',
|
||||
'latest_active_rule',
|
||||
),
|
||||
}],
|
||||
['种子获取规则', {
|
||||
|
||||
@@ -77,7 +77,6 @@ pytz-deprecation-shim==0.1.0.post0
|
||||
PyWavelets==1.3.0
|
||||
PyYAML==6.0
|
||||
qbittorrent-api==2022.8.36
|
||||
qqai==0.2.1
|
||||
redis==4.3.4
|
||||
requests==2.28.1
|
||||
requests-toolbelt==0.9.1
|
||||
|
||||
Reference in New Issue
Block a user