ignore file download if 404 not found
This commit is contained in:
parent
8302339932
commit
fe63c823e3
11
main.py
11
main.py
@ -25,11 +25,12 @@ def download_xpi(xpi_url: str, download_dir: str, unique_name: str, force_downlo
|
|||||||
return download_filepath
|
return download_filepath
|
||||||
|
|
||||||
response = requests.get(xpi_url, stream=True)
|
response = requests.get(xpi_url, stream=True)
|
||||||
print(f'download {unique_name} from {xpi_url}')
|
if response.status_code == 200:
|
||||||
with open(download_filepath, "wb") as file:
|
print(f'download {unique_name} from {xpi_url}')
|
||||||
for chunk in response.iter_content(chunk_size=1024):
|
with open(download_filepath, "wb") as file:
|
||||||
file.write(chunk)
|
for chunk in response.iter_content(chunk_size=1024):
|
||||||
return download_filepath
|
file.write(chunk)
|
||||||
|
return download_filepath
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'download {unique_name} from {xpi_url} failed: {e}')
|
print(f'download {unique_name} from {xpi_url} failed: {e}')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user