mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-06 16:44:06 +00:00
Revert "Merge branch 'image-class'"
This reverts commit6c72905c51, reversing changes made to005e591d80.
This commit is contained in:
@@ -26,7 +26,7 @@ import re
|
||||
import traceback
|
||||
from functools import partial
|
||||
from picard import config, log
|
||||
from picard.metadata import Image, is_front_image
|
||||
from picard.metadata import is_front_image
|
||||
from picard.util import mimetype, parse_amazon_url
|
||||
from picard.const import CAA_HOST, CAA_PORT
|
||||
from PyQt4.QtCore import QUrl, QObject
|
||||
@@ -101,21 +101,9 @@ def _coverart_downloaded(album, metadata, release, try_list, coverinfos, data, h
|
||||
filename = None
|
||||
if not is_front_image(coverinfos) and config.setting["caa_image_type_as_filename"]:
|
||||
filename = coverinfos['type']
|
||||
|
||||
try:
|
||||
metadata.make_and_add_image(mime, data,
|
||||
imagetype=coverinfos['type'],
|
||||
comment=coverinfos['desc'])
|
||||
for track in album._new_tracks:
|
||||
track.metadata.make_and_add_image(mime, data,
|
||||
imagetype=coverinfos['type'],
|
||||
comment=coverinfos['desc'])
|
||||
except (IOError, OSError), e:
|
||||
album.error_append(e.message)
|
||||
album._finalize_loading(error=True)
|
||||
# It doesn't make sense to store/download more images if we can't
|
||||
# save them in the temporary folder, abort.
|
||||
return
|
||||
metadata.add_image(mime, data, filename, coverinfos)
|
||||
for track in album._new_tracks:
|
||||
track.metadata.add_image(mime, data, filename, coverinfos)
|
||||
|
||||
# If the image already was a front image, there might still be some
|
||||
# other front images in the try_list - remove them.
|
||||
|
||||
@@ -314,13 +314,60 @@ class File(QtCore.QObject, Item):
|
||||
shutil.move(encode_filename(old_filename), encode_filename(new_filename))
|
||||
return new_filename
|
||||
|
||||
def _make_image_filename(self, image_filename, dirname, metadata):
|
||||
image_filename = self._script_to_filename(image_filename, metadata)
|
||||
if not image_filename:
|
||||
image_filename = "cover"
|
||||
if os.path.isabs(image_filename):
|
||||
filename = image_filename
|
||||
else:
|
||||
filename = os.path.join(dirname, image_filename)
|
||||
if config.setting['windows_compatibility'] or sys.platform == 'win32':
|
||||
filename = filename.replace('./', '_/').replace('.\\', '_\\')
|
||||
return encode_filename(filename)
|
||||
|
||||
def _save_images(self, dirname, metadata):
|
||||
"""Save the cover images to disk."""
|
||||
if not metadata.images:
|
||||
return
|
||||
default_filename = self._make_image_filename(
|
||||
config.setting["cover_image_filename"], dirname, metadata)
|
||||
overwrite = config.setting["save_images_overwrite"]
|
||||
counters = defaultdict(lambda: 0)
|
||||
for image in metadata.images:
|
||||
image.save(dirname, metadata, counters)
|
||||
filename = image["filename"]
|
||||
data = image["data"]
|
||||
mime = image["mime"]
|
||||
if filename is None:
|
||||
filename = default_filename
|
||||
else:
|
||||
filename = self._make_image_filename(filename, dirname, metadata)
|
||||
image_filename = filename
|
||||
ext = mimetype.get_extension(mime, ".jpg")
|
||||
if counters[filename] > 0:
|
||||
image_filename = "%s (%d)" % (filename, counters[filename])
|
||||
counters[filename] = counters[filename] + 1
|
||||
while os.path.exists(image_filename + ext) and not overwrite:
|
||||
if os.path.getsize(image_filename + ext) == len(data):
|
||||
log.debug("Identical file size, not saving %r", image_filename)
|
||||
break
|
||||
image_filename = "%s (%d)" % (filename, counters[filename])
|
||||
counters[filename] = counters[filename] + 1
|
||||
else:
|
||||
new_filename = image_filename + ext
|
||||
# Even if overwrite is enabled we don't need to write the same
|
||||
# image multiple times
|
||||
if (os.path.exists(new_filename) and
|
||||
os.path.getsize(new_filename) == len(data)):
|
||||
log.debug("Identical file size, not saving %r", image_filename)
|
||||
continue
|
||||
log.debug("Saving cover images to %r", image_filename)
|
||||
new_dirname = os.path.dirname(image_filename)
|
||||
if not os.path.isdir(new_dirname):
|
||||
os.makedirs(new_dirname)
|
||||
f = open(image_filename + ext, "wb")
|
||||
f.write(data)
|
||||
f.close()
|
||||
|
||||
def _move_additional_files(self, old_filename, new_filename):
|
||||
"""Move extra files, like playlists..."""
|
||||
|
||||
@@ -63,7 +63,7 @@ class APEv2File(File):
|
||||
if '\0' in values.value:
|
||||
descr, data = values.value.split('\0', 1)
|
||||
mime = mimetype.get_from_data(data, descr, 'image/jpeg')
|
||||
metadata.make_and_add_image(mime, data)
|
||||
metadata.add_image(mime, data)
|
||||
# skip EXTERNAL and BINARY values
|
||||
if values.kind != mutagen.apev2.TEXT:
|
||||
continue
|
||||
@@ -150,8 +150,8 @@ class APEv2File(File):
|
||||
if not save_this_image_to_tags(image):
|
||||
continue
|
||||
cover_filename = 'Cover Art (Front)'
|
||||
cover_filename += mimetype.get_extension(image.mimetype, '.jpg')
|
||||
tags['Cover Art (Front)'] = mutagen.apev2.APEValue(cover_filename + '\0' + image.data, mutagen.apev2.BINARY)
|
||||
cover_filename += mimetype.get_extension(image["mime"], '.jpg')
|
||||
tags['Cover Art (Front)'] = mutagen.apev2.APEValue(cover_filename + '\0' + image["data"], mutagen.apev2.BINARY)
|
||||
break # can't save more than one item with the same name
|
||||
# (mp3tags does this, but it's against the specs)
|
||||
tags.save(encode_filename(filename))
|
||||
|
||||
@@ -140,8 +140,11 @@ class ASFFile(File):
|
||||
if name == 'WM/Picture':
|
||||
for image in values:
|
||||
(mime, data, type, description) = unpack_image(image.value)
|
||||
metadata.make_and_add_image(mime, data, comment=description,
|
||||
imagetype=image_type_from_id3_num(type))
|
||||
extras = {
|
||||
'desc': description,
|
||||
'type': image_type_from_id3_num(type)
|
||||
}
|
||||
metadata.add_image(mime, data, extras=extras)
|
||||
continue
|
||||
elif name not in self.__RTRANS:
|
||||
continue
|
||||
@@ -166,9 +169,9 @@ class ASFFile(File):
|
||||
for image in metadata.images:
|
||||
if not save_this_image_to_tags(image):
|
||||
continue
|
||||
tag_data = pack_image(image.mimetype, image.data,
|
||||
image_type_as_id3_num(image.imagetype),
|
||||
image.description)
|
||||
tag_data = pack_image(image["mime"], image["data"],
|
||||
image_type_as_id3_num(image['type']),
|
||||
image['desc'])
|
||||
cover.append(ASFByteArrayAttribute(tag_data))
|
||||
if cover:
|
||||
file.tags['WM/Picture'] = cover
|
||||
|
||||
@@ -249,8 +249,11 @@ class ID3File(File):
|
||||
else:
|
||||
metadata['discnumber'] = value[0]
|
||||
elif frameid == 'APIC':
|
||||
metadata.make_and_add_image(frame.mime, frame.data, comment=frame.desc,
|
||||
imagetype=image_type_from_id3_num(frame.type))
|
||||
extras = {
|
||||
'desc': frame.desc,
|
||||
'type': image_type_from_id3_num(frame.type)
|
||||
}
|
||||
metadata.add_image(frame.mime, frame.data, extras=extras)
|
||||
elif frameid == 'POPM':
|
||||
# Rating in ID3 ranges from 0 to 255, normalize this to the range 0 to 5
|
||||
if frame.email == config.setting['rating_user_email']:
|
||||
@@ -305,7 +308,7 @@ class ID3File(File):
|
||||
# any description.
|
||||
counters = defaultdict(lambda: 0)
|
||||
for image in metadata.images:
|
||||
desc = desctag = image.description
|
||||
desc = desctag = image['desc']
|
||||
if not save_this_image_to_tags(image):
|
||||
continue
|
||||
if counters[desc] > 0:
|
||||
@@ -315,10 +318,10 @@ class ID3File(File):
|
||||
desctag = "(%i)" % counters[desc]
|
||||
counters[desc] += 1
|
||||
tags.add(id3.APIC(encoding=0,
|
||||
mime=image.mimetype,
|
||||
type=image_type_as_id3_num(image.imagetype),
|
||||
mime=image["mime"],
|
||||
type=image_type_as_id3_num(image['type']),
|
||||
desc=desctag,
|
||||
data=image.data))
|
||||
data=image["data"]))
|
||||
|
||||
tmcl = mutagen.id3.TMCL(encoding=encoding, people=[])
|
||||
tipl = mutagen.id3.TIPL(encoding=encoding, people=[])
|
||||
|
||||
@@ -141,9 +141,9 @@ class MP4File(File):
|
||||
elif name == "covr":
|
||||
for value in values:
|
||||
if value.imageformat == value.FORMAT_JPEG:
|
||||
metadata.make_and_add_image("image/jpeg", value)
|
||||
metadata.add_image("image/jpeg", value)
|
||||
elif value.imageformat == value.FORMAT_PNG:
|
||||
metadata.make_and_add_image("image/png", value)
|
||||
metadata.add_image("image/png", value)
|
||||
|
||||
self._info(metadata, file)
|
||||
return metadata
|
||||
@@ -194,11 +194,11 @@ class MP4File(File):
|
||||
for image in metadata.images:
|
||||
if not save_this_image_to_tags(image):
|
||||
continue
|
||||
mime = image.mimetype
|
||||
mime = image["mime"]
|
||||
if mime == "image/jpeg":
|
||||
covr.append(MP4Cover(image.data, MP4Cover.FORMAT_JPEG))
|
||||
covr.append(MP4Cover(image["data"], MP4Cover.FORMAT_JPEG))
|
||||
elif mime == "image/png":
|
||||
covr.append(MP4Cover(image.data, MP4Cover.FORMAT_PNG))
|
||||
covr.append(MP4Cover(image["data"], MP4Cover.FORMAT_PNG))
|
||||
if covr:
|
||||
file.tags["covr"] = covr
|
||||
|
||||
|
||||
@@ -96,22 +96,27 @@ class VCommentFile(File):
|
||||
name = "totaldiscs"
|
||||
elif name == "metadata_block_picture":
|
||||
image = mutagen.flac.Picture(base64.standard_b64decode(value))
|
||||
metadata.make_and_add_image(image.mime, image.data,
|
||||
comment=image.desc,
|
||||
imagetype=image_type_from_id3_num(image.type))
|
||||
extras = {
|
||||
'desc': image.desc,
|
||||
'type': image_type_from_id3_num(image.type)
|
||||
}
|
||||
metadata.add_image(image.mime, image.data, extras=extras)
|
||||
continue
|
||||
elif name in self.__translate:
|
||||
name = self.__translate[name]
|
||||
metadata.add(name, value)
|
||||
if self._File == mutagen.flac.FLAC:
|
||||
for image in file.pictures:
|
||||
metadata.make_and_add_image(image.mime, image.data, comment=image.desc,
|
||||
imagetype=image_type_from_id3_num(image.type))
|
||||
extras = {
|
||||
'desc': image.desc,
|
||||
'type': image_type_from_id3_num(image.type)
|
||||
}
|
||||
metadata.add_image(image.mime, image.data, extras=extras)
|
||||
# Read the unofficial COVERART tags, for backward compatibillity only
|
||||
if not "metadata_block_picture" in file.tags:
|
||||
try:
|
||||
for index, data in enumerate(file["COVERART"]):
|
||||
metadata.make_and_add_image(file["COVERARTMIME"][index],
|
||||
metadata.add_image(file["COVERARTMIME"][index],
|
||||
base64.standard_b64decode(data)
|
||||
)
|
||||
except KeyError:
|
||||
@@ -170,10 +175,10 @@ class VCommentFile(File):
|
||||
if not save_this_image_to_tags(image):
|
||||
continue
|
||||
picture = mutagen.flac.Picture()
|
||||
picture.data = image.data
|
||||
picture.mime = image.mimetype
|
||||
picture.desc = image.description
|
||||
picture.type = image_type_as_id3_num(image.imagetype)
|
||||
picture.data = image["data"]
|
||||
picture.mime = image["mime"]
|
||||
picture.desc = image['desc']
|
||||
picture.type = image_type_as_id3_num(image['type'])
|
||||
if self._File == mutagen.flac.FLAC:
|
||||
file.add_picture(picture)
|
||||
else:
|
||||
|
||||
@@ -15,29 +15,13 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
# USA.
|
||||
import os.path
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import traceback
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
from hashlib import md5
|
||||
from os import fdopen, unlink
|
||||
from PyQt4.QtCore import QObject
|
||||
from picard import config, log
|
||||
from picard import config
|
||||
from picard.plugin import ExtensionPoint
|
||||
from picard.similarity import similarity2
|
||||
from picard.util import (
|
||||
encode_filename,
|
||||
load_release_type_scores,
|
||||
mimetype as mime,
|
||||
replace_non_ascii,
|
||||
replace_win32_incompat,
|
||||
unaccent,
|
||||
)
|
||||
from picard.util import load_release_type_scores
|
||||
from picard.mbxml import artist_credit_from_node
|
||||
|
||||
MULTI_VALUED_JOINER = '; '
|
||||
@@ -55,99 +39,9 @@ def is_front_image(image):
|
||||
def save_this_image_to_tags(image):
|
||||
if not config.setting["save_only_front_images_to_tags"]:
|
||||
return True
|
||||
return image.is_front_image
|
||||
|
||||
|
||||
class Image(object):
|
||||
"""Wrapper around images. Instantiating an object of this class can raise
|
||||
an IOError or OSError due to the usage of tempfiles underneath.
|
||||
"""
|
||||
|
||||
def __init__(self, data, mimetype="image/jpeg", imagetype="front",
|
||||
comment=""):
|
||||
self.description = comment
|
||||
(fd, self._filename) = tempfile.mkstemp(prefix="picard")
|
||||
with fdopen(fd, "wb") as imagefile:
|
||||
imagefile.write(data)
|
||||
self.datalength = len(data)
|
||||
self.imagetype = imagetype
|
||||
self.is_front_image = imagetype == "front"
|
||||
self.mimetype = mimetype
|
||||
self.extension = mime.get_extension(mime, ".jpg")
|
||||
|
||||
def _make_image_filename(self, filename, dirname, metadata):
|
||||
if config.setting["ascii_filenames"]:
|
||||
if isinstance(filename, unicode):
|
||||
filename = unaccent(filename)
|
||||
filename = replace_non_ascii(filename)
|
||||
if not filename:
|
||||
filename = "cover"
|
||||
if not os.path.isabs(filename):
|
||||
filename = os.path.join(dirname, filename)
|
||||
# replace incompatible characters
|
||||
if config.setting["windows_compatibility"] or sys.platform == "win32":
|
||||
filename = replace_win32_incompat(filename)
|
||||
# remove null characters
|
||||
filename = filename.replace("\x00", "")
|
||||
return encode_filename(filename)
|
||||
|
||||
def save(self, dirname, metadata, counters):
|
||||
"""Saves this image.
|
||||
|
||||
:dirname: The name of the directory that contains the audio file
|
||||
:metadata: A metadata object
|
||||
:counters: A dictionary mapping filenames to the amount of how many
|
||||
images with that filename were already saved in `dirname`.
|
||||
"""
|
||||
if config.setting["caa_image_type_as_filename"]:
|
||||
log.debug("Using image type %s", self.imagetype)
|
||||
filename = self._make_image_filename(self.imagetype, dirname, metadata)
|
||||
else:
|
||||
log.debug("Using default file name %s",
|
||||
config.setting["cover_image_filename"])
|
||||
filename = self._make_image_filename(
|
||||
config.setting["cover_image_filename"], dirname, metadata)
|
||||
|
||||
overwrite = config.setting["save_images_overwrite"]
|
||||
ext = self.extension
|
||||
image_filename = filename
|
||||
if counters[filename] > 0:
|
||||
image_filename = "%s (%d)" % (filename, counters[filename])
|
||||
counters[filename] = counters[filename] + 1
|
||||
while os.path.exists(image_filename + ext) and not overwrite:
|
||||
if os.path.getsize(image_filename + ext) == self.datalength:
|
||||
log.debug("Identical file size, not saving %r", image_filename)
|
||||
break
|
||||
image_filename = "%s (%d)" % (filename, counters[filename])
|
||||
counters[filename] = counters[filename] + 1
|
||||
else:
|
||||
new_filename = image_filename + ext
|
||||
# Even if overwrite is enabled we don't need to write the same
|
||||
# image multiple times
|
||||
if (os.path.exists(new_filename) and
|
||||
os.path.getsize(new_filename) == self.datalength):
|
||||
log.debug("Identical file size, not saving %r", image_filename)
|
||||
return
|
||||
log.debug("Saving cover images to %r", image_filename)
|
||||
new_dirname = os.path.dirname(image_filename)
|
||||
if not os.path.isdir(new_dirname):
|
||||
os.makedirs(new_dirname)
|
||||
shutil.copyfile(self._filename, image_filename)
|
||||
|
||||
@property
|
||||
def data(self):
|
||||
"""Reads the data from the temporary file created for this image. May
|
||||
raise IOErrors or OSErrors.
|
||||
"""
|
||||
with open(self._filename, "rb") as imagefile:
|
||||
return imagefile.read()
|
||||
|
||||
def _delete(self):
|
||||
log.debug("Unlinking %s", self._filename)
|
||||
try:
|
||||
unlink(self._filename)
|
||||
except OSError, e:
|
||||
log.error(traceback.format_exc())
|
||||
if is_front_image(image):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class Metadata(dict):
|
||||
@@ -167,27 +61,26 @@ class Metadata(dict):
|
||||
self.images = []
|
||||
self.length = 0
|
||||
|
||||
def make_and_add_image(self, mime, data, filename=None, comment="",
|
||||
imagetype="front"):
|
||||
"""Build a new image object from ``data`` and adds it to this Metadata
|
||||
object. If an image with the same MD5 hash has already been added to
|
||||
any Metadata object, that file will be reused.
|
||||
def add_image(self, mime, data, filename=None, extras=None):
|
||||
"""Adds the image ``data`` to this Metadata object.
|
||||
|
||||
Arguments:
|
||||
mime -- The mimetype of the image
|
||||
data -- The image data
|
||||
filename -- The image filename, without an extension
|
||||
comment -- image description or comment, default to ''
|
||||
imagetype -- main type as a string, default to 'front'
|
||||
extras -- extra informations about image as dict
|
||||
'desc' : image description or comment, default to ''
|
||||
'type' : main type as a string, default to 'front'
|
||||
'front': if set, CAA front flag is true for this image
|
||||
"""
|
||||
m = md5()
|
||||
m.update(data)
|
||||
datahash = m.hexdigest()
|
||||
image = QObject.tagger.images[datahash]
|
||||
if image is None:
|
||||
image = Image(data, mime, imagetype, comment)
|
||||
QObject.tagger.images[datahash] = image
|
||||
self.images.append(image)
|
||||
imagedict = {'mime': mime,
|
||||
'data': data,
|
||||
'filename': filename,
|
||||
'type': 'front',
|
||||
'desc': ''}
|
||||
if extras is not None:
|
||||
imagedict.update(extras)
|
||||
self.images.append(imagedict)
|
||||
|
||||
def remove_image(self, index):
|
||||
self.images.pop(index)
|
||||
|
||||
@@ -30,9 +30,7 @@ import os.path
|
||||
import re
|
||||
import shutil
|
||||
import signal
|
||||
import socket
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from functools import partial
|
||||
from itertools import chain
|
||||
|
||||
@@ -109,18 +107,6 @@ class Tagger(QtGui.QApplication):
|
||||
self.save_thread_pool = QtCore.QThreadPool(self)
|
||||
self.save_thread_pool.setMaxThreadCount(1)
|
||||
|
||||
if not sys.platform == "win32":
|
||||
# Set up signal handling
|
||||
self.signalfd = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM, 0)
|
||||
|
||||
self.signalnotifier = QtCore.QSocketNotifier(self.signalfd[1].fileno(),
|
||||
QtCore.QSocketNotifier.Read, self)
|
||||
self.signalnotifier.activated.connect(self.sighandler)
|
||||
|
||||
signal.signal(signal.SIGHUP, self.signal)
|
||||
signal.signal(signal.SIGINT, self.signal)
|
||||
signal.signal(signal.SIGTERM, self.signal)
|
||||
|
||||
# Setup logging
|
||||
if debug or "PICARD_DEBUG" in os.environ:
|
||||
log.log_levels = log.log_levels | log.LOG_DEBUG
|
||||
@@ -179,7 +165,6 @@ class Tagger(QtGui.QApplication):
|
||||
self.albums = {}
|
||||
self.release_groups = {}
|
||||
self.mbid_redirects = {}
|
||||
self.images = defaultdict(lambda: None)
|
||||
self.unmatched_files = UnmatchedFiles()
|
||||
self.nats = None
|
||||
self.window = MainWindow()
|
||||
@@ -220,8 +205,6 @@ class Tagger(QtGui.QApplication):
|
||||
self.nats.update()
|
||||
|
||||
def exit(self):
|
||||
log.debug("exit")
|
||||
map(lambda i: i._delete(), self.images.itervalues())
|
||||
self.stopping = True
|
||||
self._acoustid.done()
|
||||
self.thread_pool.waitForDone()
|
||||
@@ -560,16 +543,6 @@ class Tagger(QtGui.QApplication):
|
||||
def instance(cls):
|
||||
return cls.__instance
|
||||
|
||||
def signal(self, signum, frame):
|
||||
log.debug("signal %i received", signum)
|
||||
self.signalfd[0].sendall("a")
|
||||
|
||||
def sighandler(self):
|
||||
self.signalnotifier.setEnabled(False)
|
||||
self.exit()
|
||||
self.quit()
|
||||
self.signalnotifier.setEnabled(True)
|
||||
|
||||
|
||||
def help():
|
||||
print """Usage: %s [OPTIONS] [FILE] [FILE] ...
|
||||
|
||||
@@ -23,6 +23,7 @@ from picard import config, log
|
||||
from picard.album import Album
|
||||
from picard.track import Track
|
||||
from picard.file import File
|
||||
from picard.metadata import is_front_image
|
||||
from picard.util import webbrowser2, encode_filename
|
||||
|
||||
|
||||
@@ -103,7 +104,7 @@ class CoverArtBox(QtGui.QGroupBox):
|
||||
if self.data:
|
||||
if pixmap is None:
|
||||
pixmap = QtGui.QPixmap()
|
||||
pixmap.loadFromData(self.data.data)
|
||||
pixmap.loadFromData(self.data["data"])
|
||||
if not pixmap.isNull():
|
||||
offx, offy, w, h = (1, 1, 121, 121)
|
||||
cover = QtGui.QPixmap(self.shadow)
|
||||
@@ -122,7 +123,7 @@ class CoverArtBox(QtGui.QGroupBox):
|
||||
data = None
|
||||
if metadata and metadata.images:
|
||||
for image in metadata.images:
|
||||
if image.is_front_image:
|
||||
if is_front_image(image):
|
||||
data = image
|
||||
break
|
||||
else:
|
||||
@@ -184,16 +185,16 @@ class CoverArtBox(QtGui.QGroupBox):
|
||||
self.__set_data([mime, data], pixmap=pixmap)
|
||||
if isinstance(self.item, Album):
|
||||
album = self.item
|
||||
album.metadata.make_and_add_image(mime, data)
|
||||
album.metadata.add_image(mime, data)
|
||||
for track in album.tracks:
|
||||
track.metadata.make_and_add_image(mime, data)
|
||||
track.metadata.add_image(mime, data)
|
||||
for file in album.iterfiles():
|
||||
file.metadata.make_and_add_image(mime, data)
|
||||
file.metadata.add_image(mime, data)
|
||||
elif isinstance(self.item, Track):
|
||||
track = self.item
|
||||
track.metadata.make_and_add_image(mime, data)
|
||||
track.metadata.add_image(mime, data)
|
||||
for file in track.iterfiles():
|
||||
file.metadata.make_and_add_image(mime, data)
|
||||
file.metadata.add_image(mime, data)
|
||||
elif isinstance(self.item, File):
|
||||
file = self.item
|
||||
file.metadata.make_and_add_image(mime, data)
|
||||
file.metadata.add_image(mime, data)
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
import os.path
|
||||
import traceback
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from picard import log
|
||||
from picard.util import format_time, encode_filename, bytes2human
|
||||
from picard.ui.ui_infodialog import Ui_InfoDialog
|
||||
|
||||
@@ -49,11 +47,7 @@ class InfoDialog(QtGui.QDialog):
|
||||
return
|
||||
|
||||
for image in images:
|
||||
try:
|
||||
data = image.data
|
||||
except (OSError, IOError), e:
|
||||
log.error(traceback.format_exc())
|
||||
continue
|
||||
data = image["data"]
|
||||
size = len(data)
|
||||
item = QtGui.QListWidgetItem()
|
||||
pixmap = QtGui.QPixmap()
|
||||
|
||||
@@ -306,11 +306,7 @@ msgstr "Tšehhi"
|
||||
#. iso.code:XC
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:245
|
||||
msgid "Czechoslovakia"
|
||||
<<<<<<< HEAD
|
||||
msgstr "Tšehhoslovakkia"
|
||||
=======
|
||||
msgstr "Tšehhoslovakkia (ajalooline, 1918–1992)"
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:CI
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:52
|
||||
@@ -345,11 +341,7 @@ msgstr "Dominikaani Vabariik"
|
||||
#. iso.code:XG
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:244
|
||||
msgid "East Germany"
|
||||
<<<<<<< HEAD
|
||||
msgstr "Ida-Saksamaa"
|
||||
=======
|
||||
msgstr "Ida-Saksamaa (ajalooline, 1949–1990)"
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:EC
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:62
|
||||
@@ -814,11 +806,7 @@ msgstr "Holland"
|
||||
#. iso.code:AN
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:151
|
||||
msgid "Netherlands Antilles"
|
||||
<<<<<<< HEAD
|
||||
msgstr "Hollandi Antillid"
|
||||
=======
|
||||
msgstr "Hollandi Antillid (ajalooline, 1954–2010)"
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:NC
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:152
|
||||
@@ -1028,11 +1016,7 @@ msgstr "Serbia"
|
||||
#. iso.code:CS
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:242
|
||||
msgid "Serbia and Montenegro"
|
||||
<<<<<<< HEAD
|
||||
msgstr "Serbia ja Montenegro"
|
||||
=======
|
||||
msgstr "Serbia ja Montenegro (ajalooline, 2003–2006)"
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:SC
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:186
|
||||
@@ -1097,11 +1081,7 @@ msgstr "Lõuna-Sudaan"
|
||||
#. iso.code:SU
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:243
|
||||
msgid "Soviet Union"
|
||||
<<<<<<< HEAD
|
||||
msgstr "Nõukogude Liit"
|
||||
=======
|
||||
msgstr "Nõukogude Liit (ajalooline, 1922–1991)"
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:ES
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:194
|
||||
@@ -1301,11 +1281,7 @@ msgstr "Jeemen"
|
||||
#. iso.code:YU
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:235
|
||||
msgid "Yugoslavia"
|
||||
<<<<<<< HEAD
|
||||
msgstr "Jugoslaavia"
|
||||
=======
|
||||
msgstr "Jugoslaavia (ajalooline, 1918–2003)"
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:ZM
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:237
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,13 +15,8 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: MusicBrainz\n"
|
||||
<<<<<<< HEAD
|
||||
"PO-Revision-Date: 2014-02-05 13:23+0000\n"
|
||||
"Last-Translator: mry_33 <mry_33@163.com>\n"
|
||||
=======
|
||||
"PO-Revision-Date: 2014-01-12 12:58+0000\n"
|
||||
"Last-Translator: Ian McEwen <ianmcorvidae@ianmcorvidae.net>\n"
|
||||
>>>>>>> image-class
|
||||
"Language-Team: Chinese (China) (http://www.transifex.com/projects/p/musicbrainz/language/zh_CN/)\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
@@ -157,11 +152,7 @@ msgstr "不丹"
|
||||
#. iso.code:BO
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:26
|
||||
msgid "Bolivia"
|
||||
<<<<<<< HEAD
|
||||
msgstr "玻利维亚"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:BQ
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:258
|
||||
@@ -196,20 +187,12 @@ msgstr "英属印度洋领地"
|
||||
#. iso.code:VG
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:230
|
||||
msgid "British Virgin Islands"
|
||||
<<<<<<< HEAD
|
||||
msgstr "英属维京群岛"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:BN
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:32
|
||||
msgid "Brunei"
|
||||
<<<<<<< HEAD
|
||||
msgstr "文莱"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:BG
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:33
|
||||
@@ -334,11 +317,7 @@ msgstr "捷克"
|
||||
#. iso.code:XC
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:245
|
||||
msgid "Czechoslovakia"
|
||||
<<<<<<< HEAD
|
||||
msgstr "捷克斯洛伐克"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:CI
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:52
|
||||
@@ -348,11 +327,7 @@ msgstr "科特迪瓦"
|
||||
#. iso.code:CD
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:236
|
||||
msgid "Democratic Republic of the Congo"
|
||||
<<<<<<< HEAD
|
||||
msgstr "刚果民主共和国"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:DK
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:57
|
||||
@@ -377,11 +352,7 @@ msgstr "多米尼加共和国"
|
||||
#. iso.code:XG
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:244
|
||||
msgid "East Germany"
|
||||
<<<<<<< HEAD
|
||||
msgstr "东德"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:EC
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:62
|
||||
@@ -426,11 +397,7 @@ msgstr "欧洲"
|
||||
#. iso.code:FK
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:69
|
||||
msgid "Falkland Islands"
|
||||
<<<<<<< HEAD
|
||||
msgstr "福克兰群岛"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:FO
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:70
|
||||
@@ -590,11 +557,7 @@ msgstr "印度尼西亚"
|
||||
#. iso.code:IR
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:101
|
||||
msgid "Iran"
|
||||
<<<<<<< HEAD
|
||||
msgstr "伊朗"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:IQ
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:102
|
||||
@@ -659,11 +622,7 @@ msgstr "基里巴斯"
|
||||
#. iso.code:XK
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:2358
|
||||
msgid "Kosovo"
|
||||
<<<<<<< HEAD
|
||||
msgstr "科索沃"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:KW
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:114
|
||||
@@ -678,11 +637,7 @@ msgstr "吉尔吉斯坦"
|
||||
#. iso.code:LA
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:116
|
||||
msgid "Laos"
|
||||
<<<<<<< HEAD
|
||||
msgstr "老挝"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:LV
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:117
|
||||
@@ -732,11 +687,7 @@ msgstr "澳门"
|
||||
#. iso.code:MK
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:126
|
||||
msgid "Macedonia"
|
||||
<<<<<<< HEAD
|
||||
msgstr "马其顿"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:MG
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:127
|
||||
@@ -806,11 +757,7 @@ msgstr "密克罗尼西亚"
|
||||
#. iso.code:MD
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:140
|
||||
msgid "Moldova"
|
||||
<<<<<<< HEAD
|
||||
msgstr "摩尔多瓦"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:MC
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:141
|
||||
@@ -870,11 +817,7 @@ msgstr "荷兰"
|
||||
#. iso.code:AN
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:151
|
||||
msgid "Netherlands Antilles"
|
||||
<<<<<<< HEAD
|
||||
msgstr "荷属安的列斯群岛"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:NC
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:152
|
||||
@@ -914,11 +857,7 @@ msgstr "诺福克岛"
|
||||
#. iso.code:KP
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:112
|
||||
msgid "North Korea"
|
||||
<<<<<<< HEAD
|
||||
msgstr "朝鲜"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:MP
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:159
|
||||
@@ -948,11 +887,7 @@ msgstr "帕劳"
|
||||
#. iso.code:PS
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:249
|
||||
msgid "Palestine"
|
||||
<<<<<<< HEAD
|
||||
msgstr "巴勒斯坦"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:PA
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:164
|
||||
@@ -1092,11 +1027,7 @@ msgstr "塞尔维亚"
|
||||
#. iso.code:CS
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:242
|
||||
msgid "Serbia and Montenegro"
|
||||
<<<<<<< HEAD
|
||||
msgstr "塞尔维亚和黑山"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:SC
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:186
|
||||
@@ -1151,11 +1082,7 @@ msgstr "南乔治亚岛和南桑德韦奇岛"
|
||||
#. iso.code:KR
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:113
|
||||
msgid "South Korea"
|
||||
<<<<<<< HEAD
|
||||
msgstr "韩国"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:SS
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:257
|
||||
@@ -1165,11 +1092,7 @@ msgstr "南苏丹"
|
||||
#. iso.code:SU
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:243
|
||||
msgid "Soviet Union"
|
||||
<<<<<<< HEAD
|
||||
msgstr "前苏联"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:ES
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:194
|
||||
@@ -1214,11 +1137,7 @@ msgstr "瑞士"
|
||||
#. iso.code:SY
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:204
|
||||
msgid "Syria"
|
||||
<<<<<<< HEAD
|
||||
msgstr "叙利亚"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:TW
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:205
|
||||
@@ -1233,11 +1152,7 @@ msgstr "塔吉克斯坦"
|
||||
#. iso.code:TZ
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:207
|
||||
msgid "Tanzania"
|
||||
<<<<<<< HEAD
|
||||
msgstr "坦桑尼亚"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:TH
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:208
|
||||
@@ -1297,11 +1212,7 @@ msgstr "图瓦卢语"
|
||||
#. iso.code:VI
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:231
|
||||
msgid "U.S. Virgin Islands"
|
||||
<<<<<<< HEAD
|
||||
msgstr "美属维京群岛"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:UG
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:218
|
||||
@@ -1356,20 +1267,12 @@ msgstr "梵蒂冈城国 (教廷)"
|
||||
#. iso.code:VE
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:228
|
||||
msgid "Venezuela"
|
||||
<<<<<<< HEAD
|
||||
msgstr "委内瑞拉"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:VN
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:229
|
||||
msgid "Vietnam"
|
||||
<<<<<<< HEAD
|
||||
msgstr "越南"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:WF
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:232
|
||||
@@ -1389,11 +1292,7 @@ msgstr "也门"
|
||||
#. iso.code:YU
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:235
|
||||
msgid "Yugoslavia"
|
||||
<<<<<<< HEAD
|
||||
msgstr "南斯拉夫"
|
||||
=======
|
||||
msgstr ""
|
||||
>>>>>>> image-class
|
||||
|
||||
#. iso.code:ZM
|
||||
#: DBarea JOIN iso_3166_1 iso on iso.area = area.id/area.name:237
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import os.path
|
||||
import picard.formats
|
||||
import unittest
|
||||
import shutil
|
||||
|
||||
|
||||
from PyQt4 import QtCore
|
||||
from collections import defaultdict
|
||||
from tempfile import mkstemp
|
||||
from picard import config, log
|
||||
from picard.metadata import Metadata
|
||||
from tempfile import mkstemp
|
||||
import picard.formats
|
||||
from PyQt4 import QtCore
|
||||
|
||||
|
||||
settings = {
|
||||
@@ -36,7 +33,6 @@ class FakeTagger(QtCore.QObject):
|
||||
QtCore.QObject.config = config
|
||||
QtCore.QObject.log = log
|
||||
self.tagger_stats_changed.connect(self.emit)
|
||||
self.images = defaultdict(lambda: None)
|
||||
|
||||
def emit(self, *args):
|
||||
pass
|
||||
@@ -508,7 +504,6 @@ class TestCoverArt(unittest.TestCase):
|
||||
QtCore.QObject.tagger = FakeTagger()
|
||||
|
||||
def _tear_down(self):
|
||||
map(lambda i: i._delete(), QtCore.QObject.tagger.images.itervalues())
|
||||
os.unlink(self.filename)
|
||||
|
||||
def test_asf(self):
|
||||
@@ -549,13 +544,13 @@ class TestCoverArt(unittest.TestCase):
|
||||
f = picard.formats.open(self.filename)
|
||||
metadata = Metadata()
|
||||
imgdata = tests[t]['head'] + dummyload
|
||||
metadata.make_and_add_image(tests[t]['mime'], imgdata)
|
||||
metadata.add_image(tests[t]['mime'], imgdata)
|
||||
f._save(self.filename, metadata)
|
||||
|
||||
f = picard.formats.open(self.filename)
|
||||
loaded_metadata = f._load(self.filename)
|
||||
image = loaded_metadata.images[0]
|
||||
self.assertEqual(image.mimetype, tests[t]['mime'])
|
||||
self.assertEqual(image.data, imgdata)
|
||||
self.assertEqual(image["mime"], tests[t]['mime'])
|
||||
self.assertEqual(image["data"], imgdata)
|
||||
finally:
|
||||
self._tear_down()
|
||||
|
||||
Reference in New Issue
Block a user