Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audible brazil #194

Closed
mkb79 opened this issue Sep 21, 2023 · 11 comments · Fixed by #195 or #204
Closed

Audible brazil #194

mkb79 opened this issue Sep 21, 2023 · 11 comments · Fixed by #195 or #204
Labels
enhancement New feature or request

Comments

@mkb79
Copy link
Owner

mkb79 commented Sep 21, 2023

Audible now has a new marketplace on www.audible.com.br.

Need to implement this in this package.

@mkb79 mkb79 added the enhancement New feature or request label Sep 21, 2023
@mkb79
Copy link
Owner Author

mkb79 commented Sep 21, 2023

Until the Brazilian marketplace is hardcoded in my package it can be used these way:

from audible.localization import Locale

brazil_locale = Locale("br", "com.br", "A10J1VAYUDTYRN")

Now you can use the brazil_locale as locale keyword so:

from audible import Authenticator, Client, AsyncClient

# login
login = Authenticator.from_login(…, locale=brazil_locale)

# login external
login_external = Authenticator.from_login_external(locale=brazil_locale, …)

# load credentials
auth = Authenticator.from_file(…, locale=brazil_locale)

@mkb79
Copy link
Owner Author

mkb79 commented Sep 21, 2023

The Brazilian marketplace can be tested out using TestPyPI with these command

pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ audible==0.8.3.dev1695285418

Comments are welcome.

@fcarreira66
Copy link

Thanks for your Audible's support to Brazilian marketplace. Is there anything to do in Audible-cli's code to support it? Even using Audible development version 0.8.3, Audible-cli does not recognise Audible BR.

@mkb79
Copy link
Owner Author

mkb79 commented Sep 26, 2023

I does not know that you want to use audible-cli. The brazil marketplace must be implemented there. I will rework audible-cli soon to create the marketplaces dynamically from the audible package.

In the meantime you can change the source code of the following files in audible-cli:

  1. cmds/cmd_manage.py
  2. cmds/cmd_api.py
  3. cmds/cmd_quickstart.py

In each of these files are exist one line(s) ["us", "ca", "uk", "au", "fr", "de", "es", "jp", "it", "in"].

You have to extend the list with br. The result should looks ["us", "ca", "uk", "au", "fr", "de", "es", "jp", "it", "in", "br"].

If you modify audible-cli these way and install the audible dev version in the same venv (if you use a venv) then it will work.

@mkb79
Copy link
Owner Author

mkb79 commented Sep 26, 2023

@fcarreira66
audible-cli v0.2.5 is now on PyPI. The update supports dynamically loading of audible marketplaces. So you only need to install audible_cli and then audible dev version into the same venv and it will work.

@mkb79
Copy link
Owner Author

mkb79 commented Sep 27, 2023

@fcarreira66
Another good news. I've updated audible to v0.9.0 now. If you reinstall audible-cli it will now work out of the box. But make sure that the new audible package is also updated.

@fcarreira66
Copy link

Wow, I apreciate your effort, thank you!
But, it seems that Audible BR is not working (yet) for login via external browser (I am using Audible-cli version 0.2.5 and Audible version 0.9.0).

When I ran Audible-Cli and chose external browser, the link was generated and the response of Audible BR site was: https://www.amazon.com.br/ap/404

When I typed my credentials (Amazon BR's login and password), audible-cli exited with error:
Login with amazon to your audible account now.
Captcha found
Open Captcha with default image viewer [Y/n]: y
Answer for CAPTCHA: ******
2FA is activated for this account.
Please enter OTP Code: ******
Uncaught Exception
Traceback (most recent call last):
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\audible_cli\cli.py", line 60, in main
sys.exit(cli(*args, **kwargs))
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\click\decorators.py", line 92, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\audible_cli\cmds\cmd_quickstart.py", line 162, in cli
build_auth_file(
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\audible_cli\utils.py", line 102, in build_auth_file
auth = Authenticator.from_login(
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\audible\auth.py", line 408, in from_login
login_device = login(
File "C:\Users\My_login\AppData\Roaming\Python\Python311\site-packages\audible\login.py", line 491, in login
raise Exception("Login failed. Please check the log.")
Exception: Login failed. Please check the log.

Is there a log file for this? Where is it location?
Again, I am really thanksful for your help.

@mkb79
Copy link
Owner Author

mkb79 commented Sep 27, 2023

@fcarreira66
I've to look deeper into this issue.

In the meantime you can use the us locale for the quickstart. Then go to the config dir and change the country_code in the config.toml file to br.

Edit:
One good news: I've found the reason for your issue with the external login. The bad: external login is not so easy to realize for the br marketplace.

The background:
The browser redirects to a page /ap/maplanding after a successfully login. This will work on all other marketplaces. But the br server responses with a HTTP 302 redirect to https://www.amazon.com.br/ap/404 instead of showing the requested /ap/maplanding url. But if you use the dev tools on Chrome you can search in the location header off any response for the ap/maplanding url. I'm hope you understand what I mean.

@mkb79 mkb79 linked a pull request Sep 27, 2023 that will close this issue
@mkb79 mkb79 reopened this Sep 27, 2023
@mkb79
Copy link
Owner Author

mkb79 commented Sep 27, 2023

@fcarreira66
If you update audible to v0.9.1 then you are now able to login to brazilian marketplace. External login will not work without additional user work.

@fcarreira66
Copy link

Yes, thank you! It worked with audible v.0.9.1. I ran **audible quickstart** with my Audible BR's credentials and I got it. Not tested with external login via browser.

@mkb79
Copy link
Owner Author

mkb79 commented Sep 28, 2023

Great to hear that. I'll close this issue now. Please open a new one if you encounter in any other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants