-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
618 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}') |
Oops, something went wrong.