mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
1. 修复更新个人数据是报invalid literal for int() with base 10: ''错误的bug
This commit is contained in:
@@ -110,40 +110,43 @@ class PtSpider:
|
||||
res = '你还没有配置通知参数哦!'
|
||||
if len(notifies) <= 0:
|
||||
return res
|
||||
for notify in notifies:
|
||||
if notify.name == PushConfig.wechat_work_push:
|
||||
"""企业微信通知"""
|
||||
notify_push = WechatPush(
|
||||
corp_id=notify.corpid,
|
||||
secret=notify.corpsecret,
|
||||
agent_id=notify.agentid, )
|
||||
res = notify_push.send_markdown(text)
|
||||
try:
|
||||
for notify in notifies:
|
||||
if notify.name == PushConfig.wechat_work_push:
|
||||
"""企业微信通知"""
|
||||
notify_push = WechatPush(
|
||||
corp_id=notify.corpid,
|
||||
secret=notify.corpsecret,
|
||||
agent_id=notify.agentid, )
|
||||
res = notify_push.send_markdown(text)
|
||||
|
||||
print(res)
|
||||
print(res)
|
||||
|
||||
if notify.name == PushConfig.wxpusher_push:
|
||||
"""WxPusher通知"""
|
||||
res = WxPusher.send_message(
|
||||
content=text,
|
||||
url=url,
|
||||
uids=notify.touser.split(','),
|
||||
token=notify.corpsecret,
|
||||
content_type=3, # 1:文本,2:html,3:markdown
|
||||
)
|
||||
print(res)
|
||||
if notify.name == PushConfig.wxpusher_push:
|
||||
"""WxPusher通知"""
|
||||
res = WxPusher.send_message(
|
||||
content=text,
|
||||
url=url,
|
||||
uids=notify.touser.split(','),
|
||||
token=notify.corpsecret,
|
||||
content_type=3, # 1:文本,2:html,3:markdown
|
||||
)
|
||||
print(res)
|
||||
|
||||
if notify.name == PushConfig.pushdeer_push:
|
||||
pushdeer = PushDeer(
|
||||
server=notify.custom_server,
|
||||
pushkey=notify.corpsecret)
|
||||
# res = pushdeer.send_text(text, desp="optional description")
|
||||
res = pushdeer.send_markdown(text)
|
||||
print(res)
|
||||
if notify.name == PushConfig.pushdeer_push:
|
||||
pushdeer = PushDeer(
|
||||
server=notify.custom_server,
|
||||
pushkey=notify.corpsecret)
|
||||
# res = pushdeer.send_text(text, desp="optional description")
|
||||
res = pushdeer.send_markdown(text=text, desp="PushDeer消息提醒")
|
||||
print(res)
|
||||
|
||||
if notify.name == PushConfig.bark_push:
|
||||
url = notify.custom_server + notify.corpsecret + '/' + text
|
||||
res = self.get_scraper().get(url=url)
|
||||
print(res)
|
||||
if notify.name == PushConfig.bark_push:
|
||||
url = notify.custom_server + notify.corpsecret + '/' + text
|
||||
res = self.get_scraper().get(url=url)
|
||||
print(res)
|
||||
except Exception as e:
|
||||
print("通知发送失败," + str(e))
|
||||
|
||||
def send_request(self,
|
||||
my_site: MySite,
|
||||
@@ -771,6 +774,11 @@ class PtSpider:
|
||||
# seed = self.get_user_torrent(seeding_html, site.seed_rule)
|
||||
leech = ''.join(details_html.xpath(site.leech_rule)).strip()
|
||||
seed = ''.join(details_html.xpath(site.seed_rule)).strip()
|
||||
if not leech and not seed:
|
||||
return CommonResponse.error(
|
||||
status=StatusCodeEnum.WEB_CONNECT_ERR,
|
||||
msg=StatusCodeEnum.WEB_CONNECT_ERR.errmsg + '请检查网站访问是否正常?'
|
||||
)
|
||||
# seed = len(seed_vol_list)
|
||||
ratio = ''.join(details_html.xpath(site.ratio_rule)).replace(',', '').strip(']:').strip()
|
||||
if ratio == '无限' or ratio == '∞' or ratio == '---':
|
||||
@@ -856,23 +864,23 @@ class PtSpider:
|
||||
my_site.my_level = my_level if my_level != '' else ' '
|
||||
if my_hr:
|
||||
my_site.my_hr = my_hr
|
||||
my_site.seed = int(seed)
|
||||
my_site.seed = int(seed) if seed else 0
|
||||
print(leech)
|
||||
my_site.leech = int(leech)
|
||||
my_site.leech = int(leech) if leech else 0
|
||||
|
||||
print('站点:', site)
|
||||
print('等级:', my_level, )
|
||||
print('魔力:', my_sp, )
|
||||
print('积分:', my_bonus if my_bonus else 0)
|
||||
print('分享率:', ratio, )
|
||||
print('下载量:', downloaded, )
|
||||
print('上传量:', uploaded, )
|
||||
print('邀请:', invitation, )
|
||||
print('注册时间:', time_join, )
|
||||
print('最后活动:', latest_active)
|
||||
print('H&R:', my_hr)
|
||||
print('上传数:', seed)
|
||||
print('下载数:', leech)
|
||||
# print('等级:', my_level, )
|
||||
# print('魔力:', my_sp, )
|
||||
# print('积分:', my_bonus if my_bonus else 0)
|
||||
# print('分享率:', ratio, )
|
||||
# print('下载量:', downloaded, )
|
||||
# print('上传量:', uploaded, )
|
||||
# print('邀请:', invitation, )
|
||||
# print('注册时间:', time_join, )
|
||||
# print('最后活动:', latest_active)
|
||||
# print('H&R:', my_hr)
|
||||
# print('上传数:', seed)
|
||||
# print('下载数:', leech)
|
||||
try:
|
||||
res_sp_hour = self.get_hour_sp(my_site=my_site)
|
||||
if not res_sp_hour[1]:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
import qbittorrentapi
|
||||
import time
|
||||
import transmission_rpc
|
||||
from django.contrib import admin, messages
|
||||
from django.db import transaction
|
||||
@@ -364,33 +364,33 @@ class MySiteAdmin(ImportExportModelAdmin): # instead of ModelAdmin
|
||||
if result.code == StatusCodeEnum.OK.code:
|
||||
res = pt_spider.parse_status_html(my_site, result.data)
|
||||
# print(my_site.site, result)
|
||||
site_status = res.data[0]
|
||||
if isinstance(site_status, SiteStatus):
|
||||
message = my_site.site.name + '{}'.format('信息获取成功!' if res.data[1] else '信息更新成功!')
|
||||
# status = my_site.sitestatus_set.filter(created_at__date__gte=datetime.today()).first()
|
||||
# print(status.ratio)
|
||||
message += message_template.format(
|
||||
my_site.my_level,
|
||||
site_status.my_sp,
|
||||
my_site.sp_hour,
|
||||
site_status.my_bonus,
|
||||
site_status.ratio,
|
||||
site_status.downloaded,
|
||||
site_status.uploaded,
|
||||
my_site.seed,
|
||||
my_site.leech,
|
||||
my_site.invitation,
|
||||
my_site.my_hr
|
||||
)
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.SUCCESS,
|
||||
message=message)
|
||||
else:
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.ERROR,
|
||||
my_site.site.name + '信息更新失败!原因:' + res.msg)
|
||||
if res.code == StatusCodeEnum.OK.code:
|
||||
site_status = res.data[0]
|
||||
if isinstance(site_status, SiteStatus):
|
||||
message = my_site.site.name + '{}'.format('信息获取成功!' if res.data[1] else '信息更新成功!')
|
||||
# status = my_site.sitestatus_set.filter(created_at__date__gte=datetime.today()).first()
|
||||
# print(status.ratio)
|
||||
message += message_template.format(
|
||||
my_site.my_level,
|
||||
site_status.my_sp,
|
||||
my_site.sp_hour,
|
||||
site_status.my_bonus,
|
||||
site_status.ratio,
|
||||
site_status.downloaded,
|
||||
site_status.uploaded,
|
||||
my_site.seed,
|
||||
my_site.leech,
|
||||
my_site.invitation,
|
||||
my_site.my_hr
|
||||
)
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.SUCCESS,
|
||||
message=message)
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.ERROR,
|
||||
my_site.site.name + '信息更新失败!原因:' + res.msg)
|
||||
else:
|
||||
messages.add_message(
|
||||
request,
|
||||
|
||||
@@ -89,7 +89,7 @@ try:
|
||||
'自动更新个人数据', end - start,
|
||||
time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
)
|
||||
pt_spider.send_text(message_list + consuming)
|
||||
pt_spider.send_text(text=message_list + consuming)
|
||||
|
||||
|
||||
def auto_update_torrents():
|
||||
|
||||
Reference in New Issue
Block a user