diff options
Diffstat (limited to 'ATRI/plugins/plugin_anime/data_source.py')
-rw-r--r-- | ATRI/plugins/plugin_anime/data_source.py | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/ATRI/plugins/plugin_anime/data_source.py b/ATRI/plugins/plugin_anime/data_source.py deleted file mode 100644 index a479a0e..0000000 --- a/ATRI/plugins/plugin_anime/data_source.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@File : body.py -@Time : 2020/10/11 14:38:23 -@Author : Kyomotoi -@Contact : [email protected] -@Github : https://github.com/Kyomotoi -@License : Copyright © 2018-2020 Kyomotoi, All Rights Reserved. -''' -__author__ = 'kyomotoi' - -import json - -from ATRI.utils.utils_error import errorRepo -from ATRI.utils.utils_request import request_get - - -class SauceNAO: - """搜图请求主体""" - def __init__(self, - api_key, - output_type=2, - testmode=0, - dbmask=None, - dbmaski=32768, - db=5, - numres=1): - api = 'https://saucenao.com/search.php' - self.api = api - params = dict() - params['api_key'] = api_key - params['output_type'] = output_type - params['testmode'] = testmode - params['dbmask'] = dbmask - params['dbmaski'] = dbmaski - params['db'] = db - params['numres'] = numres - self.params = params - - def search(self, url): - self.params['url'] = url - return request_get(self.api, self.params) - - -def resultRepo(user: str, key: str, img_url: str): - try: - task = SauceNAO(key) - data = task.search(img_url) - print(data) - except Exception: - return errorRepo('请求数据失败') - - data = json.loads(data)['results'][0] - msg0 = '' - print(data) - - msg0 += f'[CQ:at,qq={user}]\n' - msg0 += "SauceNAO INFO:\n" - msg0 += f"[CQ:image,file={data['header'].get('thumbnail', None)}]\n" - msg0 += f"Like:{data['header'].get('similarity', 0)}%\n" - msg0 += f"Title:{data['data'].get('title', None)}\n" - msg0 += f"Pixiv ID:{data['data'].get('pixiv_id', None)}\n" - msg0 += f"Author:{data['data'].get('member_name', None)}\n" - msg0 += f"Autoor ID:{data['data'].get('member_id', None)}\n" - msg0 += f"Pixiv URL: https://www.pixiv.net/artworks/{data['data'].get('pixiv_id', None)}\n" - msg0 += f"Pic URL: https://pixiv.cat/{data['data'].get('pixiv_id', None)}.jpg" - - if float(data['header'].get('similarity', 0)) < 65: - msg0 += '\n注:相似率小于65%不一定正确' - - return msg0
\ No newline at end of file |