mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 02:26:53 -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, Bruno Cauet
|
||||
#
|
||||
|
@ -19,7 +18,6 @@ This plugin is POSIX-only.
|
|||
Spec: standards.freedesktop.org/thumbnail-spec/latest/index.html
|
||||
"""
|
||||
|
||||
from __future__ import division, absolute_import, print_function
|
||||
|
||||
from hashlib import md5
|
||||
import os
|
||||
|
@ -35,7 +33,6 @@ from beets.plugins import BeetsPlugin
|
|||
from beets.ui import Subcommand, decargs
|
||||
from beets import util
|
||||
from beets.util.artresizer import ArtResizer, get_im_version, get_pil_version
|
||||
import six
|
||||
|
||||
|
||||
BASE_DIR = os.path.join(BaseDirectory.xdg_cache_home, "thumbnails")
|
||||
|
@ -45,7 +42,7 @@ LARGE_DIR = util.bytestring_path(os.path.join(BASE_DIR, "large"))
|
|||
|
||||
class ThumbnailsPlugin(BeetsPlugin):
|
||||
def __init__(self):
|
||||
super(ThumbnailsPlugin, self).__init__()
|
||||
super().__init__()
|
||||
self.config.add({
|
||||
'auto': True,
|
||||
'force': False,
|
||||
|
@ -58,15 +55,15 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
|
||||
def commands(self):
|
||||
thumbnails_command = Subcommand("thumbnails",
|
||||
help=u"Create album thumbnails")
|
||||
help="Create album thumbnails")
|
||||
thumbnails_command.parser.add_option(
|
||||
u'-f', u'--force',
|
||||
'-f', '--force',
|
||||
dest='force', action='store_true', default=False,
|
||||
help=u'force regeneration of thumbnails deemed fine (existing & '
|
||||
u'recent enough)')
|
||||
help='force regeneration of thumbnails deemed fine (existing & '
|
||||
'recent enough)')
|
||||
thumbnails_command.parser.add_option(
|
||||
u'--dolphin', dest='dolphin', action='store_true', default=False,
|
||||
help=u"create Dolphin-compatible thumbnail information (for KDE)")
|
||||
'--dolphin', dest='dolphin', action='store_true', default=False,
|
||||
help="create Dolphin-compatible thumbnail information (for KDE)")
|
||||
thumbnails_command.func = self.process_query
|
||||
|
||||
return [thumbnails_command]
|
||||
|
@ -85,8 +82,8 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
- detect whether we'll use GIO or Python to get URIs
|
||||
"""
|
||||
if not ArtResizer.shared.local:
|
||||
self._log.warning(u"No local image resizing capabilities, "
|
||||
u"cannot generate thumbnails")
|
||||
self._log.warning("No local image resizing capabilities, "
|
||||
"cannot generate thumbnails")
|
||||
return False
|
||||
|
||||
for dir in (NORMAL_DIR, LARGE_DIR):
|
||||
|
@ -100,12 +97,12 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
assert get_pil_version() # since we're local
|
||||
self.write_metadata = write_metadata_pil
|
||||
tool = "PIL"
|
||||
self._log.debug(u"using {0} to write metadata", tool)
|
||||
self._log.debug("using {0} to write metadata", tool)
|
||||
|
||||
uri_getter = GioURI()
|
||||
if not uri_getter.available:
|
||||
uri_getter = PathlibURI()
|
||||
self._log.debug(u"using {0.name} to compute URIs", uri_getter)
|
||||
self._log.debug("using {0.name} to compute URIs", uri_getter)
|
||||
self.get_uri = uri_getter.uri
|
||||
|
||||
return True
|
||||
|
@ -113,9 +110,9 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
def process_album(self, album):
|
||||
"""Produce thumbnails for the album folder.
|
||||
"""
|
||||
self._log.debug(u'generating thumbnail for {0}', album)
|
||||
self._log.debug('generating thumbnail for {0}', album)
|
||||
if not album.artpath:
|
||||
self._log.info(u'album {0} has no art', album)
|
||||
self._log.info('album {0} has no art', album)
|
||||
return
|
||||
|
||||
if self.config['dolphin']:
|
||||
|
@ -123,7 +120,7 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
|
||||
size = ArtResizer.shared.get_size(album.artpath)
|
||||
if not size:
|
||||
self._log.warning(u'problem getting the picture size for {0}',
|
||||
self._log.warning('problem getting the picture size for {0}',
|
||||
album.artpath)
|
||||
return
|
||||
|
||||
|
@ -133,9 +130,9 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
wrote &= self.make_cover_thumbnail(album, 128, NORMAL_DIR)
|
||||
|
||||
if wrote:
|
||||
self._log.info(u'wrote thumbnail for {0}', album)
|
||||
self._log.info('wrote thumbnail for {0}', album)
|
||||
else:
|
||||
self._log.info(u'nothing to do for {0}', album)
|
||||
self._log.info('nothing to do for {0}', album)
|
||||
|
||||
def make_cover_thumbnail(self, album, size, target_dir):
|
||||
"""Make a thumbnail of given size for `album` and put it in
|
||||
|
@ -146,11 +143,11 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
if os.path.exists(target) and \
|
||||
os.stat(target).st_mtime > os.stat(album.artpath).st_mtime:
|
||||
if self.config['force']:
|
||||
self._log.debug(u"found a suitable {1}x{1} thumbnail for {0}, "
|
||||
u"forcing regeneration", album, size)
|
||||
self._log.debug("found a suitable {1}x{1} thumbnail for {0}, "
|
||||
"forcing regeneration", album, size)
|
||||
else:
|
||||
self._log.debug(u"{1}x{1} thumbnail for {0} exists and is "
|
||||
u"recent enough", album, size)
|
||||
self._log.debug("{1}x{1} thumbnail for {0} exists and is "
|
||||
"recent enough", album, size)
|
||||
return False
|
||||
resized = ArtResizer.shared.resize(size, album.artpath,
|
||||
util.syspath(target))
|
||||
|
@ -160,23 +157,23 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
|
||||
def thumbnail_file_name(self, path):
|
||||
"""Compute the thumbnail file name
|
||||
See http://standards.freedesktop.org/thumbnail-spec/latest/x227.html
|
||||
See https://standards.freedesktop.org/thumbnail-spec/latest/x227.html
|
||||
"""
|
||||
uri = self.get_uri(path)
|
||||
hash = md5(uri.encode('utf-8')).hexdigest()
|
||||
return util.bytestring_path("{0}.png".format(hash))
|
||||
return util.bytestring_path(f"{hash}.png")
|
||||
|
||||
def add_tags(self, album, image_path):
|
||||
"""Write required metadata to the thumbnail
|
||||
See http://standards.freedesktop.org/thumbnail-spec/latest/x142.html
|
||||
See https://standards.freedesktop.org/thumbnail-spec/latest/x142.html
|
||||
"""
|
||||
mtime = os.stat(album.artpath).st_mtime
|
||||
metadata = {"Thumb::URI": self.get_uri(album.artpath),
|
||||
"Thumb::MTime": six.text_type(mtime)}
|
||||
"Thumb::MTime": str(mtime)}
|
||||
try:
|
||||
self.write_metadata(image_path, metadata)
|
||||
except Exception:
|
||||
self._log.exception(u"could not write metadata to {0}",
|
||||
self._log.exception("could not write metadata to {0}",
|
||||
util.displayable_path(image_path))
|
||||
|
||||
def make_dolphin_cover_thumbnail(self, album):
|
||||
|
@ -186,9 +183,9 @@ class ThumbnailsPlugin(BeetsPlugin):
|
|||
artfile = os.path.split(album.artpath)[1]
|
||||
with open(outfilename, 'w') as f:
|
||||
f.write('[Desktop Entry]\n')
|
||||
f.write('Icon=./{0}'.format(artfile.decode('utf-8')))
|
||||
f.write('Icon=./{}'.format(artfile.decode('utf-8')))
|
||||
f.close()
|
||||
self._log.debug(u"Wrote file {0}", util.displayable_path(outfilename))
|
||||
self._log.debug("Wrote file {0}", util.displayable_path(outfilename))
|
||||
|
||||
|
||||
def write_metadata_im(file, metadata):
|
||||
|
@ -211,7 +208,7 @@ def write_metadata_pil(file, metadata):
|
|||
return True
|
||||
|
||||
|
||||
class URIGetter(object):
|
||||
class URIGetter:
|
||||
available = False
|
||||
name = "Abstract base"
|
||||
|
||||
|
@ -224,7 +221,7 @@ class PathlibURI(URIGetter):
|
|||
name = "Python Pathlib"
|
||||
|
||||
def uri(self, path):
|
||||
return PurePosixPath(path).as_uri()
|
||||
return PurePosixPath(util.py3_path(path)).as_uri()
|
||||
|
||||
|
||||
def copy_c_string(c_string):
|
||||
|
@ -269,7 +266,7 @@ class GioURI(URIGetter):
|
|||
def uri(self, path):
|
||||
g_file_ptr = self.libgio.g_file_new_for_path(path)
|
||||
if not g_file_ptr:
|
||||
raise RuntimeError(u"No gfile pointer received for {0}".format(
|
||||
raise RuntimeError("No gfile pointer received for {}".format(
|
||||
util.displayable_path(path)))
|
||||
|
||||
try:
|
||||
|
@ -278,8 +275,8 @@ class GioURI(URIGetter):
|
|||
self.libgio.g_object_unref(g_file_ptr)
|
||||
if not uri_ptr:
|
||||
self.libgio.g_free(uri_ptr)
|
||||
raise RuntimeError(u"No URI received from the gfile pointer for "
|
||||
u"{0}".format(util.displayable_path(path)))
|
||||
raise RuntimeError("No URI received from the gfile pointer for "
|
||||
"{}".format(util.displayable_path(path)))
|
||||
|
||||
try:
|
||||
uri = copy_c_string(uri_ptr)
|
||||
|
@ -290,5 +287,5 @@ class GioURI(URIGetter):
|
|||
return uri.decode(util._fsencoding())
|
||||
except UnicodeDecodeError:
|
||||
raise RuntimeError(
|
||||
"Could not decode filename from GIO: {!r}".format(uri)
|
||||
f"Could not decode filename from GIO: {uri!r}"
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue