kitUIN / PicImageSearch

整合图片识别 API,用于以图搜源 / Aggregator for Reverse Image Search API
https://pic-image-search.kituin.fun/
MIT License
428 stars 46 forks source link

关于tracemoe的一个小问题 #24

Closed Numendacil closed 2 years ago

Numendacil commented 2 years ago

tracemoe.py里_get_anime_info获取到的返回信息感觉已经包括了api.trace.moe/search?anilistInfo请求的信息,是否可以只保留一个?(因为trace.moe那边的文档也说anilistInfo=true本质上就是往Anilist API多发一次请求,所以感觉发送两个不是很必要,_get_anime_info里定义的query已经远比trace.moe发送的要详细很多了)

(另外_get_anime_info中的client是不是可以考虑和TraceMoe主类共用一个,这样就没必要每次都开一个新的了

NekoAria commented 2 years ago

还是有必要的,主要是中文标题和动画海报,别的似乎都是已有的。这个暂时是打算缩减请求的内容。

之所以没和主类共用一个 client ,是因为那个 client 是 async 的。你如果有什么重构想法,欢迎回复我。

Numendacil commented 2 years ago

嗯,其实我想的是保留对 trace.moe/anilist/ 的请求而不必在对 api.trace.moe/search 的请求里加上anilistInfo这个query。 async 的话好像确实只能多加一个函数调用,比如

result = TraceMoeResponse(resp.json(), self.mute, self.size)
if anilist_info:   # Get info from Anilist API, otherwise only contains AnilistId
    await result.getInfo(chinese_title, ..., client=self.client)   # may contain other options like different query fields
return result