Skip to content

Commit

Permalink
0.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kitUIN committed Nov 7, 2020
1 parent 89cf6b9 commit ad951db
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
42 changes: 17 additions & 25 deletions PicImageSeach/saucenao.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import base64
import io

import requests
Expand Down Expand Up @@ -135,28 +134,21 @@ def __init__(self,
params['output_type'] = output_type
self.params = params

@staticmethod
def _base_64(filename):
with open(filename, 'rb') as f:
coding = base64.b64encode(f.read()) # 读取文件内容,转换为base64编码
# print('本地base64转码~')
return coding.decode()

def _file(self, filename: io.BytesIO):
return filename

def search(self, url: str, files=None):
params = self.params
if url[:4] == 'http': # 网络url
params['url'] = url
else: # 文件
image = Image.open(url)
imageData = io.BytesIO()
image.save(imageData, format='PNG')
files = {'file': ("image.png", imageData.getvalue())}
imageData.close()
resp = requests.post(self.SauceNAOURL, params=params, files=files)
status_code = resp.status_code
logger.info(status_code)
data = resp.json()
return SauceNAOResponse(data)
try:
params = self.params
if url[:4] == 'http': # 网络url
params['url'] = url
else: # 文件
image = Image.open(url)
imageData = io.BytesIO()
image.save(imageData, format='PNG')
files = {'file': ("image.png", imageData.getvalue())}
imageData.close()
resp = requests.post(self.SauceNAOURL, params=params, files=files)
status_code = resp.status_code
logger.info(status_code)
data = resp.json()
return SauceNAOResponse(data)
except Exception as e:
logger.error(e)
2 changes: 1 addition & 1 deletion PicImageSeach/tracemoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def preview_image(self): # 预览
tokenthumb)
return url

def preview_video(self, mute=True):
def preview_video(self, mute=False):
"""
创建预览视频
:param mute:预览视频是否静音,True为静音
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
requests==2.23.0
setuptools~=50.3.0
loguru~=0.5.3
loguru~=0.5.3
Pillow~=7.2.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="PicImageSearch",
version="0.6.0",
version="0.6.1",
author="kitUIN",
author_email="kulujun@gmail.com",
description="PicImageSearch APIs for Python 3.x 适用于 Python 3 以图搜源整合API",
Expand Down
2 changes: 1 addition & 1 deletion test/test1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PicImageSeach.tracemoe import TraceMoe
tracemoe = TraceMoe()
t = tracemoe.search('https://trace.moe/img/tinted-good.jpg')
print(tracemoe.thumbnail)
print(tracemoe.viedo)
print(tracemoe.similarity)
print(type(tracemoe.similarity))

0 comments on commit ad951db

Please sign in to comment.