mirror of
https://github.com/beetbox/beets.git
synced 2026-11-30 10:24:33 -06:00
typing: add types to command handlers
This commit is contained in:
@@ -1,16 +1,27 @@
|
||||
"""The 'completion' command: print shell script for command line completion."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import re
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import library, logging, plugins, ui
|
||||
from beets.util import syspath
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
# Global logger.
|
||||
log = logging.getLogger("beets")
|
||||
|
||||
|
||||
def print_completion(*args):
|
||||
def print_completion(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
from beets.ui.commands import default_commands
|
||||
|
||||
for line in completion_script(default_commands + plugins.commands()):
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
"""The 'config' command: show and edit user configuration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import config, ui
|
||||
from beets.exceptions import UserError
|
||||
from beets.util import displayable_path, editor_command, interactive_open
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
def config_func(lib, opts, args):
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
def config_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
# Make sure lazy configuration is loaded
|
||||
config.resolve()
|
||||
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
"""The `fields` command: show available fields for queries and format strings."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import textwrap
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import library, ui
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
def _print_keys(query):
|
||||
"""Given a SQLite query result, print the `key` field of each
|
||||
@@ -13,7 +21,7 @@ def _print_keys(query):
|
||||
ui.print_(f" {row['key']}")
|
||||
|
||||
|
||||
def fields_func(lib, opts, args):
|
||||
def fields_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
def _print_rows(names):
|
||||
ui.print_(textwrap.indent("\n".join(sorted(names)), " "))
|
||||
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
"""The 'help' command: show help information for commands."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import ui
|
||||
from beets.exceptions import UserError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
class HelpCommand(ui.Subcommand):
|
||||
def __init__(self):
|
||||
@@ -12,7 +21,9 @@ class HelpCommand(ui.Subcommand):
|
||||
help="give detailed help on a specific sub-command",
|
||||
)
|
||||
|
||||
def func(self, lib, opts, args):
|
||||
def func(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
if args:
|
||||
cmdname = args[0]
|
||||
helpcommand = self.root_parser._subcommand_for_name(cmdname)
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
"""The 'list' command: query and show library contents."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import ui
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
def list_items(lib, query, album, fmt=""):
|
||||
"""Print out items in lib matching query. If album, then search for
|
||||
@@ -15,7 +24,7 @@ def list_items(lib, query, album, fmt=""):
|
||||
ui.print_(format(item, fmt))
|
||||
|
||||
|
||||
def list_func(lib, opts, args):
|
||||
def list_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
list_items(lib, args, opts.album)
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@ from beets.util.deprecation import maybe_replace_legacy_field
|
||||
from .utils import do_query
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from beets.library import LibModel
|
||||
import optparse
|
||||
|
||||
from beets.library import LibModel, Library
|
||||
|
||||
|
||||
class ModifyOperation(NamedTuple):
|
||||
@@ -150,7 +152,7 @@ def modify_parse_args(args, is_album: bool):
|
||||
return query, mods, dels
|
||||
|
||||
|
||||
def modify_func(lib, opts, args):
|
||||
def modify_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
query, mods, dels = modify_parse_args(args, is_album=opts.album)
|
||||
if not mods and not dels:
|
||||
raise UserError("no modifications specified")
|
||||
|
||||
@@ -13,6 +13,9 @@ from beets.util.diff import colordiff
|
||||
from .utils import do_query
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
from beets.util import PathLike
|
||||
|
||||
# Global logger.
|
||||
@@ -147,7 +150,7 @@ def move_items(
|
||||
obj.move(operation=MoveOperation.MOVE, basedir=dest)
|
||||
|
||||
|
||||
def move_func(lib, opts, args):
|
||||
def move_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
dest = opts.dest
|
||||
if dest is not None:
|
||||
dest = normpath(dest)
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
"""The `remove` command: remove items from the library (and optionally delete files)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import ui
|
||||
|
||||
from .utils import do_query
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
def remove_items(lib, query, album, delete, force):
|
||||
"""Remove items matching query from lib. If album, then match and
|
||||
@@ -67,7 +76,7 @@ def remove_items(lib, query, album, delete, force):
|
||||
obj.remove(delete)
|
||||
|
||||
|
||||
def remove_func(lib, opts, args):
|
||||
def remove_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
remove_items(lib, args, opts.album, opts.delete, opts.force)
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,20 @@
|
||||
"""The 'stats' command: show library statistics."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import logging, ui
|
||||
from beets.util import syspath
|
||||
from beets.util.units import human_bytes, human_seconds
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
# Global logger.
|
||||
log = logging.getLogger("beets")
|
||||
|
||||
@@ -49,7 +58,7 @@ Albums: {len(albums)}
|
||||
Album artists: {len(album_artists)}""")
|
||||
|
||||
|
||||
def stats_func(lib, opts, args):
|
||||
def stats_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
show_stats(lib, args, opts.exact)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
"""The `update` command: Update library contents according to on-disk tags."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import library, logging, ui
|
||||
from beets.util import ancestry, syspath
|
||||
@@ -8,6 +11,12 @@ from beets.util.color import colorize
|
||||
|
||||
from .utils import do_query
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
# Global logger.
|
||||
log = logging.getLogger("beets")
|
||||
|
||||
@@ -130,7 +139,7 @@ def update_items(lib, query, album, move, pretend, fields, exclude_fields=None):
|
||||
album.store(fields=album_fields)
|
||||
|
||||
|
||||
def update_func(lib, opts, args):
|
||||
def update_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
# Verify that the library folder exists to prevent accidental wipes.
|
||||
if not os.path.isdir(syspath(lib.directory)):
|
||||
ui.print_("Library path is unavailable or does not exist.")
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
"""The 'version' command: show version information."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from platform import python_version
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import beets
|
||||
from beets import plugins, ui
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
def show_version(*args):
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
def show_version(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
ui.print_(f"beets version {beets.__version__}")
|
||||
ui.print_(f"Python version {python_version()}")
|
||||
# Show plugins.
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
"""The `write` command: write tag information to files."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import library, logging, ui
|
||||
from beets.util import syspath
|
||||
|
||||
from .utils import do_query
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
# Global logger.
|
||||
log = logging.getLogger("beets")
|
||||
|
||||
@@ -40,7 +49,7 @@ def write_items(lib, query, pretend, force):
|
||||
item.try_sync(True, False)
|
||||
|
||||
|
||||
def write_func(lib, opts, args):
|
||||
def write_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
write_items(lib, args, opts.pretend, opts.force)
|
||||
|
||||
|
||||
|
||||
+12
-1
@@ -1,5 +1,7 @@
|
||||
"""Calculate acoustic information and submit to AcousticBrainz."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import errno
|
||||
import hashlib
|
||||
import json
|
||||
@@ -7,12 +9,19 @@ import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import requests
|
||||
|
||||
from beets import plugins, ui, util
|
||||
from beets.exceptions import UserError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
# We use this field to check whether AcousticBrainz info is present.
|
||||
PROBE_FIELD = "mood_acoustic"
|
||||
|
||||
@@ -113,7 +122,9 @@ class AcousticBrainzSubmitPlugin(plugins.BeetsPlugin):
|
||||
cmd.func = self.command
|
||||
return [cmd]
|
||||
|
||||
def command(self, lib, opts, args):
|
||||
def command(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
if not self.url:
|
||||
raise UserError(
|
||||
"This plugin is deprecated since AcousticBrainz no longer "
|
||||
|
||||
@@ -12,7 +12,10 @@ from beets.dbcore import types
|
||||
from beets.exceptions import UserError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
LEVELS = ["/low-level", "/high-level"]
|
||||
@@ -109,7 +112,7 @@ class AcousticPlugin(plugins.BeetsPlugin):
|
||||
help="re-download data when already present",
|
||||
)
|
||||
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
items = lib.items(args)
|
||||
self._fetch_info(
|
||||
items,
|
||||
|
||||
+4
-1
@@ -27,6 +27,7 @@ from beets.plugins import BeetsPlugin
|
||||
from beets.ui import Subcommand, _open_library
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
from collections.abc import Mapping
|
||||
|
||||
from beets.dbcore.query import SQLiteType
|
||||
@@ -931,7 +932,9 @@ class AURAPlugin(BeetsPlugin):
|
||||
def commands(self):
|
||||
"""Add subcommand used to run the AURA server."""
|
||||
|
||||
def run_aura(lib, opts, args):
|
||||
def run_aura(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
"""Run the application using Flask's built in-server.
|
||||
|
||||
Args:
|
||||
|
||||
@@ -12,6 +12,8 @@ from beets.ui import Subcommand, should_write
|
||||
from beets.util.deprecation import deprecate_for_user
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.importer import ImportTask
|
||||
from beets.library import Item, Library
|
||||
|
||||
@@ -62,7 +64,9 @@ class AutoBPMPlugin(BeetsPlugin):
|
||||
cmd.func = self.command
|
||||
return [cmd]
|
||||
|
||||
def command(self, lib: Library, opts, args: list[str]) -> None:
|
||||
def command(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
force = self.config["force"].get(bool) or opts.force
|
||||
quiet = self.config["quiet"].get(bool) or opts.quiet
|
||||
self.calculate_bpm(
|
||||
|
||||
@@ -18,7 +18,10 @@ from beets.util import displayable_path, par_map
|
||||
from beets.util.color import colorize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Library
|
||||
|
||||
ImportAction = Literal["abort", "skip", "continue"]
|
||||
|
||||
@@ -249,7 +252,9 @@ class BadFiles(BeetsPlugin):
|
||||
raise Exception(f"Unexpected selection: {sel}")
|
||||
return None
|
||||
|
||||
def command(self, lib, opts, args):
|
||||
def command(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
# Get items from arguments
|
||||
items = lib.items(args)
|
||||
self.verbose = opts.verbose
|
||||
|
||||
+12
-1
@@ -4,6 +4,10 @@
|
||||
|
||||
"""Provides a bare-ASCII matching query."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from unidecode import unidecode
|
||||
|
||||
from beets import ui
|
||||
@@ -11,6 +15,11 @@ from beets.dbcore.query import StringFieldQuery
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.ui import print_
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
class BareascQuery(StringFieldQuery[str]):
|
||||
"""Compare items using bare ASCII, without accents etc."""
|
||||
@@ -63,7 +72,9 @@ class BareascPlugin(BeetsPlugin):
|
||||
cmd.func = self.unidecode_list
|
||||
return [cmd]
|
||||
|
||||
def unidecode_list(self, lib, opts, args):
|
||||
def unidecode_list(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
"""Emulate normal 'list' command but with unidecode output."""
|
||||
album = opts.album
|
||||
# Copied from commands.py - list_items
|
||||
|
||||
@@ -27,7 +27,10 @@ from beets.util import as_string
|
||||
from beetsplug._utils import vfs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.dbcore.query import Query
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
try:
|
||||
@@ -1621,7 +1624,7 @@ class BPDPlugin(BeetsPlugin):
|
||||
"bpd", help="run an MPD-compatible music player server"
|
||||
)
|
||||
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
host = self.config["host"].as_str()
|
||||
host = args.pop(0) if args else host
|
||||
port = args.pop(0) if args else self.config["port"].get(int)
|
||||
|
||||
+11
-1
@@ -1,10 +1,18 @@
|
||||
"""Determine BPM by pressing a key to the rhythm."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import ui
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
def bpm(max_strokes):
|
||||
"""Returns average BPM (possibly of a playing song)
|
||||
@@ -42,7 +50,9 @@ class BPMPlugin(BeetsPlugin):
|
||||
cmd.func = self.command
|
||||
return [cmd]
|
||||
|
||||
def command(self, lib, opts, args):
|
||||
def command(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
write = ui.should_write()
|
||||
self.get_bpm(lib.items(args), write)
|
||||
|
||||
|
||||
+12
-1
@@ -1,5 +1,9 @@
|
||||
"""Update library's tags using Beatport."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import library, ui, util
|
||||
from beets.autotag import AlbumMatch, Distance, TrackMatch
|
||||
from beets.plugins import BeetsPlugin, apply_item_changes
|
||||
@@ -7,6 +11,11 @@ from beets.util.deprecation import deprecate_for_user
|
||||
|
||||
from .beatport import BeatportPlugin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
class BPSyncPlugin(BeetsPlugin):
|
||||
def __init__(self):
|
||||
@@ -49,7 +58,9 @@ class BPSyncPlugin(BeetsPlugin):
|
||||
cmd.func = self.func
|
||||
return [cmd]
|
||||
|
||||
def func(self, lib, opts, args):
|
||||
def func(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
"""Command handler for the bpsync function."""
|
||||
move = ui.should_move(opts.move)
|
||||
pretend = opts.pretend
|
||||
|
||||
+11
-3
@@ -20,10 +20,12 @@ from beets.metadata_plugins import MetadataSourcePlugin, get_metadata_source
|
||||
from beets.util.color import colorize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
from collections.abc import Iterable, Iterator
|
||||
|
||||
from beets.autotag import TrackInfo
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Library
|
||||
from beets.library.models import Item
|
||||
from beetsplug.musicbrainz import MusicBrainzPlugin
|
||||
|
||||
@@ -258,7 +260,9 @@ class AcoustidPlugin(MetadataSourcePlugin):
|
||||
"submit", help="submit Acoustid fingerprints"
|
||||
)
|
||||
|
||||
def submit_cmd_func(lib, opts, args):
|
||||
def submit_cmd_func(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
try:
|
||||
apikey = config["acoustid"]["apikey"].as_str()
|
||||
except confuse.NotFoundError:
|
||||
@@ -271,7 +275,9 @@ class AcoustidPlugin(MetadataSourcePlugin):
|
||||
"fingerprint", help="generate fingerprints for items without them"
|
||||
)
|
||||
|
||||
def fingerprint_cmd_func(lib, opts, args):
|
||||
def fingerprint_cmd_func(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
for item in lib.items(args):
|
||||
fingerprint_item(self._log, item, write=ui.should_write())
|
||||
|
||||
@@ -315,7 +321,9 @@ class AcoustidPlugin(MetadataSourcePlugin):
|
||||
help="Write computed fingerprints to files",
|
||||
)
|
||||
|
||||
def search_cmd_func(lib, opts, args):
|
||||
def search_cmd_func(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
if not opts.search:
|
||||
raise UserError("no --search provided")
|
||||
if opts.count <= 0:
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ from beets.metadata_plugins import IDResponse, SearchApiMetadataSourcePlugin
|
||||
VARIOUS_ARTISTS_ID = 5080
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
from collections.abc import Sequence
|
||||
|
||||
from beets.library import Item, Library
|
||||
@@ -46,7 +47,7 @@ class DeezerPlugin(SearchApiMetadataSourcePlugin[IDResponse]):
|
||||
"deezerupdate", help=f"Update {self.data_source} rank"
|
||||
)
|
||||
|
||||
def func(lib: Library, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
items = lib.items(args)
|
||||
self.deezerupdate(list(items), ui.should_write())
|
||||
|
||||
|
||||
+10
-1
@@ -1,7 +1,10 @@
|
||||
"""List duplicate tracks or albums."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shlex
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets.library import Album, Item
|
||||
from beets.plugins import BeetsPlugin
|
||||
@@ -14,6 +17,12 @@ from beets.util import (
|
||||
subprocess,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
PLUGIN = "duplicates"
|
||||
|
||||
|
||||
@@ -128,7 +137,7 @@ class DuplicatesPlugin(BeetsPlugin):
|
||||
self._command.parser.add_all_common_options()
|
||||
|
||||
def commands(self):
|
||||
def _dup(lib, opts, args):
|
||||
def _dup(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
self.config.set_args(opts)
|
||||
album = self.config["album"].get(bool)
|
||||
checksum = self.config["checksum"].get(str)
|
||||
|
||||
+6
-1
@@ -21,7 +21,10 @@ from beets.ui.commands.utils import do_query
|
||||
from beets.util import PromptChoice
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Library
|
||||
|
||||
# These "safe" types can avoid the format/parse cycle that most fields go
|
||||
# through: they are safe to edit with native YAML types.
|
||||
@@ -174,7 +177,9 @@ class EditPlugin(plugins.BeetsPlugin):
|
||||
edit_command.func = self._edit_command
|
||||
return [edit_command]
|
||||
|
||||
def _edit_command(self, lib, opts, args):
|
||||
def _edit_command(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
"""The CLI command function for the `beet edit` command."""
|
||||
# Get the objects to edit.
|
||||
items, albums = do_query(lib, args, opts.album, False)
|
||||
|
||||
+9
-1
@@ -1,10 +1,13 @@
|
||||
"""Exports data from beets"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import codecs
|
||||
import csv
|
||||
import json
|
||||
import sys
|
||||
from datetime import date, datetime
|
||||
from typing import TYPE_CHECKING
|
||||
from xml.etree import ElementTree
|
||||
|
||||
import mediafile
|
||||
@@ -13,6 +16,11 @@ from beets import ui, util
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beetsplug.info import library_data, tag_data
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
class ExportEncoder(json.JSONEncoder):
|
||||
"""Deals with dates because JSON doesn't have a standard"""
|
||||
@@ -107,7 +115,7 @@ class ExportPlugin(BeetsPlugin):
|
||||
)
|
||||
return [cmd]
|
||||
|
||||
def run(self, lib, opts, args):
|
||||
def run(self, lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
file_path = opts.output
|
||||
file_mode = "a" if opts.append else "w"
|
||||
file_format = opts.format or self.config["default_format"].get(str)
|
||||
|
||||
@@ -23,6 +23,7 @@ from beets.util.color import colorize
|
||||
from beets.util.config import UnknownPairError, sanitize_pairs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
from collections.abc import Iterable, Iterator, Sequence
|
||||
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
@@ -1548,7 +1549,7 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin):
|
||||
help="quiet mode: do not output albums that already have artwork",
|
||||
)
|
||||
|
||||
def func(lib: Library, opts, args) -> None:
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
self.batch_fetch_art(lib, lib.albums(args), opts.force, opts.quiet)
|
||||
|
||||
cmd.func = func
|
||||
|
||||
+10
-1
@@ -7,13 +7,22 @@ by default but can be added via the `-e` / `--extravalues` flag. For example:
|
||||
`beet fish -e genres -e albumartist`
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from operator import attrgetter
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import library, plugins, ui
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.ui import commands
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
BL_NEED2 = """complete -c beet -n '__fish_beet_needs_command' {} {}\n"""
|
||||
BL_USE3 = """complete -c beet -n '__fish_beet_using_command {}' {} {}\n"""
|
||||
BL_SUBS = """complete -c beet -n '__fish_at_level {} ""' {} {}\n"""
|
||||
@@ -80,7 +89,7 @@ class FishPlugin(BeetsPlugin):
|
||||
)
|
||||
return [cmd]
|
||||
|
||||
def run(self, lib, opts, args):
|
||||
def run(self, lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
# Gather the commands from Beets core and its plugins.
|
||||
# Collect the album and track fields.
|
||||
# If specified, also collect the values for these fields.
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
"""Creates freedesktop.org-compliant .directory files on an album level."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import ui
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
class FreedesktopPlugin(BeetsPlugin):
|
||||
def commands(self):
|
||||
@@ -13,7 +22,9 @@ class FreedesktopPlugin(BeetsPlugin):
|
||||
deprecated.func = self.deprecation_message
|
||||
return [deprecated]
|
||||
|
||||
def deprecation_message(self, lib, opts, args):
|
||||
def deprecation_message(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
ui.print_(
|
||||
"This plugin is deprecated. Its functionality is "
|
||||
"superseded by the 'thumbnails' plugin"
|
||||
|
||||
@@ -9,9 +9,11 @@ from typing import TYPE_CHECKING
|
||||
from beets import config, plugins, ui
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.autotag import AlbumInfo, Info, TrackInfo
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Album, Item
|
||||
from beets.library import Album, Item, Library
|
||||
|
||||
DEFAULT_BRACKET_KEYWORDS: tuple[str, ...] = (
|
||||
"abridged",
|
||||
@@ -256,7 +258,7 @@ class FtInTitlePlugin(plugins.BeetsPlugin):
|
||||
)
|
||||
|
||||
def commands(self) -> list[ui.Subcommand]:
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
self.config.set_args(opts)
|
||||
write = ui.should_write()
|
||||
|
||||
|
||||
+9
-1
@@ -1,6 +1,9 @@
|
||||
"""Shows file metadata."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import mediafile
|
||||
|
||||
@@ -9,6 +12,11 @@ from beets.library import Item
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.util import displayable_path, normpath, syspath
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
def tag_data(lib, args, album=False):
|
||||
query = []
|
||||
@@ -167,7 +175,7 @@ class InfoPlugin(BeetsPlugin):
|
||||
cmd.parser.add_format_option(target="item")
|
||||
return [cmd]
|
||||
|
||||
def run(self, lib, opts, args):
|
||||
def run(self, lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
"""Print tag info or library data for each file referenced by args.
|
||||
|
||||
Main entry point for the `beet info ARGS...` command.
|
||||
|
||||
+12
-2
@@ -1,13 +1,21 @@
|
||||
"""Adds support for ipfs. Requires go-ipfs and a running ipfs daemon"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import config, library, ui, util
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
class IPFSPlugin(BeetsPlugin):
|
||||
def __init__(self):
|
||||
@@ -54,7 +62,7 @@ class IPFSPlugin(BeetsPlugin):
|
||||
help="Play music from remote libraries",
|
||||
)
|
||||
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
if opts.add:
|
||||
for album in lib.albums(args):
|
||||
if len(album.items()) == 0:
|
||||
@@ -88,7 +96,9 @@ class IPFSPlugin(BeetsPlugin):
|
||||
if self.ipfs_add(task.album):
|
||||
task.album.store()
|
||||
|
||||
def ipfs_play(self, lib, opts, args):
|
||||
def ipfs_play(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
from beetsplug.play import PlayPlugin
|
||||
|
||||
jlib = self.get_remote_lib(lib)
|
||||
|
||||
+11
-1
@@ -1,11 +1,19 @@
|
||||
"""Uses the `KeyFinder` program to add the `initial_key` field."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os.path
|
||||
import subprocess
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import ui, util
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
class KeyFinderPlugin(BeetsPlugin):
|
||||
def __init__(self):
|
||||
@@ -22,7 +30,9 @@ class KeyFinderPlugin(BeetsPlugin):
|
||||
cmd.func = self.command
|
||||
return [cmd]
|
||||
|
||||
def command(self, lib, opts, args):
|
||||
def command(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
self.find_key(lib.items(args), write=ui.should_write())
|
||||
|
||||
def imported(self, session, task):
|
||||
|
||||
@@ -12,6 +12,10 @@ from beets.exceptions import UserError
|
||||
from ._utils.playcount import update_play_counts
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
from ._utils.playcount import Track
|
||||
|
||||
API_URL = "https://ws.audioscrobbler.com/2.0/"
|
||||
@@ -29,7 +33,7 @@ class LastImportPlugin(plugins.BeetsPlugin):
|
||||
def commands(self):
|
||||
cmd = ui.Subcommand("lastimport", help="import last.fm play-count")
|
||||
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
import_lastfm(lib, self._log)
|
||||
|
||||
cmd.func = func
|
||||
|
||||
+9
-1
@@ -7,15 +7,23 @@
|
||||
query language).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import deque
|
||||
from itertools import islice
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets.dbcore import FieldQuery
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.ui import Subcommand, print_
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
def lslimit(lib, opts, args):
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
def lslimit(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
"""Query command with head/tail."""
|
||||
|
||||
if (opts.head is not None) and (opts.tail is not None):
|
||||
|
||||
@@ -21,8 +21,11 @@ from ._utils.playcount import update_play_counts
|
||||
from ._utils.requests import TimeoutAndRetrySession
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
from pathlib import Path
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
from ._utils.playcount import Track
|
||||
|
||||
|
||||
@@ -93,7 +96,7 @@ class ListenBrainzPlugin(MusicBrainzAPIMixin, BeetsPlugin):
|
||||
),
|
||||
)
|
||||
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
self._lbupdate(
|
||||
lib, export_file=opts.export_file, max_listens=opts.max_listens
|
||||
)
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ from ._utils.requests import (
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
from collections.abc import Callable, Iterable, Iterator
|
||||
|
||||
import confuse
|
||||
@@ -1142,7 +1143,7 @@ class LyricsPlugin(LyricsRequestHandler, plugins.BeetsPlugin):
|
||||
help="do not fetch missing lyrics",
|
||||
)
|
||||
|
||||
def func(lib: Library, opts, args) -> None:
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
# The "write to files" option corresponds to the
|
||||
# import_write config value.
|
||||
self.config.set(vars(opts))
|
||||
|
||||
@@ -16,6 +16,7 @@ from ._utils.musicbrainz import MusicBrainzAPI
|
||||
from ._utils.requests import BeetsHTTPError
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
from collections.abc import Iterable, Iterator
|
||||
|
||||
from requests import Response
|
||||
@@ -182,7 +183,9 @@ class MusicBrainzCollectionPlugin(BeetsPlugin):
|
||||
mbupdate.func = self.update_collection
|
||||
return [mbupdate]
|
||||
|
||||
def update_collection(self, lib: Library, opts, args) -> None:
|
||||
def update_collection(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
self.config.set_args(opts)
|
||||
remove_missing = self.config["remove"].get(bool)
|
||||
self.update_album_list(lib, lib.albums(), remove_missing)
|
||||
|
||||
@@ -19,7 +19,10 @@ from beets.util import PromptChoice, displayable_path
|
||||
from beetsplug.info import print_data
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
class MBSubmitPlugin(BeetsPlugin):
|
||||
@@ -79,7 +82,7 @@ class MBSubmitPlugin(BeetsPlugin):
|
||||
"mbsubmit", help="Submit Tracks to MusicBrainz"
|
||||
)
|
||||
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
items = lib.items(args)
|
||||
self._mbsubmit(items)
|
||||
|
||||
|
||||
+11
-1
@@ -1,11 +1,19 @@
|
||||
"""Synchronise library metadata with metadata source backends."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import defaultdict
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import library, metadata_plugins, ui, util
|
||||
from beets.autotag import AlbumMatch, Distance, TrackMatch
|
||||
from beets.plugins import BeetsPlugin, apply_item_changes
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
class MBSyncPlugin(BeetsPlugin):
|
||||
def __init__(self):
|
||||
@@ -45,7 +53,9 @@ class MBSyncPlugin(BeetsPlugin):
|
||||
cmd.func = self.func
|
||||
return [cmd]
|
||||
|
||||
def func(self, lib, opts, args):
|
||||
def func(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
"""Command handler for the mbsync function."""
|
||||
move = ui.should_move(opts.move)
|
||||
pretend = opts.pretend
|
||||
|
||||
@@ -12,7 +12,10 @@ from beets import ui
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.dbcore import types
|
||||
from beets.library import Library
|
||||
|
||||
METASYNC_MODULE = "beetsplug.metasync"
|
||||
|
||||
@@ -84,7 +87,9 @@ class MetaSyncPlugin(BeetsPlugin):
|
||||
cmd.func = self.func
|
||||
return [cmd]
|
||||
|
||||
def func(self, lib, opts, args):
|
||||
def func(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
"""Command handler for the metasync function."""
|
||||
pretend = opts.pretend
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ from beets.ui import Subcommand, print_
|
||||
from ._utils.musicbrainz import MusicBrainzAPIMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
from collections.abc import Iterator
|
||||
|
||||
from beets.library import Library
|
||||
@@ -151,7 +152,7 @@ class MissingPlugin(MusicBrainzAPIMixin, BeetsPlugin):
|
||||
self._command.parser.add_format_option()
|
||||
|
||||
def commands(self):
|
||||
def _miss(lib, opts, args):
|
||||
def _miss(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
self.config.set_args(opts)
|
||||
albms = self.config["album"].get()
|
||||
|
||||
|
||||
+10
-2
@@ -1,6 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import time
|
||||
from typing import ClassVar
|
||||
from typing import TYPE_CHECKING, ClassVar
|
||||
|
||||
import mpd
|
||||
|
||||
@@ -10,6 +12,12 @@ from beets.dbcore.query import PathQuery
|
||||
from beets.exceptions import UserError
|
||||
from beets.util import displayable_path
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
# If we lose the connection, how many times do we want to retry and how
|
||||
# much time should we wait between retries?
|
||||
RETRIES = 10
|
||||
@@ -351,7 +359,7 @@ class MPDStatsPlugin(plugins.BeetsPlugin):
|
||||
help="set the password of the MPD server to connect to",
|
||||
)
|
||||
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
mpd_config.set_args(opts)
|
||||
|
||||
try:
|
||||
|
||||
@@ -14,6 +14,9 @@ from beets.plugins import BeetsPlugin
|
||||
from ._utils.musicbrainz import MusicBrainzAPIMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
from beetsplug._utils.musicbrainz import Work
|
||||
|
||||
|
||||
@@ -27,7 +30,7 @@ class ParentWorkPlugin(MusicBrainzAPIMixin, BeetsPlugin):
|
||||
self.import_stages = [self.imported]
|
||||
|
||||
def commands(self):
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
self.config.set_args(opts)
|
||||
force_parent = self.config["force"].get(bool)
|
||||
write = ui.should_write()
|
||||
|
||||
+6
-1
@@ -16,7 +16,10 @@ from beets.util import PromptChoice, get_temp_filename
|
||||
from beets.util.color import colorize
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
# Indicate where arguments should be inserted into the command string.
|
||||
@@ -102,7 +105,9 @@ class PlayPlugin(BeetsPlugin):
|
||||
play_command.func = self._play_command
|
||||
return [play_command]
|
||||
|
||||
def _play_command(self, lib, opts, args):
|
||||
def _play_command(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
"""The CLI command function for `beet play`. Create a list of paths
|
||||
from query, determine if tracks or albums are to be played.
|
||||
"""
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ if TYPE_CHECKING:
|
||||
from beets.library import LibModel, Library
|
||||
|
||||
|
||||
def random_func(lib: Library, opts: optparse.Values, args: list[str]):
|
||||
def random_func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
"""Select some random items or albums and print the results."""
|
||||
# Fetch all the objects matching the query into a list.
|
||||
objs = lib.albums(args) if opts.album else lib.items(args)
|
||||
|
||||
@@ -1568,7 +1568,7 @@ class ReplayGainPlugin(BeetsPlugin):
|
||||
|
||||
def command_func(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
):
|
||||
) -> None:
|
||||
try:
|
||||
write = ui.should_write(opts.write)
|
||||
force = opts.force
|
||||
|
||||
+6
-1
@@ -13,7 +13,10 @@ from beets import config, ui, util
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
_MUTAGEN_FORMATS = {
|
||||
@@ -46,7 +49,9 @@ class ScrubPlugin(BeetsPlugin):
|
||||
self.register_listener("import_task_files", self.import_task_files)
|
||||
|
||||
def commands(self):
|
||||
def scrub_func(lib, opts, args):
|
||||
def scrub_func(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
# Walk through matching files and remove tags.
|
||||
for item in lib.items(args):
|
||||
self._log.info("scrubbing: {.filepath}", item)
|
||||
|
||||
@@ -27,6 +27,7 @@ from beets.metadata_plugins import IDResponse, SearchApiMetadataSourcePlugin
|
||||
from beets.util import chunks
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
from collections.abc import Sequence
|
||||
|
||||
from beets.library import Item, Library
|
||||
@@ -530,7 +531,9 @@ class SpotifyPlugin(
|
||||
|
||||
def commands(self) -> list[ui.Subcommand]:
|
||||
# autotagger import command
|
||||
def queries(lib, opts, args):
|
||||
def queries(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
success = self._parse_opts(opts)
|
||||
if success:
|
||||
results = self._match_library_tracks(lib, args)
|
||||
@@ -570,7 +573,7 @@ class SpotifyPlugin(
|
||||
help="re-download data when already present",
|
||||
)
|
||||
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
items = lib.items(args)
|
||||
self._fetch_info(lib, items, ui.should_write(), opts.force_refetch)
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import random
|
||||
import string
|
||||
from hashlib import md5
|
||||
from typing import TYPE_CHECKING
|
||||
from urllib.parse import urlencode
|
||||
from xml.etree import ElementTree
|
||||
|
||||
@@ -11,6 +14,12 @@ from beets.dbcore.query import MatchQuery
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.ui import Subcommand
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
__author__ = "https://github.com/MrNuggelz"
|
||||
|
||||
|
||||
@@ -90,7 +99,9 @@ class SubsonicPlaylistPlugin(BeetsPlugin):
|
||||
return name, tracks
|
||||
|
||||
def commands(self):
|
||||
def build_playlist(lib, opts, args):
|
||||
def build_playlist(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
self.config.set_args(opts)
|
||||
ids = self.config["playlist_ids"].as_str_seq()
|
||||
if self.config["playlist_names"].as_str_seq():
|
||||
|
||||
@@ -23,7 +23,9 @@ from beets.util.artresizer import ArtResizer
|
||||
|
||||
BASE_DIR = os.path.join(BaseDirectory.xdg_cache_home, "thumbnails")
|
||||
if TYPE_CHECKING:
|
||||
from beets.library import Album
|
||||
import optparse
|
||||
|
||||
from beets.library import Album, Library
|
||||
|
||||
|
||||
NORMAL_DIR = bytestring_path(os.path.join(BASE_DIR, "normal"))
|
||||
@@ -62,7 +64,9 @@ class ThumbnailsPlugin(BeetsPlugin):
|
||||
|
||||
return [thumbnails_command]
|
||||
|
||||
def process_query(self, lib, opts, args):
|
||||
def process_query(
|
||||
self, lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
self.config.set_args(opts)
|
||||
if self._check_local_ok():
|
||||
for album in lib.albums(args):
|
||||
|
||||
@@ -15,9 +15,11 @@ from beets.autotag import AlbumInfo
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.autotag import Info
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Item
|
||||
from beets.library import Item, Library
|
||||
|
||||
__author__ = "henryoberholtzer@gmail.com"
|
||||
__version__ = "1.0"
|
||||
@@ -155,7 +157,7 @@ class TitlecasePlugin(BeetsPlugin):
|
||||
self.titlecase_fields(track)
|
||||
|
||||
def commands(self) -> list[ui.Subcommand]:
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
write = ui.should_write()
|
||||
for item in lib.items(args):
|
||||
self._log.info(f"titlecasing {item.title}:")
|
||||
|
||||
+12
-1
@@ -3,12 +3,21 @@ List all files in the library folder which are not listed in the
|
||||
beets library database, including art files
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from beets import util
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.ui import Subcommand, print_
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
__author__ = "https://github.com/MrNuggelz"
|
||||
|
||||
|
||||
@@ -18,7 +27,9 @@ class Unimported(BeetsPlugin):
|
||||
self.config.add({"ignore_extensions": [], "ignore_subdirectories": []})
|
||||
|
||||
def commands(self):
|
||||
def print_unimported(lib, opts, args):
|
||||
def print_unimported(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
ignore_exts = [
|
||||
f".{x}".encode()
|
||||
for x in self.config["ignore_extensions"].as_str_seq()
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
"""A Web interface to beets."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import typing as t
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import flask
|
||||
from flask import jsonify
|
||||
@@ -15,6 +18,12 @@ from beets import ui, util
|
||||
from beets.dbcore.query import PathQuery
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.library import Library
|
||||
|
||||
|
||||
# Type checking hacks
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
@@ -445,7 +454,7 @@ class WebPlugin(BeetsPlugin):
|
||||
help="debug mode",
|
||||
)
|
||||
|
||||
def func(lib, opts, args):
|
||||
def func(lib: Library, opts: optparse.Values, args: list[str]) -> None:
|
||||
args = args
|
||||
if args:
|
||||
self.config["host"] = args.pop(0)
|
||||
|
||||
+6
-2
@@ -13,8 +13,10 @@ from beets.plugins import BeetsPlugin
|
||||
from beets.ui import Subcommand, input_yn
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import optparse
|
||||
|
||||
from beets.importer import ImportSession, ImportTask
|
||||
from beets.library import Item
|
||||
from beets.library import Item, Library
|
||||
|
||||
|
||||
__author__ = "baobab@heresiarch.info"
|
||||
@@ -78,7 +80,9 @@ class ZeroPlugin(BeetsPlugin):
|
||||
def commands(self):
|
||||
zero_command = Subcommand("zero", help="set fields to null")
|
||||
|
||||
def zero_fields(lib, opts, args):
|
||||
def zero_fields(
|
||||
lib: Library, opts: optparse.Values, args: list[str]
|
||||
) -> None:
|
||||
if not args and not input_yn(
|
||||
"Remove fields for all items? (Y/n)", True
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user