mirror of
1
0
Fork 0
This commit is contained in:
Tingfeng 2022-06-22 20:53:21 +08:00
parent 324947e2f3
commit 8c5e53faba
1 changed files with 3 additions and 7 deletions

View File

@ -71,15 +71,11 @@ SOURCE_DIR = path.join(path.dirname(__file__), "sources_non_forked")
def download_extract_replace(plugin_name, zip_path, temp_dir, source_dir):
temp_zip_path = path.join(temp_dir, plugin_name)
# Download and extract file in temp dir
with urllib.request.urlopen(zip_path) as req:
with open(temp_zip_path, "wb") as f:
f.write(BytesIO(req.read()))
zip_f = zipfile.ZipFile(temp_zip_path)
zip_f.extractall(temp_dir)
content_disp = req.headers.get("Content-Disposition")
zip_f = zipfile.ZipFile(BytesIO(req.read()))
zip_f.extractall(temp_dir)
content_disp = req.headers.get("Content-Disposition")
filename = re.findall("filename=(.+).zip", content_disp)[0]
plugin_temp_path = path.join(temp_dir, path.join(temp_dir, filename))