mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-21 08:24:00 +01:00
update Beets
This commit is contained in:
+22
-22
@@ -15,15 +15,12 @@
|
||||
|
||||
"""Warns you about things you hate (or even blocks import)."""
|
||||
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets.importer import action
|
||||
from beets.library import parse_query_string
|
||||
from beets.library import Item
|
||||
from beets.library import Album
|
||||
from beets.library import Album, Item, parse_query_string
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
||||
|
||||
__author__ = 'baobab@heresiarch.info'
|
||||
__version__ = '2.0'
|
||||
__author__ = "baobab@heresiarch.info"
|
||||
__version__ = "2.0"
|
||||
|
||||
|
||||
def summary(task):
|
||||
@@ -31,20 +28,23 @@ def summary(task):
|
||||
object.
|
||||
"""
|
||||
if task.is_album:
|
||||
return f'{task.cur_artist} - {task.cur_album}'
|
||||
return f"{task.cur_artist} - {task.cur_album}"
|
||||
else:
|
||||
return f'{task.item.artist} - {task.item.title}'
|
||||
return f"{task.item.artist} - {task.item.title}"
|
||||
|
||||
|
||||
class IHatePlugin(BeetsPlugin):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.register_listener('import_task_choice',
|
||||
self.import_task_choice_event)
|
||||
self.config.add({
|
||||
'warn': [],
|
||||
'skip': [],
|
||||
})
|
||||
self.register_listener(
|
||||
"import_task_choice", self.import_task_choice_event
|
||||
)
|
||||
self.config.add(
|
||||
{
|
||||
"warn": [],
|
||||
"skip": [],
|
||||
}
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def do_i_hate_this(cls, task, action_patterns):
|
||||
@@ -62,19 +62,19 @@ class IHatePlugin(BeetsPlugin):
|
||||
return False
|
||||
|
||||
def import_task_choice_event(self, session, task):
|
||||
skip_queries = self.config['skip'].as_str_seq()
|
||||
warn_queries = self.config['warn'].as_str_seq()
|
||||
skip_queries = self.config["skip"].as_str_seq()
|
||||
warn_queries = self.config["warn"].as_str_seq()
|
||||
|
||||
if task.choice_flag == action.APPLY:
|
||||
if skip_queries or warn_queries:
|
||||
self._log.debug('processing your hate')
|
||||
self._log.debug("processing your hate")
|
||||
if self.do_i_hate_this(task, skip_queries):
|
||||
task.choice_flag = action.SKIP
|
||||
self._log.info('skipped: {0}', summary(task))
|
||||
self._log.info("skipped: {0}", summary(task))
|
||||
return
|
||||
if self.do_i_hate_this(task, warn_queries):
|
||||
self._log.info('you may hate this: {0}', summary(task))
|
||||
self._log.info("you may hate this: {0}", summary(task))
|
||||
else:
|
||||
self._log.debug('nothing to do')
|
||||
self._log.debug("nothing to do")
|
||||
else:
|
||||
self._log.debug('user made a decision, nothing to do')
|
||||
self._log.debug("user made a decision, nothing to do")
|
||||
|
||||
Reference in New Issue
Block a user