Skip to content

Commit

Permalink
feat: load marketplaces dynamically from audible package (#157)
Browse files Browse the repository at this point in the history
* feat: dynamically load available marketplaces

* docs: modify CHANGELOG

* build: bump version 0.2.4 > 0.2.5
  • Loading branch information
mkb79 authored Sep 26, 2023
1 parent acbfa2d commit 69504d6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/audible_cli/_version.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 2 additions & 3 deletions src/audible_cli/cmds/cmd_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import click
from audible import Client

from ..constants import AVAILABLE_MARKETPLACES
from ..decorators import pass_session


Expand Down Expand Up @@ -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."
)
Expand Down
4 changes: 2 additions & 2 deletions src/audible_cli/cmds/cmd_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down
10 changes: 6 additions & 4 deletions src/audible_cli/cmds/cmd_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions src/audible_cli/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Dict

from audible.localization import LOCALE_TEMPLATES


APP_NAME: str = "Audible"
CONFIG_FILE: str = "config.toml"
Expand All @@ -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()
]

0 comments on commit 69504d6

Please sign in to comment.