requests instead of wget

weird bug with wget for some urls because it can't detect the filename, even though we provide a filename
This commit is contained in:
hlky 2022-10-04 23:08:24 +01:00
parent 177e96fea9
commit 8cef7c8762
No known key found for this signature in database
GPG Key ID: 55A99F1E80D907D5

View File

@ -15,7 +15,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# base webui import and utils.
from sd_utils import *
import wget
# streamlit imports
@ -32,7 +31,13 @@ def download_file(file_name, file_path, file_url):
if not os.path.exists(file_path + '/' + file_name):
print('Downloading ' + file_name + '...')
# TODO - add progress bar in streamlit
wget.download(url=file_url, out=file_path + '/' + file_name)
# download file with `requests``
with requests.get(file_url, stream=True) as r:
r.raise_for_status()
with open(file_path + '/' + file_name, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
else:
print(file_name + ' already exists.')