Skip to content

Commit

Permalink
Code for downloading tablebase
Browse files Browse the repository at this point in the history
  • Loading branch information
quesswho committed Oct 2, 2024
1 parent 69af2d4 commit 868ab58
Show file tree
Hide file tree
Showing 4 changed files with 618 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,7 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

tb/*.rtbw
tb/*.rtbz
34 changes: 34 additions & 0 deletions downloadtablebase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import requests

# Specify the directory to save the downloaded files
download_directory = 'tb'

# Create the directory if it doesn't exist
os.makedirs(download_directory, exist_ok=True)

# Read the tablebases.txt file
with open('tb/tablebases.txt', 'r') as file:
urls = file.readlines()

# Download each file
for url in urls:
url = url.strip() # Remove any leading/trailing whitespace
if url: # Check if the URL is not empty
try:
# Get the filename from the URL
filename = os.path.join(download_directory, url.split('/')[-1])

# Download the file
response = requests.get(url, allow_redirects=True)

# Check if the request was successful
response.raise_for_status()

# Write the content to a file
with open(filename, 'wb') as f:
f.write(response.content)

print(f'Downloaded: {filename}')
except requests.exceptions.RequestException as e:
print(f'Failed to download {url}: {e}')
Loading

0 comments on commit 868ab58

Please sign in to comment.