添加aur包过期提示,优化部分代码
This commit is contained in:
parent
7c2a44bb3f
commit
0af6ff0f3b
1 changed files with 16 additions and 6 deletions
|
@ -21,12 +21,20 @@ class Ans(StdAns):
|
|||
repo = '&repo=' + self.parms[2].capitalize()
|
||||
except:
|
||||
print('repo empty')
|
||||
|
||||
def timeTrans(value):
|
||||
temp = time.localtime(int(value))
|
||||
timeValue = time.strftime("%Y-%m-%d %H:%M:%S", temp)
|
||||
return timeValue[:16]
|
||||
|
||||
req = requests.get(
|
||||
url='https://archlinux.org/packages/search/json/?name=' + self.parms[1] + repo).json()
|
||||
if not req['results']:
|
||||
req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=info&arg=' + self.parms[1]).json()
|
||||
req = requests.get(
|
||||
url='https://aur.tuna.tsinghua.edu.cn/rpc/?v=5&type=info&arg=' + self.parms[1]).json()
|
||||
if req['resultcount'] == 0:
|
||||
req = requests.get(url='https://aur.archlinux.org/rpc/?v=5&type=search&arg=' + self.parms[1]).json()
|
||||
req = requests.get(
|
||||
url='https://aur.tuna.tsinghua.edu.cn/rpc/?v=5&type=search&arg=' + self.parms[1]).json()
|
||||
# print(req)
|
||||
if req['resultcount'] > 0:
|
||||
name = '包名:' + req['results'][0]['Name']
|
||||
|
@ -35,16 +43,18 @@ class Ans(StdAns):
|
|||
description = '描述:' + req['results'][0]['Description']
|
||||
maintainer = '维护:' + str(req['results'][0]['Maintainer'])
|
||||
numvotes = '投票:' + str(req['results'][0]['NumVotes'])
|
||||
updatetime = req['results'][0]['LastModified']
|
||||
updatetime = time.localtime(int(updatetime))
|
||||
updatetime = time.strftime("%Y-%m-%d %H:%M:%S", updatetime)
|
||||
updatetime = '更新日期:' + timeTrans(req['results'][0]['LastModified'])
|
||||
outofdate = req['results'][0]['OutOfDate']
|
||||
if outofdate is not None:
|
||||
outofdate=timeTrans(outofdate)
|
||||
updatetime = updatetime + '\n过期日期:' + outofdate
|
||||
url = req['results'][0]['URL']
|
||||
if url is None:
|
||||
url = '链接:None'
|
||||
else:
|
||||
url = '链接:' + url
|
||||
msg = '仓库:AUR\n' + name + '\n' + version + '\n' + description + '\n' + maintainer \
|
||||
+ '\n' + numvotes + '\n更新日期:' + updatetime + '\n' + url
|
||||
+ '\n' + numvotes + '\n' + updatetime + '\n' + url
|
||||
return msg
|
||||
else:
|
||||
repo = req['results'][0]['repo']
|
||||
|
|
Loading…
Reference in a new issue