diff --git a/Readme.md b/Readme.md index 9ad704b..f82d051 100644 --- a/Readme.md +++ b/Readme.md @@ -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 diff --git a/itchiodl/bundle_tool/__main__.py b/itchiodl/bundle_tool/__main__.py index 6592b51..c47ae89 100644 --- a/itchiodl/bundle_tool/__main__.py +++ b/itchiodl/bundle_tool/__main__.py @@ -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() \ No newline at end of file + url = input("Bundle URL: ") + b = itchiodl.Bundle(l, url) + b.load_games() + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/itchiodl/downloader/__main__.py b/itchiodl/downloader/__main__.py index c53a03f..151b3a5 100644 --- a/itchiodl/downloader/__main__.py +++ b/itchiodl/downloader/__main__.py @@ -3,24 +3,28 @@ from getpass import getpass 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() \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 9f4bbf2..bbc2823 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "MIT" @@ -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" \ No newline at end of file