Skip to content

Commit

Permalink
[fix] error on blog page
Browse files Browse the repository at this point in the history
  • Loading branch information
findix committed Jul 21, 2023
1 parent 3401572 commit b7adf3d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from multiprocessing import cpu_count
from urllib.parse import urlparse
import http.client as http_client
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup, element
import pafy
import requests
import json
Expand Down Expand Up @@ -67,7 +67,12 @@ def http_client_get(self, url):

def http_client_get_json(self, url):
resp = self.http_client_get(url)
return json.loads(resp.read().decode())
try:
resp_str = resp.read().decode()
json_result = json.loads(resp_str)
except json.decoder.JSONDecodeError:
print(f"json decode error\nurl:{url}\n{resp_str}")
return json_result

def http_get(self, url):
try:
Expand Down Expand Up @@ -163,7 +168,7 @@ def download_project(self, hash_id):
except Exception as e:
print(e)

def get_projects(self, username):
def get_projects(self, username) -> element.ResultSet[element.Tag]:
data = []
if username != "":
page = 0
Expand Down Expand Up @@ -197,10 +202,11 @@ def download_by_username(self, username):
if len(data) != 0:
future_list = []
for project in data:
future = self.invoke(
self.download_project, project.string.split("/")[-1]
)
future_list.append(future)
if project.string.startswith("https://www.artstation.com/artwork/"):
future = self.invoke(
self.download_project, project.string.split("/")[-1]
)
future_list.append(future)
futures.wait(future_list)

def download_by_usernames(
Expand Down

0 comments on commit b7adf3d

Please sign in to comment.