Added the framework for writing verbose folder names, changed how the destination path was being generated to allow for more runtime configurations, also added an extra argument for skipping files above a certain size however it is not currently implemented.

This commit is contained in:
64Core 2022-05-25 16:15:01 -05:00
parent 9568fd01d4
commit c5673cf974
2 changed files with 31 additions and 4 deletions

View file

@ -18,6 +18,22 @@ def main():
help="Platform to download for (default: all), will accept values like 'windows', 'linux', 'osx' and android",
)
parser.add_argument(
"-vf",
"--verbose-folders",
type=bool,
default=False,
help="Download Folders are named based on the full text version of the title instead of the trimmed URL title"
)
parser.add_argument(
"-sas",
"--skip-above-size",
type=float,
default=float('inf'),
help="Skips individual files that are above the specified size threshold, size in MB"
)
parser.add_argument(
"-j",
"--jobs",
@ -41,6 +57,10 @@ def main():
args = parser.parse_args()
l = ""
global SkipAboveSize
SkipAboveSize = args.skip_above_size
global VerboseFolders
VerboseFolders = args.verbose_folders
if not args.api_key:
user = input("Username: ")

View file

@ -29,6 +29,13 @@ class Game:
self.game_slug = matches.group(2)
self.publisher_slug = matches.group(1)
if "VerboseFolders" in globals():
self.destination_folder = self.game_slug if not VerboseFolders else self.name
else:
self.destination_folder = self.game_slug
print("VerboseFolders Not Detected in Global Variables, Falling Back to Game Slug\n")
self.destination_path = itchiodl.utils.clean_path(f"{self.publisher_slug}/{self.destination_folder}")
self.files = []
self.downloads = []
@ -62,8 +69,8 @@ class Game:
if not os.path.exists(self.publisher_slug):
os.mkdir(self.publisher_slug)
if not os.path.exists(f"{self.publisher_slug}/{self.game_slug}"):
os.mkdir(f"{self.publisher_slug}/{self.game_slug}")
if not os.path.exists(self.destination_path):
os.mkdir(self.destination_path)
for d in self.downloads:
if (
@ -75,7 +82,7 @@ class Game:
continue
self.do_download(d, token)
with open(f"{self.publisher_slug}/{self.game_slug}.json", "w") as f:
with open(f"{self.destination_path}.json", "w") as f:
json.dump(
{
"name": self.name,
@ -94,7 +101,7 @@ class Game:
print(f"Downloading {d['filename']}")
file = itchiodl.utils.clean_path(d["filename"] or d["display_name"] or d["id"])
path = itchiodl.utils.clean_path(f"{self.publisher_slug}/{self.game_slug}")
path = self.destination_path
if os.path.exists(f"{path}/{file}"):
print(f"File Already Exists! {file}")