first commit
This commit is contained in:
33
u/joshuakrzemien/mtg_json_download.py
Normal file
33
u/joshuakrzemien/mtg_json_download.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
import wmill
|
||||
import requests
|
||||
|
||||
# You can import any PyPi package.
|
||||
# See here for more info: https://www.windmill.dev/docs/advanced/dependencies_in_python
|
||||
|
||||
# you can use typed resources by doing a type alias to dict
|
||||
#postgresql = dict
|
||||
|
||||
def main():
|
||||
url = "https://mtgjson.com/api/v5/TcgplayerSkus.json.zip"
|
||||
files = {
|
||||
"skus": "https://mtgjson.com/api/v5/TcgplayerSkus.json.zip",
|
||||
"identifiers": "https://mtgjson.com/api/v5/AllIdentifiers.json.zip"
|
||||
}
|
||||
success = {}
|
||||
for file_type, url in files.items():
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
file_name = url.split("/")[-1]
|
||||
content_type = response.headers.get("Content-Type")
|
||||
if content_type == 'application/zip':
|
||||
# save file
|
||||
path = f"./shared/{file_name}"
|
||||
with open(path, 'wb') as f:
|
||||
f.write(response.content)
|
||||
success[file_name] = True
|
||||
else:
|
||||
success[file_name] = False
|
||||
return success
|
||||
# success {"TcgplayerSkus.json.zip": True, "AllIdentifiers.json.zip": True}
|
||||
|
Reference in New Issue
Block a user