Add proxy parameter to res download function
parent
f887f5fd84
commit
3a7ffaef6d
|
@ -5,14 +5,15 @@ import zipfile
|
|||
|
||||
import requests
|
||||
|
||||
import lokrez.characters_ssbu as characters_ssbu
|
||||
from .characters_ssbu import EVERYONE
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
def download_file(url, with_progressbar = True):
|
||||
def download_file(url, with_progressbar = True, proxy = None):
|
||||
|
||||
r = requests.get(
|
||||
url,
|
||||
stream = with_progressbar,
|
||||
proxies = { "https": proxy, "http": proxy },
|
||||
)
|
||||
|
||||
if not with_progressbar:
|
||||
|
@ -44,7 +45,7 @@ def download_file(url, with_progressbar = True):
|
|||
return f
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
def download_res_ssbu(dstdir, log=None):
|
||||
def download_res_ssbu(dstdir, proxy = None, log=None):
|
||||
"""Downloads SSBU resources from spriters and rename them according to
|
||||
lokrez expectations"""
|
||||
|
||||
|
@ -53,11 +54,11 @@ def download_res_ssbu(dstdir, log=None):
|
|||
# -------------------------------------------------------------------------
|
||||
# Download stock icons
|
||||
log.info("Downloading stock icons...")
|
||||
fstocks = download_file(stock_icons_url)
|
||||
fstocks = download_file(stock_icons_url, proxy = proxy)
|
||||
zfstocks = zipfile.ZipFile(fstocks)
|
||||
|
||||
# Iter over each character
|
||||
for character in characters_ssbu.EVERYONE:
|
||||
for character in EVERYONE:
|
||||
log.info("Downloading images for {}...".format(character.name))
|
||||
|
||||
# Create directory for this character
|
||||
|
@ -82,7 +83,7 @@ def download_res_ssbu(dstdir, log=None):
|
|||
|
||||
# Download urls & write image files
|
||||
for url in character.spritersurls:
|
||||
f = download_file(url)
|
||||
f = download_file(url, proxy = proxy)
|
||||
with zipfile.ZipFile(f) as zfchar:
|
||||
for zf in [zfchar,zfstocks]:
|
||||
for source_filename in zf.namelist():
|
||||
|
|
Loading…
Reference in New Issue