mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 21:33:13 -07:00
Update vendored beets to 1.6.0
Updates colorama to 0.4.6 Adds confuse version 1.7.0 Updates jellyfish to 0.9.0 Adds mediafile 0.10.1 Updates munkres to 1.1.4 Updates musicbrainzngs to 0.7.1 Updates mutagen to 1.46.0 Updates pyyaml to 6.0 Updates unidecode to 1.3.6
This commit is contained in:
parent
5073ec0c6f
commit
56c6773c6b
385 changed files with 25143 additions and 18080 deletions
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of beets.
|
||||
# Copyright 2016, Thomas Scholtes.
|
||||
#
|
||||
|
@ -16,8 +15,8 @@
|
|||
"""Uses the `KeyFinder` program to add the `initial_key` field.
|
||||
"""
|
||||
|
||||
from __future__ import division, absolute_import, print_function
|
||||
|
||||
import os.path
|
||||
import subprocess
|
||||
|
||||
from beets import ui
|
||||
|
@ -28,11 +27,11 @@ from beets.plugins import BeetsPlugin
|
|||
class KeyFinderPlugin(BeetsPlugin):
|
||||
|
||||
def __init__(self):
|
||||
super(KeyFinderPlugin, self).__init__()
|
||||
super().__init__()
|
||||
self.config.add({
|
||||
u'bin': u'KeyFinder',
|
||||
u'auto': True,
|
||||
u'overwrite': False,
|
||||
'bin': 'KeyFinder',
|
||||
'auto': True,
|
||||
'overwrite': False,
|
||||
})
|
||||
|
||||
if self.config['auto'].get(bool):
|
||||
|
@ -40,7 +39,7 @@ class KeyFinderPlugin(BeetsPlugin):
|
|||
|
||||
def commands(self):
|
||||
cmd = ui.Subcommand('keyfinder',
|
||||
help=u'detect and add initial key from audio')
|
||||
help='detect and add initial key from audio')
|
||||
cmd.func = self.command
|
||||
return [cmd]
|
||||
|
||||
|
@ -52,34 +51,45 @@ class KeyFinderPlugin(BeetsPlugin):
|
|||
|
||||
def find_key(self, items, write=False):
|
||||
overwrite = self.config['overwrite'].get(bool)
|
||||
bin = self.config['bin'].as_str()
|
||||
command = [self.config['bin'].as_str()]
|
||||
# The KeyFinder GUI program needs the -f flag before the path.
|
||||
# keyfinder-cli is similar, but just wants the path with no flag.
|
||||
if 'keyfinder-cli' not in os.path.basename(command[0]).lower():
|
||||
command.append('-f')
|
||||
|
||||
for item in items:
|
||||
if item['initial_key'] and not overwrite:
|
||||
continue
|
||||
|
||||
try:
|
||||
output = util.command_output([bin, '-f',
|
||||
util.syspath(item.path)])
|
||||
output = util.command_output(command + [util.syspath(
|
||||
item.path)]).stdout
|
||||
except (subprocess.CalledProcessError, OSError) as exc:
|
||||
self._log.error(u'execution failed: {0}', exc)
|
||||
self._log.error('execution failed: {0}', exc)
|
||||
continue
|
||||
except UnicodeEncodeError:
|
||||
# Workaround for Python 2 Windows bug.
|
||||
# http://bugs.python.org/issue1759845
|
||||
self._log.error(u'execution failed for Unicode path: {0!r}',
|
||||
# https://bugs.python.org/issue1759845
|
||||
self._log.error('execution failed for Unicode path: {0!r}',
|
||||
item.path)
|
||||
continue
|
||||
|
||||
key_raw = output.rsplit(None, 1)[-1]
|
||||
try:
|
||||
key_raw = output.rsplit(None, 1)[-1]
|
||||
except IndexError:
|
||||
# Sometimes keyfinder-cli returns 0 but with no key, usually
|
||||
# when the file is silent or corrupt, so we log and skip.
|
||||
self._log.error('no key returned for path: {0}', item.path)
|
||||
continue
|
||||
|
||||
try:
|
||||
key = util.text_string(key_raw)
|
||||
except UnicodeDecodeError:
|
||||
self._log.error(u'output is invalid UTF-8')
|
||||
self._log.error('output is invalid UTF-8')
|
||||
continue
|
||||
|
||||
item['initial_key'] = key
|
||||
self._log.info(u'added computed initial key {0} for {1}',
|
||||
self._log.info('added computed initial key {0} for {1}',
|
||||
key, util.displayable_path(item.path))
|
||||
|
||||
if write:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue