Skip to content

Commit

Permalink
Added Setup tools entry points
Browse files Browse the repository at this point in the history
  • Loading branch information
Emersont1 committed Mar 9, 2022
1 parent 16446fe commit 68c30fd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 24 deletions.
12 changes: 12 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,31 @@ pip install itchiodl
## Download All Games in library from account

```bash

python -m itchiodl.downloader

# via setup-tools entry point
itch-download
```

This uses the same API the itchio app uses to download the files. If you have 2FA enabled, generate an API key [here](https://itch.io/user/settings/api-keys) and run the following instead

```bash
# via python
python -m itchiodl.downloader --api-key=KEYHERE

# via setup-tools entry point
itch-download -k KEYHERE
```

## Add All Games in a bundle to your library

```bash
# via python
python -m itchiodl.bundle_tool

# via setup-tools entry point
itch-load-bundle
```

This is a bit of a bodge, but it works. It essentially goes through and clicks the "Download" link on every item on the bundle's page, which adds it to your itchio library. It does not download any files. You will need the download page's URL (this will be in the bundle's email, and possibly your purchase history). It will not work with 2FA, and I'm unlikely to be able to fix it without making it far more complicated
Expand Down
18 changes: 11 additions & 7 deletions itchiodl/bundle_tool/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from getpass import getpass
import itchiodl

user = input("Username: ")
password = getpass("Password: ")

l = itchiodl.LoginWeb(user, password)
def main():
user = input("Username: ")
password = getpass("Password: ")

l = itchiodl.LoginWeb(user, password)

url = input("Bundle URL: ")
b = itchiodl.Bundle(l, url)
b.load_games()
url = input("Bundle URL: ")
b = itchiodl.Bundle(l, url)
b.load_games()

if __name__ == "__main__":
main()
36 changes: 20 additions & 16 deletions itchiodl/downloader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@

import itchiodl

parser = argparse.ArgumentParser(
prog='python -m hstp',
description='Build an '
)
def main():
parser = argparse.ArgumentParser(
prog='python -m hstp',
description='Build an '
)

parser.add_argument("-k", "--api-key", help="Use API key instead of username/password")
parser.add_argument("-k", "--api-key", help="Use API key instead of username/password")

args = parser.parse_args()
args = parser.parse_args()

l = ""
l = ""

if not args.api_key:
user = input("Username: ")
password = getpass("Password: ")
l = itchiodl.LoginAPI(user, password)
else:
l = args.api_key
if not args.api_key:
user = input("Username: ")
password = getpass("Password: ")
l = itchiodl.LoginAPI(user, password)
else:
l = args.api_key

lib = itchiodl.Library(l)
lib.load_games()
lib.download_library()
lib = itchiodl.Library(l)
lib.load_games()
lib.download_library()

if __name__ == "__main__":
main()
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "itchiodl"
version = "1.1.2"
version = "1.2.0"
description = "Python Scripts for downloading / archiving your itchio library"
authors = ["Peter Taylor <[email protected]>"]
license = "MIT"
Expand All @@ -17,3 +17,7 @@ clint = "^0.5.1"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.plugins."console_scripts"]
"itch-download" = "itchiodl.downloader.__main__:main"
"itch-load-bundle" = "itchiodl.bundle_tool.__main__:main"

0 comments on commit 68c30fd

Please sign in to comment.