Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions plugin_cmds/cmd_decrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class SupportedFiles(Enum):

@classmethod
def get_supported_list(cls):
return list(set(item.value for item in cls))
return list({item.value for item in cls})

@classmethod
def is_supported_suffix(cls, value):
Expand Down Expand Up @@ -66,9 +66,9 @@ def _get_input_files(
raise click.BadParameter("{filename}: file not found or supported.")

expanded_filter = filter(
lambda x: SupportedFiles.is_supported_file(x), expanded
SupportedFiles.is_supported_file, expanded
)
expanded = list(map(lambda x: pathlib.Path(x).resolve(), expanded_filter))
expanded = [pathlib.Path(x).resolve() for x in expanded_filter]
filenames.extend(expanded)

return filenames
Expand Down Expand Up @@ -135,7 +135,7 @@ def extract_chapters(initial, current):
if "chapters" in current:
return initial + [current] + current["chapters"]
else:
return initial + [current]
return [*initial, current]

chapters = list(
reduce(
Expand Down Expand Up @@ -630,7 +630,7 @@ def cli(
FILES are the names of the file to decrypt.
Wildcards `*` and recursive lookup with `**` are supported.

Only FILES with `aax` or `aaxc` suffix are processed.
Only FILES with `aax` or `aaxc` suffix are processed.
Other files are skipped silently.
"""
if not which("ffmpeg"):
Expand Down
2 changes: 1 addition & 1 deletion plugin_cmds/cmd_goodreads-transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
@pass_session
@pass_client
async def cli(session, client, output):
"""YOUR COMMAND DESCRIPTION"""
"""YOUR COMMAND DESCRIPTION."""
logger.debug("fetching library")
bunch_size = session.params.get("bunch_size")
library = await Library.from_api_full_sync(
Expand Down
2 changes: 1 addition & 1 deletion plugin_cmds/cmd_image-urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@timeout_option()
@pass_client()
async def cli(client, asin):
"""Print out the image urls for different resolutions for a book"""
"""Print out the image urls for different resolutions for a book."""
r = await client.get(
f"catalog/products/{asin}",
response_groups="media",
Expand Down
4 changes: 2 additions & 2 deletions plugin_cmds/cmd_listening-stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ async def _get_stats_year(client, year):
)
@pass_client
async def cli(client, output, signup_year):
"""Get and analyse listening statistics"""
year_range = [y for y in range(signup_year, current_year+1)]
"""Get and analyse listening statistics."""
year_range = list(range(signup_year, current_year+1))

r = await asyncio.gather(
*[_get_stats_year(client, y) for y in year_range]
Expand Down
10 changes: 5 additions & 5 deletions plugin_cmds/convert_oa_cred.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Converts the credentials.json file from OpenAudible >= v2.4 beta to an
audible-cli auth file. The credentials.json file from OpenAudible leaves
unchanged, so you can use one device registration for OpenAudible and
audible-cli auth file. The credentials.json file from OpenAudible leaves
unchanged, so you can use one device registration for OpenAudible and
audible-cli.
"""

Expand Down Expand Up @@ -41,7 +41,7 @@ def make_auth_file(fn, origin):
device_info = extensions["device_info"]
customer_info = extensions["customer_info"]

website_cookies = dict()
website_cookies = {}
for cookie in tokens["website_cookies"]:
website_cookies[cookie["Name"]] = cookie["Value"].replace(r'"', r"")

Expand Down Expand Up @@ -70,8 +70,8 @@ def make_auth_file(fn, origin):
help="OpenAudible credentials.json file")
@pass_session
def cli(session, input):
"""Converts a OpenAudible credential file to a audible-cli auth file
"""Converts a OpenAudible credential file to a audible-cli auth file.

Stores the auth files in app dir
"""
fdata = pathlib.Path(input).read_text("utf-8")
Expand Down
32 changes: 13 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -195,28 +195,22 @@ lines-after-imports = 2
# individual findings. Shrink the list by fixing a rule in a file and
# dropping its code here.
"docs/source/conf.py" = ["A001"]
"plugin_cmds/cmd_decrypt.py" = ["C401", "C417", "PLR0917", "PLW0108", "RUF005", "W291"]
"plugin_cmds/cmd_goodreads-transform.py" = ["D415", "G004"]
"plugin_cmds/cmd_image-urls.py" = ["D415"]
"plugin_cmds/cmd_listening-stats.py" = ["C416", "D415"]
"plugin_cmds/convert_oa_cred.py" = ["A002", "C408", "D205", "D415", "W291", "W293"]
"src/audible_cli/_logging.py" = ["B028", "C408", "D205", "G004"]
"src/audible_cli/cli.py" = ["C408", "D415"]
"plugin_cmds/cmd_decrypt.py" = ["PLR0917"]
"plugin_cmds/cmd_goodreads-transform.py" = ["G004"]
"plugin_cmds/convert_oa_cred.py" = ["A002", "D205"]
"src/audible_cli/_logging.py" = ["D205", "G004"]
"src/audible_cli/cmds/__init__.py" = ["D205"]
"src/audible_cli/cmds/cmd_api.py" = ["D415", "G004", "W291"]
"src/audible_cli/cmds/cmd_download.py" = ["ASYNC240", "C901", "D415", "G004", "PLR0917", "PLW0603", "PLW2901", "S101"]
"src/audible_cli/cmds/cmd_library.py" = ["D415"]
"src/audible_cli/cmds/cmd_manage.py" = ["D415", "PLR0917"]
"src/audible_cli/cmds/cmd_quickstart.py" = ["D415", "W291"]
"src/audible_cli/cmds/cmd_wishlist.py" = ["D415", "G004"]
"src/audible_cli/config.py" = ["B904", "D415", "D417", "G004", "W291", "W293"]
"src/audible_cli/decorators.py" = ["B904", "D205", "D415", "RUF001", "W293"]
"src/audible_cli/cmds/cmd_api.py" = ["G004"]
"src/audible_cli/cmds/cmd_download.py" = ["ASYNC240", "C901", "G004", "PLR0917", "PLW0603", "PLW2901", "S101"]
"src/audible_cli/cmds/cmd_manage.py" = ["PLR0917"]
"src/audible_cli/cmds/cmd_wishlist.py" = ["G004"]
"src/audible_cli/config.py" = ["B904", "D417", "G004"]
"src/audible_cli/decorators.py" = ["B904", "D205", "RUF001"]
"src/audible_cli/downloader.py" = ["G004", "PLR0917"]
"src/audible_cli/exceptions.py" = ["D415"]
"src/audible_cli/models.py" = ["B904", "D205", "D415", "G004", "S101", "W293"]
"src/audible_cli/plugins.py" = ["D200", "D205", "D415", "UP031"]
"src/audible_cli/models.py" = ["B904", "D205", "G004", "S101"]
"src/audible_cli/plugins.py" = ["D205"]
"src/audible_cli/utils.py" = ["G004", "PGH004", "PLR0917"]
"utils/update_chapter_titles.py" = ["C408", "D205", "D415", "S101", "W293"]
"utils/update_chapter_titles.py" = ["D205", "S101"]


[tool.pytest.ini_options]
Expand Down
14 changes: 7 additions & 7 deletions src/audible_cli/_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _set_level(obj, level: str | int | None) -> None:
if 0 < obj.level < audible_cli_logger.level:
warn(
f"{obj.name} level is lower than "
f"{audible_cli_logger.name} logger level"
f"{audible_cli_logger.name} logger level", stacklevel=2
)

def _set_handler(self, handler, name, level):
Expand Down Expand Up @@ -119,19 +119,19 @@ def _normalize_logger(logger):

def _normalize_style_kwargs(styles):
normalized_styles = {
"error": dict(fg="red"),
"exception": dict(fg="red"),
"critical": dict(fg="red"),
"debug": dict(fg="blue"),
"warning": dict(fg="yellow")
"error": {"fg": "red"},
"exception": {"fg": "red"},
"critical": {"fg": "red"},
"debug": {"fg": "blue"},
"warning": {"fg": "yellow"}
}
if styles:
normalized_styles.update(styles)
return normalized_styles


def _normalize_echo_kwargs(echo_kwargs):
normamized_echo_kwargs = dict()
normamized_echo_kwargs = {}
if echo_kwargs:
normamized_echo_kwargs.update(echo_kwargs)
return normamized_echo_kwargs
Expand Down
4 changes: 2 additions & 2 deletions src/audible_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
logger = logging.getLogger("audible_cli")
click_basic_config(logger)

CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}


@plugins.from_folder(get_plugin_dir())
Expand All @@ -42,7 +42,7 @@ def cli():
@version_option
@verbosity_option(cli_logger=logger)
def quickstart(ctx):
"""Entrypoint for the quickstart command"""
"""Entrypoint for the quickstart command."""
try:
sys.exit(ctx.forward(cmd_quickstart.cli))
except click.Abort:
Expand Down
6 changes: 3 additions & 3 deletions src/audible_cli/cmds/cmd_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@
)
@pass_session
def cli(session, **options):
"""Send requests to an Audible API endpoint
"""Send requests to an Audible API endpoint.

Take a look at
https://audible.readthedocs.io/en/latest/misc/external_api.html for known
Take a look at
https://audible.readthedocs.io/en/latest/misc/external_api.html for known
endpoints and parameters.
"""
auth = session.auth
Expand Down
2 changes: 1 addition & 1 deletion src/audible_cli/cmds/cmd_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def display_counter():
@pass_session
@pass_client(headers=CLIENT_HEADERS)
async def cli(session, api_client, **params):
"""Download audiobook(s) from library"""
"""Download audiobook(s) from library."""
client = api_client.session
output_dir = pathlib.Path(params.get("output_dir")).resolve()

Expand Down
6 changes: 3 additions & 3 deletions src/audible_cli/cmds/cmd_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@click.group("library")
def cli():
"""Interact with library"""
"""Interact with library."""


async def _get_library(session, client, resolve_podcasts):
Expand Down Expand Up @@ -77,7 +77,7 @@ async def _get_library(session, client, resolve_podcasts):
@pass_session
@pass_client
async def export_library(session, client, **params):
"""Export library"""
"""Export library."""

@wrap_async
def _prepare_item(item):
Expand Down Expand Up @@ -165,7 +165,7 @@ def _prepare_item(item):
@pass_session
@pass_client
async def list_library(session, client, resolve_podcasts):
"""List titles in library"""
"""List titles in library."""

@wrap_async
def _prepare_item(item):
Expand Down
20 changes: 10 additions & 10 deletions src/audible_cli/cmds/cmd_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,35 @@

@click.group("manage")
def cli():
"""Manage audible-cli"""
"""Manage audible-cli."""


@cli.group("config")
def manage_config():
"""Manage config"""
"""Manage config."""


@cli.group("profile")
def manage_profiles():
"""Manage profiles"""
"""Manage profiles."""


@cli.group("auth-file")
def manage_auth_files():
"""Manage auth files"""
"""Manage auth files."""


@manage_config.command("edit")
@pass_session
def config_editor(session):
"""Open the config file with default editor"""
"""Open the config file with default editor."""
click.edit(filename=os.fspath(session.config.filename))


@manage_profiles.command("list")
@pass_session
def list_profiles(session):
"""List all profiles in the config file"""
"""List all profiles in the config file."""
head = ["P", "Profile", "auth file", "cc"]
config = session.config
profiles = config.data.get("profile")
Expand Down Expand Up @@ -91,7 +91,7 @@ def list_profiles(session):
@pass_session
@click.pass_context
def add_profile(ctx, session, profile, country_code, auth_file, is_primary):
"""Adds a profile to config file"""
"""Adds a profile to config file."""
if not (session.config.dirname / auth_file).exists():
logger.error("Auth file doesn't exists")
raise click.Abort()
Expand All @@ -112,7 +112,7 @@ def add_profile(ctx, session, profile, country_code, auth_file, is_primary):
)
@pass_session
def remove_profile(session, profile):
"""Remove one or multiple profile(s) from config file"""
"""Remove one or multiple profile(s) from config file."""
profiles = session.config.data.get("profile")
for p in profile:
if p not in profiles:
Expand Down Expand Up @@ -180,7 +180,7 @@ def add_auth_file(
session, auth_file, password, audible_username,
audible_password, country_code, external_login, with_username
):
"""Register a new device and add an auth file to config dir"""
"""Register a new device and add an auth file to config dir."""
build_auth_file(
filename=session.config.dirname / auth_file,
username=audible_username,
Expand Down Expand Up @@ -214,7 +214,7 @@ def check_if_auth_file_exists(session, ctx, param, value):
help="The optional password for the auth file."
)
def remove_auth_file(auth_file, password):
"""Deregister a device and remove auth file from config dir"""
"""Deregister a device and remove auth file from config dir."""
auth = Authenticator.from_file(auth_file, password)
device_name = auth.device_info["device_name"]
auth.refresh_access_token()
Expand Down
12 changes: 6 additions & 6 deletions src/audible_cli/cmds/cmd_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def ask_user(config: ConfigFile):
secho(welcome_message, bold=True)
secho(len(welcome_message) * "=", bold=True)

intro = """Quickstart will guide you through the process of build a basic
intro = """Quickstart will guide you through the process of build a basic
config, create a first profile and assign an auth file to the profile now.

The profile created by quickstart will set as primary. It will be used, if no
The profile created by quickstart will set as primary. It will be used, if no
other profile is chosen.

An auth file can be shared between multiple profiles. Simply enter the name of
an existing auth file when asked about it. Auth files have to be stored in the
config dir. If the auth file doesn't exists, it will be created. In this case,
An auth file can be shared between multiple profiles. Simply enter the name of
an existing auth file when asked about it. Auth files have to be stored in the
config dir. If the auth file doesn't exists, it will be created. In this case,
an authentication to the audible server is necessary to register a new device.
"""
echo()
Expand Down Expand Up @@ -139,7 +139,7 @@ def ask_user(config: ConfigFile):
@click.command("quickstart")
@pass_session
def cli(session):
"""Quick setup audible"""
"""Quick setup audible."""
config_file: pathlib.Path = session.app_dir / CONFIG_FILE
config = ConfigFile(config_file, file_exists=False)
if config_file.is_file():
Expand Down
10 changes: 5 additions & 5 deletions src/audible_cli/cmds/cmd_wishlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def _get_wishlist(client):

@click.group("wishlist")
def cli():
"""Interact with wishlist"""
"""Interact with wishlist."""


@cli.command("export")
Expand All @@ -56,7 +56,7 @@ def cli():
)
@pass_client
async def export_wishlist(client, **params):
"""Export wishlist"""
"""Export wishlist."""

@wrap_async
def _prepare_item(item):
Expand Down Expand Up @@ -134,7 +134,7 @@ def _prepare_item(item):
@timeout_option
@pass_client
async def list_wishlist(client):
"""List titles in wishlist"""
"""List titles in wishlist."""

@wrap_async
def _prepare_item(item):
Expand Down Expand Up @@ -179,7 +179,7 @@ def _prepare_item(item):
@timeout_option
@pass_client(limits=limits)
async def add_wishlist(client, asin, title):
"""Add asin(s) to wishlist
"""Add asin(s) to wishlist.

Run the command without any option for interactive mode.
"""
Expand Down Expand Up @@ -262,7 +262,7 @@ async def add_asin(asin):
@timeout_option
@pass_client(limits=limits)
async def remove_wishlist(client, asin, title):
"""Remove asin(s) from wishlist
"""Remove asin(s) from wishlist.

Run the command without any option for interactive mode.
"""
Expand Down
Loading
Loading