mirror of
https://github.com/Emersont1/itchio.git
synced 2026-03-11 08:54:39 +00:00
Platform tools (#40)
* Added Platform Tools * autopep8 action fixes (#39) * autopep8 action fixes (#41)
This commit is contained in:
parent
170253793e
commit
9370bbfe46
4 changed files with 19 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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__":
|
||||
|
|
|
|||
|
|
@ -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}"):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue