diff --git a/README.md b/README.md index 754cc56..f872169 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,9 @@ Since v1.5.5, we've already optimized the SHA256 function to the top. So the onl # Change Log +## v1.8.1 +* fix http headers' utf8 issue for downloading + ## v1.8.0 * Add remove model button diff --git a/scripts/ch_lib/downloader.py b/scripts/ch_lib/downloader.py index 2b14ebc..58fdb9c 100644 --- a/scripts/ch_lib/downloader.py +++ b/scripts/ch_lib/downloader.py @@ -41,7 +41,8 @@ def dl(url, folder, filename, filepath): if not file_path: filename = "" if "Content-Disposition" in rh.headers.keys(): - cd = rh.headers["Content-Disposition"] + # headers default is decoded with latin1, so need to re-decode it with utf-8 + cd = rh.headers["Content-Disposition"].encode('latin1').decode('utf-8', errors='ignore') # Extract the filename from the header # content of a CD: "attachment;filename=FileName.txt" # in case "" is in CD filename's start and end, need to strip them out diff --git a/scripts/ch_lib/util.py b/scripts/ch_lib/util.py index fb171bf..9eaa3dd 100644 --- a/scripts/ch_lib/util.py +++ b/scripts/ch_lib/util.py @@ -6,7 +6,7 @@ import requests import shutil -version = "1.8.0" +version = "1.8.1" def_headers = {'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'}