Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
fix(wallhaven): 修复wallhaven随机列表不生效的问题
Browse files Browse the repository at this point in the history
Author: ambition-echo
  • Loading branch information
ambition_echo committed Nov 21, 2022
1 parent 293f7fa commit 2970adb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion earth_wallpaper/interfaces/utils/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def nsfw(self):
return trans(str(self.settings.value("APP/NSFW")))

def sorting(self):
return self.settings.value("APP/sorting")
return self.settings.value("APP/sorting").lower().replace(" ", "_")

@staticmethod
def desktop_res() -> (int, int):
Expand Down
5 changes: 3 additions & 2 deletions earth_wallpaper/interfaces/wallhaven.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def build_search_url(self):
self.search_url += f"&sorting={self.sorting}"
if not len(self.apikey) == 0:
self.search_url += f"&apikey={self.apikey}"
print(self.search_url)
print("列表json: " + self.search_url)

def get_img_url(self):
img_info = requests.get(self.search_url, proxies=self.proxies)
Expand All @@ -49,12 +49,13 @@ def get_img_url(self):
self.img_url += img_info_json[randint(0, len(img_info_json) - 1)]["id"]
if not len(self.apikey) == 0:
self.img_url += f"?apikey={self.apikey}"
print(self.img_url)
print("图像信息json: " + self.img_url)

def download(self):
img_info = requests.get(self.img_url, proxies=self.proxies)
if img_info.ok:
download_url = json.loads(img_info.content.decode())["data"]["path"]
print("图像url: " + download_url)
img = requests.get(download_url, proxies=self.proxies)
return img.content

Expand Down

0 comments on commit 2970adb

Please sign in to comment.