Skip to content

Commit

Permalink
Bug fixed for error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
ch010060 committed Sep 16, 2020
1 parent 8406657 commit 1be0748
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions dlsite_renamer-cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ def match_code(work_code):
url = VJ_G_WEBPATH + work_code
r = s.get(url, allow_redirects=False, cookies=R_COOKIE)
if r.status_code != 200:
return r.status_code, "", "", []
return r.status_code, "", "", [], [], "", ""
except os.error as err:
print("**請求超時!\n")
print(" 請檢查網絡連接\n")
return "", "", "", []
return "", "", "", [], [], "", ""

# fromstring()在解析xml格式時, 將字串轉換為Element對像, 解析樹的根節點
# 在python中, 對get請求返回的r.content做fromstring()處理, 可以方便進行後續的xpath()定位等
Expand All @@ -178,11 +178,11 @@ def match_code(work_code):
release_date = release_date[2]+release_date[3]+release_date[5]+release_date[6]+release_date[8]+release_date[9]

return 200, title, circle, cvList, authorList, work_age[0], release_date

except os.error as err:
print("**請求超時!\n")
print(" 請檢查網絡連接\n")
return "", "", "", []
return "", "", "", [], [], "", ""

def nameChange(path, del_flag):
print("選擇路徑: " + path + "\n")
Expand Down
6 changes: 3 additions & 3 deletions dlsite_renamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ def match_code(work_code):
url = VJ_G_WEBPATH + work_code
r = s.get(url, allow_redirects=False, cookies=R_COOKIE)
if r.status_code != 200:
return r.status_code, "", "", []
return r.status_code, "", "", [], [], "", ""
except os.error as err:
text.insert(tk.END, "**請求超時!\n")
text.insert(tk.END, " 請檢查網絡連接\n")
return "", "", "", []
return "", "", "", [], [], "", ""

# fromstring()在解析xml格式時, 將字串轉換為Element對像, 解析樹的根節點
# 在python中, 對get請求返回的r.content做fromstring()處理, 可以方便進行後續的xpath()定位等
Expand Down Expand Up @@ -180,7 +180,7 @@ def match_code(work_code):
except os.error as err:
text.insert(tk.END, "**請求超時!\n")
text.insert(tk.END, " 請檢查網絡連接\n")
return "", "", "", []
return "", "", "", [], [], "", ""

def nameChange():
# askdirectory()檔案對話框, 選擇目錄, 返回目錄名
Expand Down

0 comments on commit 1be0748

Please sign in to comment.