-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Using new ygoprodeck domain * Download delay (waiting time between each download) increased from 0.1s to 0.5s * Refactored a lot of the code, should work the same though
- Loading branch information
Showing
18 changed files
with
169 additions
and
153 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ workpath_pyinstaller/ | |
|
||
hd_cards_downloader_tracker | ||
hd_fields_downloader_tracker | ||
HdDownloader.LICENSE.txt |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,14 +1,19 @@ | ||
FILENAME = EDOPro-HD-Downloader | ||
LICENSE = HdDownloader.LICENSE.txt | ||
DISTPATH = bin | ||
WORKPATH = workpath_pyinstaller | ||
ZIP_WIN = windows.zip | ||
FILENAME = EDOPro-HD-Downloader | ||
LICENSE = LICENSE | ||
LICENSE_BIN = HdDownloader.LICENSE.txt | ||
DISTPATH = bin | ||
WORKPATH = workpath_pyinstaller | ||
ZIP_WIN = windows.zip | ||
|
||
build: | ||
pyinstaller main.py -y --distpath "$(DISTPATH)" -F --specpath "$(DISTPATH)" -n "$(FILENAME)" -c --clean --workpath "$(WORKPATH)" | ||
cp "$(LICENSE)" "$(DISTPATH)/$(LICENSE)" | ||
cp "$(LICENSE)" "$(DISTPATH)/$(LICENSE_BIN)" | ||
|
||
rm -rf "$(WORKPATH)" | ||
|
||
7z-win: build | ||
cd "$(DISTPATH)" && 7z a "$(ZIP_WIN)" "$(FILENAME).exe" "$(LICENSE)" | ||
cd "$(DISTPATH)" && 7z a "$(ZIP_WIN)" "$(FILENAME).exe" "$(LICENSE_BIN)" | ||
|
||
clean: | ||
rm -rf "hd_cards_downloader_tracker" | ||
rm -rf "hd_fields_downloader_tracker" |
This file was deleted.
Oops, something went wrong.
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
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
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
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
# Yes, this is correct | ||
# I'm sorry | ||
from command_handler import CommandHandler | ||
from commands.cmd_allcards import COMMAND_ALLCARDS | ||
from commands.cmd_all import COMMAND_ALL | ||
from commands.cmd_allfields import COMMAND_ALLFIELDS | ||
from commands.cmd_exit import COMMAND_EXIT | ||
from commands.cmd_force import COMMAND_FORCE | ||
from commands.cmd_help import COMMAND_HELP | ||
|
||
|
||
def setup_commands(): | ||
import commands.cmd_allcards as _ | ||
import commands.cmd_allfields as _ | ||
import commands.cmd_exit as _ | ||
import commands.cmd_force as _ | ||
import commands.cmd_help as _ | ||
import commands.cmd_all as _ | ||
CommandHandler.add_command(COMMAND_ALL) | ||
CommandHandler.add_command(COMMAND_ALLCARDS) | ||
CommandHandler.add_command(COMMAND_ALLFIELDS) | ||
CommandHandler.add_command(COMMAND_EXIT) | ||
CommandHandler.add_command(COMMAND_FORCE) | ||
CommandHandler.add_command(COMMAND_HELP) |
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,28 @@ | ||
DOWNLOADER_VERSION = "2.1" | ||
"""Program version""" | ||
|
||
REQUEST_HEADERS = { | ||
"User-Agent": f"NiiMiyo-EDOPro-HD-Downloader/{DOWNLOADER_VERSION}" | ||
} | ||
"""Header to be used in an HTTP request""" | ||
|
||
INPUT_STRING = "Insert deck name (without .ydk) or command: " | ||
"""String that appears at user input""" | ||
|
||
YGOPRODECK_CARDS_URL = "https://db.ygoprodeck.com/api/v7/cardinfo.php" | ||
"""Base API URL for YGOProDeck""" | ||
|
||
IMAGES_BASE_URL = "https://images.ygoprodeck.com/images/cards" | ||
"""Base URL for images""" | ||
|
||
CARD_CACHE_PATH = "./hd_cards_downloader_tracker" | ||
"""Path to the cards cache file""" | ||
|
||
FIELD_CACHE_PATH = "./hd_fields_downloader_tracker" | ||
"""Path to the fields cache file""" | ||
|
||
SETUP_CREATION_FILES = (CARD_CACHE_PATH, FIELD_CACHE_PATH) | ||
"""Files needed on setup""" | ||
|
||
SETUP_CREATION_FOLDERS = ("pics", "pics/field") | ||
"""Folders needed on setup""" |
This file was deleted.
Oops, something went wrong.
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
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,30 @@ | ||
import requests | ||
from os.path import join | ||
|
||
from commands.typing import DownloadCard | ||
from constants import IMAGES_BASE_URL | ||
|
||
def download_image(card: DownloadCard) -> bool: | ||
""" | ||
Downloads the card image or artwork and puts in the specified folder. | ||
Returns `True` if downloads successfully, otherwise returns `False`. | ||
""" | ||
|
||
url = IMAGES_BASE_URL | ||
store_at = "./pics/" | ||
|
||
if card.artwork: | ||
url += "_cropped" | ||
store_at += "field/" | ||
url += f"/{card.card_id}.jpg" | ||
|
||
file_path = join(store_at, f"{card.card_id}.jpg") | ||
try: | ||
res = requests.get(url) | ||
with open(file_path, 'wb+') as f: | ||
f.write(res.content) | ||
return True | ||
except Exception as e: | ||
print(f"Error downloading '{card.card_id}': {type(e).__name__}\n{e}") | ||
return False |
Oops, something went wrong.