优化ACGM的API

This commit is contained in:
TNTcraftHIM 2020-08-25 13:44:46 +08:00
parent 0e40bf5e83
commit 0c94ecdf43
2 changed files with 14 additions and 21 deletions

View File

@ -1,7 +1,7 @@
import json
from random import randint
import random
import requests
from time import sleep
from requests import get
from pagermaid.listener import listener
from os import remove
@ -12,32 +12,25 @@ async def joke(context):
await context.edit("获取中 . . .")
status = False
for _ in range (20): #最多重试20次
website = randint(0, 9)
website = random.randint(0, 5)
if website == 0:
img = get("http://api.btstu.cn/sjbz/?lx=m_dongman")
img = requests.get("http://api.btstu.cn/sjbz/?lx=m_dongman")
elif website == 1:
img = get("https://acg.yanwz.cn/api.php")
img = requests.get("https://acg.yanwz.cn/api.php")
elif website == 2:
img = get("https://img.xjh.me/random_img.php?type=bg&ctype=acg&return=302&device=mobile")
img = requests.get("https://img.xjh.me/random_img.php?type=bg&ctype=acg&return=302&device=mobile")
elif website == 3:
img = get("https://www.yunboys.cn/sjbz/api.php?method=mobile&lx=dongman")
img = requests.get("https://www.yunboys.cn/sjbz/api.php?method=mobile&lx=dongman")
elif website == 4:
img = get("http://www.dmoe.cc/random.php")
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063','Referer':'https://osk.soloop.ooo/give_me_eropics-l/'}
img = requests.get("https://osk.soloop.ooo/rdm.php?"+ str(random.random()), headers=headers)
elif website == 5:
img = get("https://api.vvhan.com/api/acgimg")
elif website == 6:
img = get("http://api.mtyqx.cn/api/random.php")
elif website == 7:
img = get("http://random.firefliestudio.com/")
elif website == 8:
img = get("https://api.mmcee.cn/acgimg/acgurl.php")
elif website == 9:
img = get('https://api.lolicon.app/setu/?r18=0')
img = requests.get('https://api.lolicon.app/setu/?r18=0')
if img.status_code == 200:
if website == 9:
if website == 5:
tmp = json.loads(img.content)
img = tmp['data'][0]['url']
img = get(img)
img = requests.get(img)
if img.status_code != 200:
continue #如果返回不正常就赶紧下一回
with open(r'tu.png', 'wb') as f:

View File

@ -232,10 +232,10 @@
},
{
"name": "acg-multi",
"version": "1.1",
"version": "1.2",
"section": "profile",
"maintainer": "TNTcraftHIM",
"size": "2.4 kb",
"size": "2.3 kb",
"supported": true,
"des-short": "多网站随机获取ACG图",
"des": "从几个不同的图库中随机获取二刺螈bushiACG图片基本都是手机尺寸的图。命令acgm。"