From 0af6ff0f3bbc672bd0e771d40a56fc13262f59ff Mon Sep 17 00:00:00 2001 From: liyp Date: Wed, 18 Aug 2021 18:02:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0aur=E5=8C=85=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=8F=90=E7=A4=BA=EF=BC=8C=E4=BC=98=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worker/pkg.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/worker/pkg.py b/worker/pkg.py index 4cca9ad..1dabb71 100644 --- a/worker/pkg.py +++ b/worker/pkg.py @@ -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']