diff --git a/Readme.md b/Readme.md index cf9cd42..5eab20c 100644 --- a/Readme.md +++ b/Readme.md @@ -23,7 +23,13 @@ This uses the same API the itchio app uses to download the files. If you have 2F python -m itchiodl.downloader --api-key=KEYHERE --jobs=4 # via setup-tools entry point +itch-download -k KEYHERE + +# download with multiple threads itch-download -k KEYHERE -j 4 + +# only download osx or cross platform downloads +itch-download -p osx ``` ## Add All Games in a bundle to your library diff --git a/itchiodl/downloader/__main__.py b/itchiodl/downloader/__main__.py index 7770a93..d23ac28 100644 --- a/itchiodl/downloader/__main__.py +++ b/itchiodl/downloader/__main__.py @@ -15,6 +15,11 @@ def main(): "--api-key", help="Use API key instead of username/password") + parser.add_argument( + "-p", + "--platform", + help="Platform to download for (default: all), will accept values like 'windows', 'linux', 'osx' and android") + parser.add_argument( "-j", "--jobs", @@ -35,7 +40,7 @@ def main(): lib = itchiodl.Library(l, args.jobs) lib.load_games() - lib.download_library() + lib.download_library(args.platform) if __name__ == "__main__": diff --git a/itchiodl/game.py b/itchiodl/game.py index 963505f..a255b3e 100644 --- a/itchiodl/game.py +++ b/itchiodl/game.py @@ -34,7 +34,7 @@ class Game: for d in j["uploads"]: self.downloads.append(d) - def download(self, token): + def download(self, token, platform): if os.path.exists(f"{self.publisher_slug}/{self.game_slug}.json"): print(f"Skipping Game {self.name}") return @@ -48,6 +48,10 @@ class Game: os.mkdir(f"{self.publisher_slug}/{self.game_slug}") for d in self.downloads: + if platform is not None and d["traits"] and f"p_{platform}" not in d["traits"]: + print(f"Skipping {self.name} for platform {d['traits']}") + continue + file = d['filename'] or d['display_name'] or d['id'] path = f"{self.publisher_slug}/{self.game_slug}" if os.path.exists(f"{path}/{file}"): diff --git a/itchiodl/library.py b/itchiodl/library.py index 5859df2..c459670 100644 --- a/itchiodl/library.py +++ b/itchiodl/library.py @@ -32,7 +32,7 @@ class Library: break page += 1 - def download_library(self): + def download_library(self, platform=None): with ThreadPoolExecutor(max_workers=self.jobs) as executor: - def dl(g): return g.download(self.login) + def dl(g): return g.download(self.login, platform) executor.map(dl, self.games)