Update beets to 1.4.7

Also updates:
- colorama-0.4.1
- jellyfish-0.6.1
- munkres-1.0.12
- musicbrainzngs-0.6
- mutagen-1.41.1
- pyyaml-3.13
- six-1.12.0
- unidecode-1.0.23
This commit is contained in:
Labrys of Knossos 2018-12-15 00:52:11 -05:00
commit e854005ae1
193 changed files with 15896 additions and 6384 deletions

View file

@ -24,26 +24,12 @@ import os
import re
from beets.plugins import BeetsPlugin
from beets.util import mkdirall, normpath, syspath, bytestring_path
from beets.util import mkdirall, normpath, syspath, bytestring_path, link
from beets import config
M3U_DEFAULT_NAME = 'imported.m3u'
def _get_feeds_dir(lib):
"""Given a Library object, return the path to the feeds directory to be
used (either in the library directory or an explicitly configured
path). Ensures that the directory exists.
"""
# Inside library directory.
dirpath = lib.directory
# Ensure directory exists.
if not os.path.exists(syspath(dirpath)):
os.makedirs(syspath(dirpath))
return dirpath
def _build_m3u_filename(basename):
"""Builds unique m3u filename by appending given basename to current
date."""
@ -61,7 +47,7 @@ def _write_m3u(m3u_path, items_paths):
"""Append relative paths to items into m3u file.
"""
mkdirall(m3u_path)
with open(syspath(m3u_path), 'a') as f:
with open(syspath(m3u_path), 'ab') as f:
for path in items_paths:
f.write(path + b'\n')
@ -78,30 +64,28 @@ class ImportFeedsPlugin(BeetsPlugin):
'absolute_path': False,
})
feeds_dir = self.config['dir'].get()
if feeds_dir:
feeds_dir = os.path.expanduser(bytestring_path(feeds_dir))
self.config['dir'] = feeds_dir
if not os.path.exists(syspath(feeds_dir)):
os.makedirs(syspath(feeds_dir))
relative_to = self.config['relative_to'].get()
if relative_to:
self.config['relative_to'] = normpath(relative_to)
else:
self.config['relative_to'] = feeds_dir
self.config['relative_to'] = self.get_feeds_dir()
self.register_listener('library_opened', self.library_opened)
self.register_listener('album_imported', self.album_imported)
self.register_listener('item_imported', self.item_imported)
def get_feeds_dir(self):
feeds_dir = self.config['dir'].get()
if feeds_dir:
return os.path.expanduser(bytestring_path(feeds_dir))
return config['directory'].as_filename()
def _record_items(self, lib, basename, items):
"""Records relative paths to the given items for each feed format
"""
feedsdir = bytestring_path(self.config['dir'].as_filename())
feedsdir = bytestring_path(self.get_feeds_dir())
formats = self.config['formats'].as_str_seq()
relative_to = self.config['relative_to'].get() \
or self.config['dir'].as_filename()
or self.get_feeds_dir()
relative_to = bytestring_path(relative_to)
paths = []
@ -119,7 +103,7 @@ class ImportFeedsPlugin(BeetsPlugin):
if 'm3u' in formats:
m3u_basename = bytestring_path(
self.config['m3u_name'].get(unicode))
self.config['m3u_name'].as_str())
m3u_path = os.path.join(feedsdir, m3u_basename)
_write_m3u(m3u_path, paths)
@ -131,17 +115,13 @@ class ImportFeedsPlugin(BeetsPlugin):
for path in paths:
dest = os.path.join(feedsdir, os.path.basename(path))
if not os.path.exists(syspath(dest)):
os.symlink(syspath(path), syspath(dest))
link(path, dest)
if 'echo' in formats:
self._log.info(u"Location of imported music:")
for path in paths:
self._log.info(u" {0}", path)
def library_opened(self, lib):
if self.config['dir'].get() is None:
self.config['dir'] = _get_feeds_dir(lib)
def album_imported(self, lib, album):
self._record_items(lib, album.album, album.items())