Update download.py

This commit is contained in:
Jarrett Minton 2025-08-27 00:22:01 -06:00
parent 4451fb81e6
commit 75dfd73a34

View File

@ -1,4 +1,3 @@
import requests import requests
import re import re
import os import os
@ -17,15 +16,13 @@ def get_folders():
response = requests.get(BASE_URL, timeout=10) response = requests.get(BASE_URL, timeout=10)
response.raise_for_status() response.raise_for_status()
# Parse HTML to find directory links
soup = BeautifulSoup(response.text, 'html.parser') soup = BeautifulSoup(response.text, 'html.parser')
folders = [] folders = []
# Look for links that end with '/' (directories)
for link in soup.find_all('a', href=True): for link in soup.find_all('a', href=True):
href = link['href'] href = link['href']
if href.endswith('/') and href not in ['/', '../']: if href.endswith('/') and href not in ['/', '../']:
# Decode URL-encoded folder names
folder_name = unquote(href) folder_name = unquote(href)
folders.append(folder_name) folders.append(folder_name)
@ -78,13 +75,11 @@ def download_folder(folder):
urljoin(BASE_URL, folder) urljoin(BASE_URL, folder)
] ]
# Run wget
result = subprocess.run(cmd, capture_output=True, text=True) result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0: if result.returncode == 0:
print(f"✓ Completed download of: {clean_folder}") print(f"✓ Completed download of: {clean_folder}")
# Change ownership of downloaded folder
if os.path.exists(clean_folder): if os.path.exists(clean_folder):
change_ownership(clean_folder) change_ownership(clean_folder)