first commit
This commit is contained in:
commit
07645e33d0
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/images
|
33
README.md
Normal file
33
README.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# Disney's Lorcana Python Tools
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
Before you begin, ensure you have met the following requirements:
|
||||||
|
- Python installed
|
||||||
|
|
||||||
|
You can download the latest version of Python from python.org.
|
||||||
|
During installation, make sure to add Python to your system's PATH.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
To get started with the project, follow these steps:
|
||||||
|
|
||||||
|
Clone the repository to your local machine:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/0ceanslim/lorcana.git
|
||||||
|
```
|
||||||
|
Navigate to the project directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd lorcana
|
||||||
|
```
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
- The only funtionality at the moment is grabbing the pngs for all the cards in the game and saving them into a local folder. You can do that just by running the main script in the root of this directory
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python main.py
|
||||||
|
```
|
||||||
|
This currently runs all the scripts in the src folder and grabs all current card images for the game.
|
48
mian.py
Normal file
48
mian.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def check_python_installation():
|
||||||
|
try:
|
||||||
|
python_version = subprocess.check_output(
|
||||||
|
["python", "--version"], stderr=subprocess.STDOUT, universal_newlines=True
|
||||||
|
)
|
||||||
|
print(f"{python_version}")
|
||||||
|
return True
|
||||||
|
except FileNotFoundError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def install_python():
|
||||||
|
print("Python is not installed. Please download and install it from:")
|
||||||
|
print("https://www.python.org/downloads/")
|
||||||
|
input("Press Enter to continue after installing Python...")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def run_scripts_in_folder(folder_path):
|
||||||
|
if not check_python_installation():
|
||||||
|
install_python()
|
||||||
|
|
||||||
|
# Get a list of all files in the folder
|
||||||
|
script_files = [f for f in os.listdir(folder_path) if f.endswith('.py')]
|
||||||
|
|
||||||
|
if not script_files:
|
||||||
|
print(f"No Python scripts found in {folder_path}")
|
||||||
|
return
|
||||||
|
|
||||||
|
for script_file in script_files:
|
||||||
|
script_path = os.path.join(folder_path, script_file)
|
||||||
|
|
||||||
|
# Run the script using subprocess
|
||||||
|
try:
|
||||||
|
subprocess.run(['python', script_path], check=True)
|
||||||
|
print(f"Script {script_file} executed successfully.")
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
print(f"Error executing script {script_file}: {e}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Specify the folder containing the scripts
|
||||||
|
scripts_folder = "src"
|
||||||
|
|
||||||
|
run_scripts_in_folder(scripts_folder)
|
||||||
|
|
||||||
|
print("Done.")
|
25
src/lorcana_1.1.py
Normal file
25
src/lorcana_1.1.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
def download_images(base_url, set_name, num_images, local_folder):
|
||||||
|
# Ensure the local folder exists
|
||||||
|
os.makedirs(local_folder, exist_ok=True)
|
||||||
|
|
||||||
|
for i in range(205, num_images + 1):
|
||||||
|
image_url = f"{base_url}/{set_name}/{i}.png" #might have to add the set tag here
|
||||||
|
response = requests.get(image_url)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
with open(os.path.join(local_folder, f"{i}.png"), 'wb') as file:
|
||||||
|
file.write(response.content)
|
||||||
|
print(f"Downloaded {i}.png")
|
||||||
|
else:
|
||||||
|
print(f"Failed to download {i}.png - Status code: {response.status_code}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
base_url = "https://www.lorcanawiz.com/images" #/thefirstchapter/TFC-205.png
|
||||||
|
set_name = "thefirstchapter"
|
||||||
|
num_images = 216
|
||||||
|
local_folder = f"images/{set_name}/"
|
||||||
|
|
||||||
|
download_images(base_url, set_name, num_images, local_folder)
|
25
src/lorcana_1.py
Normal file
25
src/lorcana_1.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
def download_images(base_url, set_name, num_images, local_folder):
|
||||||
|
# Ensure the local folder exists
|
||||||
|
os.makedirs(local_folder, exist_ok=True)
|
||||||
|
|
||||||
|
for i in range(1, num_images + 1):
|
||||||
|
image_url = f"{base_url}/{set_name}/TFC-{i}.png" #might have to add the set tag here
|
||||||
|
response = requests.get(image_url)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
with open(os.path.join(local_folder, f"{i}.png"), 'wb') as file:
|
||||||
|
file.write(response.content)
|
||||||
|
print(f"Downloaded {i}.png")
|
||||||
|
else:
|
||||||
|
print(f"Failed to download {i}.png - Status code: {response.status_code}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
base_url = "https://www.lorcanawiz.com/images" #/thefirstchapter/TFC-205.png
|
||||||
|
set_name = "thefirstchapter"
|
||||||
|
num_images = 204
|
||||||
|
local_folder = f"images/{set_name}/"
|
||||||
|
|
||||||
|
download_images(base_url, set_name, num_images, local_folder)
|
27
src/lorcana_2.py
Normal file
27
src/lorcana_2.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
def download_images(base_url, set_name, num_images, local_folder):
|
||||||
|
# Ensure the local folder exists
|
||||||
|
os.makedirs(local_folder, exist_ok=True)
|
||||||
|
|
||||||
|
for i in range(1, num_images + 1):
|
||||||
|
image_url = f"{base_url}/{set_name}/{i}.png"
|
||||||
|
response = requests.get(image_url)
|
||||||
|
|
||||||
|
if response.status_code == 200 and 'image' in response.headers.get('Content-Type', ''):
|
||||||
|
with open(os.path.join(local_folder, f"{i}.png"), 'wb') as file:
|
||||||
|
file.write(response.content)
|
||||||
|
print(f"Downloaded {i}.png")
|
||||||
|
elif response.status_code == 404:
|
||||||
|
print(f"Image {i}.png not found - Status code: {response.status_code}")
|
||||||
|
else:
|
||||||
|
print(f"Failed to download {i}.png - Status code: {response.status_code}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
base_url = "https://www.lorcanawiz.com/images"
|
||||||
|
set_name = "riseofthefloodborn"
|
||||||
|
num_images = 250
|
||||||
|
local_folder = f"images/{set_name}/"
|
||||||
|
|
||||||
|
download_images(base_url, set_name, num_images, local_folder)
|
25
src/lorcana_promos.py
Normal file
25
src/lorcana_promos.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
def download_images(base_url, set_name, num_images, local_folder):
|
||||||
|
# Ensure the local folder exists
|
||||||
|
os.makedirs(local_folder, exist_ok=True)
|
||||||
|
|
||||||
|
for i in range(1, num_images + 1):
|
||||||
|
image_url = f"{base_url}/{set_name}/{i}.png" #might have to add the set tag here
|
||||||
|
response = requests.get(image_url)
|
||||||
|
|
||||||
|
if response.status_code == 200 and 'image' in response.headers.get('Content-Type', ''):
|
||||||
|
with open(os.path.join(local_folder, f"{i}.png"), 'wb') as file:
|
||||||
|
file.write(response.content)
|
||||||
|
print(f"Downloaded {i}.png")
|
||||||
|
else:
|
||||||
|
print(f"Failed to download {i}.png - Status code: {response.status_code}")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
base_url = "https://www.lorcanawiz.com/images" #/thefirstchapter/205.png
|
||||||
|
set_name = "promos"
|
||||||
|
num_images = 24
|
||||||
|
local_folder = f"images/{set_name}/"
|
||||||
|
|
||||||
|
download_images(base_url, set_name, num_images, local_folder)
|
Loading…
Reference in New Issue
Block a user