mkb79 / Audible

A(Sync) Interface for internal Audible API written in pure Python.
https://audible.readthedocs.io
GNU Affero General Public License v3.0
314 stars 38 forks source link

Locale error on Linux Mint 22 #491

Closed qaphsiel closed 2 months ago

qaphsiel commented 2 months ago

Describe the bug After upgrading, audible raises a "can't find locale" exception.

To Reproduce Steps to reproduce the behavior:

  1. Run 'audible' with any command (e.g., not help or with no commands)
  2. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots audible library list, for example, should list my audiobooks.

Desktop (please complete the following information):

Error message:

$ audible library list
Uncaught Exception
Traceback (most recent call last):
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible_cli/cli.py", line 65, in main
    sys.exit(cli(*args, **kwargs))
             ^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/decorators.py", line 92, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible_cli/decorators.py", line 25, in wrapper
    return asyncio.run(f(*args, ** kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible_cli/decorators.py", line 61, in wrapper
    client = session.get_client(**client_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible_cli/config.py", line 346, in get_client
    return self.get_client_for_profile(profile, password, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible_cli/config.py", line 339, in get_client_for_profile
    auth = self.get_auth_for_profile(profile, password)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible_cli/config.py", line 304, in get_auth_for_profile
    auth = Authenticator.from_file(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible/auth.py", line 365, in from_file
    auth.locale = locale
    ^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible/auth.py", line 257, in __setattr__
    value = test_convert(attr, value)
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible/utils.py", line 142, in test_convert
    return string_function_map[key](value) or value
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible/utils.py", line 93, in _check_locale
    return Locale(value.lower())
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/NNNN/.local/share/pipx/venvs/audible-cli/lib/python3.12/site-packages/audible/localization.py", line 139, in __init__
    raise Exception("can\'t find locale")
Exception: can't find locale
qaphsiel commented 2 months ago

I should've been more clear, after upgrading from Mint 21 to 22.

Also, I uninstalled and reinstalled audible-cli, but that didn't help.

qaphsiel commented 2 months ago

Right, so I fixed this by adding the Brazil locale info to audible-cli/lib/python3.12/site-packages/audible/localization.py

That info is:

"brazil": {
    "country_code": "br",
    "domain": "com.br",
    "market_place_id": "A2Q3Y263D00KWC"
},
mkb79 commented 2 months ago

@qaphsiel Which version of Audible do you have installed? Audible since v0.9.0 support Brazil.

qaphsiel commented 2 months ago

@qaphsiel Which version of Audible do you have installed? Audible since v0.9.0 support Brazil.

pip install audible installed 0.8.2, so I guess we have found the problem.

Originally, I think I had a newer version that I'd installed manually (?), but the upgrade broke that, so I just did the pip-based install.

Anyhow, I tried to install from the tar.gz, but my version of python is too new it seems:

ERROR: Package 'audible' requires a different Python: 3.12.3 not in '<3.12,>=3.8'

Edit: I edited the pyproject.toml and raised the max python version to 3.13, and it installed. Appears to work fine.