diff --git a/README.md b/README.md index 25cb923..3455422 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ After we have received the token once, we can use it for further requestes and w #### Commandline-Tool ```bash $ lidl-plus auth -Enter your language (DE, EN, ...): DE -Enter your country (de, at, ...): de +Enter your language (de, en, ...): de +Enter your country (DE, AT, ...): AT Enter your lidl plus username (phone number): +4915784632296 Enter your lidl plus password: Enter the verify code you received via phone: 590287 @@ -45,7 +45,7 @@ Enter the verify code you received via phone: 590287 ```python from lidlplus import LidlPlusApi -lidl = LidlPlusApi(language="DE", country="de") +lidl = LidlPlusApi(language="de", country="AT") lidl.login(phone="+4915784632296", password="password", verify_token_func=lambda: input("Insert code: ")) print(lidl.refresh_token) ``` @@ -78,14 +78,37 @@ Get your receipts as json and receive a list of bought items like: #### Commandline-Tool ```bash -$ lidl-plus --country=de --language=DE --refresh-token=XXXXX receipt --all > data.json +$ lidl-plus --language=de --country=AT --refresh-token=XXXXX receipt --all > data.json ``` #### Python ```python from lidlplus import LidlPlusApi -lidl = LidlPlusApi("DE", "de", refresh_token="XXXXXXXXXX") +lidl = LidlPlusApi("de", "AT", refresh_token="XXXXXXXXXX") for receipt in lidl.tickets(): pprint(lidl.ticket(receipt["id"])) ``` + +## Help +#### Commandline-Tool +```commandline +Lidl Plus API + +options: + -h, --help show this help message and exit + -c CC, --country CC country (DE, BE, NL, AT, ...) + -l LANG, --language LANG language (de, en, fr, it, ...) + -u USER, --user USER Lidl Plus login username + -p XXX, --password XXX Lidl Plus login password + --2fa {phone,email} choose two factor auth method + -r TOKEN, --refresh-token TOKEN + refresh token to authenticate + --skip-verify skip ssl verification + --not-accept-legal-terms not auto accept legal terms updates + -d, --debug debug mode + +commands: + auth authenticate and get token + receipt output last receipts as json +``` diff --git a/lidlplus/__main__.py b/lidlplus/__main__.py index 36c2d9f..1983fa5 100755 --- a/lidlplus/__main__.py +++ b/lidlplus/__main__.py @@ -18,21 +18,25 @@ def get_arguments(): """Get parsed arguments.""" - parser = argparse.ArgumentParser(description="Lidl Plus api") - parser.add_argument("-c", "--country", help="country (DE, EN, FR, IT, ...)") - parser.add_argument("-l", "--language", help="language (de, be, nl, at, ...)") - parser.add_argument("-u", "--user", help="Lidl Plus login user") - parser.add_argument("-p", "--password", help="Lidl Plus login password") - parser.add_argument("--2fa", choices=["phone", "email"], default="phone", help="set 2fa method") - parser.add_argument("-r", "--refresh-token", help="refresh token to authenticate") + parser = argparse.ArgumentParser( + prog="lidl-plus", + description="Lidl Plus API", + formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=28), + ) + parser.add_argument("-c", "--country", metavar="CC", help="country (DE, BE, NL, AT, ...)") + parser.add_argument("-l", "--language", metavar="LANG", help="language (de, en, fr, it, ...)") + parser.add_argument("-u", "--user", help="Lidl Plus login username") + parser.add_argument("-p", "--password", metavar="XXX", help="Lidl Plus login password") + parser.add_argument("--2fa", choices=["phone", "email"], default="phone", help="choose two factor auth method") + parser.add_argument("-r", "--refresh-token", metavar="TOKEN", help="refresh token to authenticate") parser.add_argument("--skip-verify", help="skip ssl verification", action="store_true") - parser.add_argument("--not-accept-legal-terms", help="Deny legal terms updates", action="store_true") + parser.add_argument("--not-accept-legal-terms", help="not auto accept legal terms updates", action="store_true") parser.add_argument("-d", "--debug", help="debug mode", action="store_true") subparser = parser.add_subparsers(title="commands", metavar="command", required=True) - auth = subparser.add_parser("auth", help="authenticate and get refresh_token") - auth.add_argument("auth", help="authenticate and get refresh_token", action="store_true") - receipt = subparser.add_parser("receipt", help="last receipt as json") - receipt.add_argument("receipt", help="last receipt as json", action="store_true") + auth = subparser.add_parser("auth", help="authenticate and get token") + auth.add_argument("auth", help="authenticate and print refresh_token", action="store_true") + receipt = subparser.add_parser("receipt", help="output last receipts as json") + receipt.add_argument("receipt", help="output last receipts as json", action="store_true") receipt.add_argument("-a", "--all", help="fetch all receipts", action="store_true") return vars(parser.parse_args()) @@ -61,8 +65,8 @@ def lidl_plus_login(args): if args.get("skip_verify"): os.environ["WDM_SSL_VERIFY"] = "0" os.environ["CURL_CA_BUNDLE"] = "" - language = args.get("language") or input("Enter your language (DE, EN, ...): ") - country = args.get("country") or input("Enter your country (de, at, ...): ") + language = args.get("language") or input("Enter your language (de, en, ...): ") + country = args.get("country") or input("Enter your country (DE, AT, ...): ") if args.get("refresh_token"): return LidlPlusApi(language, country, args.get("refresh_token")) username = args.get("user") or input("Enter your lidl plus username (phone number): ")