Skip to content

Commit

Permalink
🐛 修复部分情况下 EHentai 拿到的缩略图不对的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoAria committed Mar 29, 2022
1 parent 72b6477 commit 3d1e904
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion PicImageSearch/ascii2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def search(self, url: str) -> Ascii2DResponse:
• .raw[0].thumbnail = First index of url image that was found\n
• .raw[0].detail = First index of details image that was found
"""
if url[:4] == "http": # 网络url
if url.startswith("http"): # 网络url
ascii2d_url = "https://ascii2d.net/search/uri"
resp = await self.post(ascii2d_url, data={"uri": url})
else: # 本地文件
Expand Down
2 changes: 1 addition & 1 deletion PicImageSearch/baidu.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, **request_kwargs: Any):
async def search(self, url: str) -> BaiDuResponse:
params = {"from": "pc"}
files = None
if url[:4] == "http": # 网络url
if url.startswith("http"): # 网络url
params["image"] = url
else:
# 上传文件
Expand Down
2 changes: 1 addition & 1 deletion PicImageSearch/ehentai.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def search(self, url: str, ex: bool = False) -> EHentaiResponse:
else "https://upld.e-hentai.org/image_lookup.php"
)
data = {"f_sfile": "search"}
if url[:4] == "http": # 网络url
if url.startswith("http"): # 网络url
file_content = io.BytesIO((await self.get(url)).content)
files = {"sfile": file_content}
else: # 本地文件
Expand Down
2 changes: 1 addition & 1 deletion PicImageSearch/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def search(self, url: str) -> GoogleResponse:
• .raw[2].url = First index of url source that was found\n
• .raw[2].thumbnail = First index of url image that was found
"""
if url[:4] == "http":
if url.startswith("http"):
encoded_image_url = quote(url, safe="")
params = {"image_url": encoded_image_url}
resp = await self.get(self.url, params=params)
Expand Down
2 changes: 1 addition & 1 deletion PicImageSearch/iqdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async def search(
self, url: str, force_gray: bool = False, is_3d: bool = False
) -> IqdbResponse:
iqdb_url = "https://3d.iqdb.org/" if is_3d else "https://iqdb.org/"
if url[:4] == "http": # 网络url
if url.startswith("http"): # 网络url
data = {"url": url}
if force_gray: # 忽略颜色
data["forcegray"] = "on"
Expand Down
6 changes: 5 additions & 1 deletion PicImageSearch/model/ehentai.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def __init__(self, data: PyQuery):
def _arrange(self, data: PyQuery) -> None:
self.title = data.find(".glink").text()
self.url = data.find(".glink").parent("a").attr("href")
self.thumbnail = data.find(".glthumb img").attr("src")
self.thumbnail = data.find(".glthumb img")
if self.thumbnail.attr("src").startswith("http"):
self.thumbnail = self.thumbnail.attr("src")
else:
self.thumbnail = self.thumbnail.attr("data-src")
self.type = data.find(".cn").eq(0).text()
self.date = data.find("[id^='posted']").eq(0).text()
self.tags = [i.text() for i in data.find("div.gt").items()]
Expand Down
2 changes: 1 addition & 1 deletion PicImageSearch/model/iqdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _arrange(self, data: PyQuery) -> None:

@staticmethod
def _get_url(url: str) -> str:
if url[:4] == "http":
if url.startswith("http"):
return url
return f"https:{url}"

Expand Down
2 changes: 1 addition & 1 deletion PicImageSearch/saucenao.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def search(self, url: str) -> SauceNAOResponse:
"""
params = self.params
files = None
if url[:4] == "http": # 网络url
if url.startswith("http"): # 网络url
params["url"] = url
else:
# 上传文件
Expand Down
2 changes: 1 addition & 1 deletion PicImageSearch/tracemoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def search(
:param cut_borders: 切割黑边框(默认开启)
"""
headers = {"x-trace-key": key} if key else None
if url[:4] == "http": # 网络url
if url.startswith("http"): # 网络url
params = self.set_params(url, anilist_id, anilist_info, cut_borders)
resp = await self.get(self.search_url, headers=headers, params=params) # type: ignore
else: # 本地文件
Expand Down

0 comments on commit 3d1e904

Please sign in to comment.