72 lines
1.9 KiB
Python
72 lines
1.9 KiB
Python
# Copyright: Copyright (c) 2020., <AUTHOR>
|
|
# Author: <AUTHOR> <EMAIL>
|
|
# License: See LICENSE.txt
|
|
|
|
from optparse import OptionParser
|
|
|
|
from beets.library import Library
|
|
from beets.ui import Subcommand
|
|
|
|
from beetsplug.beets_music_videos import common
|
|
|
|
|
|
class BeetsMusicVideoCommand(Subcommand):
|
|
config = None
|
|
lib: Library = None
|
|
query = None
|
|
parser: OptionParser = None
|
|
|
|
def __init__(self, cfg):
|
|
self.config = cfg
|
|
|
|
self.parser = OptionParser(
|
|
usage="beet {plg} [options] [QUERY...]".format(
|
|
plg=common.plg_ns["__PLUGIN_NAME__"]
|
|
)
|
|
)
|
|
|
|
self.parser.add_option(
|
|
"-v",
|
|
"--version",
|
|
action="store_true",
|
|
dest="version",
|
|
default=False,
|
|
help="show plugin version",
|
|
)
|
|
|
|
super(BeetsMusicVideoCommand, self).__init__(
|
|
parser=self.parser,
|
|
name=common.plg_ns["__PLUGIN_NAME__"],
|
|
aliases=[common.plg_ns["__PLUGIN_ALIAS__"]]
|
|
if common.plg_ns["__PLUGIN_ALIAS__"]
|
|
else [],
|
|
help=common.plg_ns["__PLUGIN_SHORT_DESCRIPTION__"],
|
|
)
|
|
|
|
def func(self, lib: Library, options, arguments):
|
|
self.lib = lib
|
|
self.query = decargs(arguments)
|
|
|
|
if options.version:
|
|
self.show_version_information()
|
|
return
|
|
|
|
self.handle_main_task()
|
|
|
|
def handle_main_task(self):
|
|
self._say("Your journey starts here...", log_only=False)
|
|
|
|
def show_version_information(self):
|
|
self._say(
|
|
"{pt}({pn}) plugin for Beets: v{ver}".format(
|
|
pt=common.plg_ns["__PACKAGE_TITLE__"],
|
|
pn=common.plg_ns["__PACKAGE_NAME__"],
|
|
ver=common.plg_ns["__version__"],
|
|
),
|
|
log_only=False,
|
|
)
|
|
|
|
@staticmethod
|
|
def _say(msg, log_only=True, is_error=False):
|
|
common.say(msg, log_only, is_error)
|