Added database scripts and updated rebrickable downloader. Fixed #1

This commit is contained in:
2024-06-19 13:42:28 +02:00
parent c25dab304c
commit 2c0e3f49d0
3 changed files with 169 additions and 9 deletions

View File

@@ -5,6 +5,33 @@ import os
import sys
from urllib.parse import urlparse
def get_nil_images():
image_urls = [
"https://rebrickable.com/static/img/nil_mf.jpg",
"https://rebrickable.com/static/img/nil.png"
]
static_folder = "static"
# Create the static folder if it does not exist
if not os.path.exists(static_folder):
os.makedirs(static_folder)
for url in image_urls:
# Extract the output filename from the URL
parsed_url = urlparse(url)
output_file = os.path.join(static_folder, os.path.basename(parsed_url.path))
# Download the image
response = requests.get(url, stream=True)
response.raise_for_status() # Check for any request errors
# Save the image to the static folder
with open(output_file, 'wb') as f:
f.write(response.content)
print(f"Downloaded {output_file}")
def download_and_unzip(url: str):
# Extract the output filename from the URL
parsed_url = urlparse(url)