Demo
# Demo
# 示例
import asyncio
from loguru import logger
from PicImageSearch import Network, TraceMoe
from PicImageSearch.model import TraceMoeResponse
# proxies = "http://127.0.0.1:1081"
proxies = None
# url = "https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test05.jpg"
url = r"images/test05.jpg" # 搜索本地图片
@logger.catch()
async def test() -> None:
async with Network(proxies=proxies) as client:
tracemoe = TraceMoe(client=client, mute=False, size=None)
resp = await tracemoe.search(url)
show_result(resp)
def show_result(resp: TraceMoeResponse) -> None:
# logger.info(resp.origin) # 原始数据
logger.info(resp.raw[0].origin)
logger.info(resp.frameCount)
logger.info(resp.raw[0].anilist)
logger.info(resp.raw[0].idMal)
logger.info(resp.raw[0].title)
logger.info(resp.raw[0].title_native)
logger.info(resp.raw[0].title_romaji)
logger.info(resp.raw[0].title_english)
logger.info(resp.raw[0].title_chinese)
logger.info(resp.raw[0].synonyms)
logger.info(resp.raw[0].isAdult)
logger.info(resp.raw[0].filename)
logger.info(resp.raw[0].episode)
logger.info(resp.raw[0].From)
logger.info(resp.raw[0].To)
logger.info(resp.raw[0].similarity)
logger.info(resp.raw[0].video)
logger.info(resp.raw[0].image)
logger.info(resp.raw[0].anime_info)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(test())
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from loguru import logger
from PicImageSearch.model import TraceMoeResponse
from PicImageSearch.sync import TraceMoe as TraceMoeSync
# proxies = "http://127.0.0.1:1081"
proxies = None
# url = "https://raw.githubusercontent.com/kitUIN/PicImageSearch/main/demo/images/test05.jpg"
url = r"images/test05.jpg" # 搜索本地图片
@logger.catch()
def test_sync() -> None:
tracemoe = TraceMoeSync(proxies=proxies, mute=False, size=None)
resp = tracemoe.search(url)
show_result(resp)
def show_result(resp: TraceMoeResponse) -> None:
# logger.info(resp.origin) # 原始数据
logger.info(resp.raw[0].origin)
logger.info(resp.frameCount)
logger.info(resp.raw[0].anilist)
logger.info(resp.raw[0].idMal)
logger.info(resp.raw[0].title)
logger.info(resp.raw[0].title_native)
logger.info(resp.raw[0].title_romaji)
logger.info(resp.raw[0].title_english)
logger.info(resp.raw[0].title_chinese)
logger.info(resp.raw[0].synonyms)
logger.info(resp.raw[0].isAdult)
logger.info(resp.raw[0].filename)
logger.info(resp.raw[0].episode)
logger.info(resp.raw[0].From)
logger.info(resp.raw[0].To)
logger.info(resp.raw[0].similarity)
logger.info(resp.raw[0].video)
logger.info(resp.raw[0].image)
logger.info(resp.raw[0].anime_info)
if __name__ == "__main__":
test_sync()
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Make sure to add code blocks to your code group
- name: 前往查看
desc: 🚀测试文件Demo
link: https://github.com/kitUIN/PicImageSearch/blob/main/demo/demo_tracemoe.py
bgColor: '#DFEEE7'
textColor: '#2A3344'
1
2
3
4
5
6
7
2
3
4
5
6
7
程序输出,部分过长数据已省略
2022-03-27 20:37:43.252 | INFO | __main__:show_result:35 - {'anilist': {'id': 11887, 'idMal': 11887, 'title': {'native': 'ココロコネクト', 'romaji': 'Kokoro Connect', 'english': 'Kokoro Connect'}, 'synonyms': ['Kokoroco'], 'isAdult': False}, 'filename': 'Kokoro Connect - 05 (BD 1280x720 x264 AACx2).mp4', 'episode': 5, 'from': 1166, 'to': 1175, 'similarity': 0.98, 'video': 'https://media.trace.moe/video/11887/Kokoro%20Connect%20-%2005%20(BD%201280x720%20x264%20AACx2).mp4?t=1170.5&token=iq1V8F1GGWnr6Y0tXrGXSxP7S7w', 'image': 'https://media.trace.moe/image/11887/Kokoro%20Connect%20-%2005%20(BD%201280x720%20x264%20AACx2).mp4?t=1170.5&token=iq1V8F1GGWnr6Y0tXrGXSxP7S7w'}
2022-03-27 20:37:43.252 | INFO | __main__:show_result:36 - 9787176
2022-03-27 20:37:43.252 | INFO | __main__:show_result:37 - 11887
2022-03-27 20:37:43.252 | INFO | __main__:show_result:38 - 11887
2022-03-27 20:37:43.252 | INFO | __main__:show_result:39 - {'native': 'ココロコネクト', 'romaji': 'Kokoro Connect', 'english': 'Kokoro Connect'}
2022-03-27 20:37:43.252 | INFO | __main__:show_result:40 - ココロコネクト
2022-03-27 20:37:43.253 | INFO | __main__:show_result:41 - Kokoro Connect
2022-03-27 20:37:43.253 | INFO | __main__:show_result:42 - Kokoro Connect
2022-03-27 20:37:43.253 | INFO | __main__:show_result:43 - 心連·情結
2022-03-27 20:37:43.253 | INFO | __main__:show_result:44 - ['Kokoroco']
2022-03-27 20:37:43.253 | INFO | __main__:show_result:45 - False
2022-03-27 20:37:43.253 | INFO | __main__:show_result:46 - Kokoro Connect - 05 (BD 1280x720 x264 AACx2).mp4
2022-03-27 20:37:43.253 | INFO | __main__:show_result:47 - 5
2022-03-27 20:37:43.253 | INFO | __main__:show_result:48 - 1166
2022-03-27 20:37:43.253 | INFO | __main__:show_result:49 - 1175
2022-03-27 20:37:43.253 | INFO | __main__:show_result:50 - 98.0
2022-03-27 20:37:43.253 | INFO | __main__:show_result:51 - https://media.trace.moe/video/11887/Kokoro%20Connect%20-%2005%20(BD%201280x720%20x264%20AACx2).mp4?t=1170.5&token=iq1V8F1GGWnr6Y0tXrGXSxP7S7w
2022-03-27 20:37:43.253 | INFO | __main__:show_result:52 - https://media.trace.moe/image/11887/Kokoro%20Connect%20-%2005%20(BD%201280x720%20x264%20AACx2).mp4?t=1170.5&token=iq1V8F1GGWnr6Y0tXrGXSxP7S7w
2022-03-27 20:37:43.253 | INFO | __main__:show_result:53 - {'data': {'Media': {'id': 11887, 'title': {'native': 'ココロコネクト', 'romaji': 'Kokoro Connect', 'english': 'Kokoro Connect', 'chinese': '心連·情結'}, 'type': 'ANIME', 'format': 'TV', 'status': 'FINISHED', 'startDate': {'year': 2012, 'month': 7, 'day': 8}, 'endDate': {'year': 2012, 'month': 9, 'day': 30}, 'season': 'SUMMER', 'episodes': 13, 'duration': 24, 'source': 'LIGHT_NOVEL', 'coverImage': {'large': 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/medium/bx11887-AJezDTY27LxZ.png', 'medium': 'https://s4.anilist.co/file/anilistcdn/media/anime/cover/small/bx11887-AJezDTY27LxZ.png'}, 'bannerImage': 'https://s4.anilist.co/file/anilistcdn/media/anime/banner/11887-DWtqKSd0DBFF.jpg', 'genres': ['Drama', 'Romance', 'Slice of Life', 'Supernatural'], 'synonyms': ['Kokoroco', '戀愛隨意鏈', '戀愛隨意連結', '心靈鏈環', '心靈接觸', '心與心的連結'], 'studios': {'edges': [{'isMain': False, 'node': {'id': 92, 'name': 'Starchild Records', 'siteUrl': 'https://anilist.co/studio/92'}}, {'isMain': True, 'node': {'id': 300, 'name': 'SILVER LINK.', 'siteUrl': 'https://anilist.co/studio/300'}}, {'isMain': False, 'node': {'id': 376, 'name': 'Sentai Filmworks', 'siteUrl': 'https://anilist.co/studio/376'}}, {'isMain': False, 'node': {'id': 392, 'name': 'Enterbrain', 'siteUrl': 'https://anilist.co/studio/392'}}]}, 'isAdult': False, 'externalLinks': [{'id': 219, 'url': 'http://www.crunchyroll.com/kokoro-connect', 'site': 'Crunchyroll'}, {'id': 2999, 'url': 'http://kokoro-connect.com/', 'site': 'Official Site'}, {'id': 32128, 'url': 'https://vrv.co/series/GR5VJ0V8R/Kokoro-Connect', 'site': 'VRV'}], 'siteUrl': 'https://anilist.co/anime/11887'}}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
上次更新: 2022/03/27, 20:47:51