diff --git a/CHANGELOG.md b/CHANGELOG.md index dff2013..10e4556 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - +## [0.2.5] - 2022-09-26 + +### Added + +- Dynamically load available marketplaces from the `audible package`. Allows to implement a new marketplace without updating `audible-cli`. + ## [0.2.4] - 2022-09-21 ### Added diff --git a/src/audible_cli/_version.py b/src/audible_cli/_version.py index 66c9501..222ae3a 100644 --- a/src/audible_cli/_version.py +++ b/src/audible_cli/_version.py @@ -1,7 +1,7 @@ __title__ = "audible-cli" __description__ = "Command line interface (cli) for the audible package." __url__ = "https://github.com/mkb79/audible-cli" -__version__ = "0.2.4" +__version__ = "0.2.5" __author__ = "mkb79" __author_email__ = "mkb79@hackitall.de" __license__ = "AGPL" diff --git a/src/audible_cli/cmds/cmd_api.py b/src/audible_cli/cmds/cmd_api.py index 95cfc9c..cd0ff2c 100644 --- a/src/audible_cli/cmds/cmd_api.py +++ b/src/audible_cli/cmds/cmd_api.py @@ -6,6 +6,7 @@ import click from audible import Client +from ..constants import AVAILABLE_MARKETPLACES from ..decorators import pass_session @@ -54,9 +55,7 @@ ) @click.option( "--country-code", "-c", - type=click.Choice( - ["us", "ca", "uk", "au", "fr", "de", "es", "jp", "it", "in"] - ), + type=click.Choice(AVAILABLE_MARKETPLACES), help="Requested Audible marketplace. If not set, the country code for " "the current profile is used." ) diff --git a/src/audible_cli/cmds/cmd_manage.py b/src/audible_cli/cmds/cmd_manage.py index 03e4259..b4399b3 100644 --- a/src/audible_cli/cmds/cmd_manage.py +++ b/src/audible_cli/cmds/cmd_manage.py @@ -6,6 +6,7 @@ from click import echo, secho from tabulate import tabulate +from ..constants import AVAILABLE_MARKETPLACES from ..decorators import pass_session from ..utils import build_auth_file @@ -72,8 +73,7 @@ def list_profiles(session): @click.option( "--country-code", "-cc", prompt="Please enter the country code", - type=click.Choice([ - "us", "ca", "uk", "au", "fr", "de", "jp", "it", "in"]), + type=click.Choice(AVAILABLE_MARKETPLACES), help="The country code for the profile." ) @click.option( diff --git a/src/audible_cli/cmds/cmd_quickstart.py b/src/audible_cli/cmds/cmd_quickstart.py index a5bd8d3..876ee3e 100644 --- a/src/audible_cli/cmds/cmd_quickstart.py +++ b/src/audible_cli/cmds/cmd_quickstart.py @@ -8,7 +8,11 @@ from .. import __version__ from ..config import ConfigFile -from ..constants import CONFIG_FILE, DEFAULT_AUTH_FILE_EXTENSION +from ..constants import ( + AVAILABLE_MARKETPLACES, + CONFIG_FILE, + DEFAULT_AUTH_FILE_EXTENSION +) from ..decorators import pass_session from ..utils import build_auth_file @@ -67,13 +71,11 @@ def ask_user(config: ConfigFile): "Please enter a name for your primary profile", default="audible") - available_country_codes = [ - "us", "ca", "uk", "au", "fr", "de", "es", "jp", "it", "in"] echo() d["country_code"] = prompt( "Enter a country code for the profile", show_choices=False, - type=click.Choice(available_country_codes) + type=click.Choice(AVAILABLE_MARKETPLACES) ) echo() diff --git a/src/audible_cli/constants.py b/src/audible_cli/constants.py index b9954a6..a996d59 100644 --- a/src/audible_cli/constants.py +++ b/src/audible_cli/constants.py @@ -1,5 +1,7 @@ from typing import Dict +from audible.localization import LOCALE_TEMPLATES + APP_NAME: str = "Audible" CONFIG_FILE: str = "config.toml" @@ -16,3 +18,7 @@ } CODEC_HIGH_QUALITY: str = "AAX_44_128" CODEC_NORMAL_QUALITY: str = "AAX_44_64" + +AVAILABLE_MARKETPLACES = [ + market["country_code"] for market in LOCALE_TEMPLATES.values() +]