mirror of
https://github.com/fergalmoran/picard.git
synced 2026-03-01 02:54:01 +00:00
Merge pull request #455 from rahul-raturi/master
PICARD-350: Picard downloads multiple 'front' images instead of just …
This commit is contained in:
@@ -131,6 +131,7 @@ class ProviderOptionsCaa(ProviderOptions):
|
||||
"""
|
||||
|
||||
options = [
|
||||
config.BoolOption("setting", "caa_save_single_front_image", False),
|
||||
config.BoolOption("setting", "caa_approved_only", False),
|
||||
config.BoolOption("setting", "caa_image_type_as_filename", False),
|
||||
config.IntOption("setting", "caa_image_size", 1),
|
||||
@@ -147,6 +148,7 @@ class ProviderOptionsCaa(ProviderOptions):
|
||||
|
||||
def load(self):
|
||||
self.ui.cb_image_size.setCurrentIndex(config.setting["caa_image_size"])
|
||||
self.ui.cb_save_single_front_image.setChecked(config.setting["caa_save_single_front_image"])
|
||||
self.ui.cb_approved_only.setChecked(config.setting["caa_approved_only"])
|
||||
self.ui.cb_type_as_filename.setChecked(config.setting["caa_image_type_as_filename"])
|
||||
self.ui.restrict_images_types.setChecked(
|
||||
@@ -154,9 +156,11 @@ class ProviderOptionsCaa(ProviderOptions):
|
||||
self.update_caa_types()
|
||||
|
||||
def save(self):
|
||||
config.setting["caa_image_size"] =\
|
||||
config.setting["caa_image_size"] = \
|
||||
self.ui.cb_image_size.currentIndex()
|
||||
config.setting["caa_approved_only"] =\
|
||||
config.setting["caa_save_single_front_image"] = \
|
||||
self.ui.cb_save_single_front_image.isChecked()
|
||||
config.setting["caa_approved_only"] = \
|
||||
self.ui.cb_approved_only.isChecked()
|
||||
config.setting["caa_image_type_as_filename"] = \
|
||||
self.ui.cb_type_as_filename.isChecked()
|
||||
@@ -330,5 +334,9 @@ class CoverArtProviderCaa(CoverArtProvider):
|
||||
# PDFs cannot be saved to tags (as 2014/05/29)
|
||||
coverartimage.can_be_saved_to_tags = False
|
||||
self.queue_put(coverartimage)
|
||||
if config.setting["caa_save_single_front_image"] and \
|
||||
config.setting["save_images_to_files"] and \
|
||||
image["front"]:
|
||||
break
|
||||
|
||||
self.next_in_queue()
|
||||
|
||||
@@ -334,7 +334,12 @@ class File(QtCore.QObject, Item):
|
||||
if not metadata.images:
|
||||
return
|
||||
counters = defaultdict(lambda: 0)
|
||||
for image in metadata.images:
|
||||
images = []
|
||||
if config.setting["caa_save_single_front_image"]:
|
||||
images = metadata.get_single_front_image()
|
||||
if not images:
|
||||
images = metadata.images
|
||||
for image in images:
|
||||
image.save(dirname, metadata, counters)
|
||||
|
||||
def _move_additional_files(self, old_filename, new_filename):
|
||||
|
||||
@@ -59,11 +59,19 @@ class Metadata(dict):
|
||||
if config.setting["save_only_front_images_to_tags"]:
|
||||
# FIXME : rename option at some point
|
||||
# Embed only ONE front image
|
||||
for img in images:
|
||||
if img.is_front_image():
|
||||
return [img]
|
||||
front_image = self.get_single_front_image(images)
|
||||
if front_image:
|
||||
return front_image
|
||||
return images
|
||||
|
||||
def get_single_front_image(self, images=None):
|
||||
if not images:
|
||||
images = self.images
|
||||
for img in images:
|
||||
if img.is_front_image():
|
||||
return [img]
|
||||
return []
|
||||
|
||||
def remove_image(self, index):
|
||||
self.images.pop(index)
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@ class Ui_CaaOptions(object):
|
||||
self.cb_image_size.addItem(_fromUtf8(""))
|
||||
self.horizontalLayout.addWidget(self.cb_image_size)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
self.cb_save_single_front_image = QtGui.QCheckBox(CaaOptions)
|
||||
self.cb_save_single_front_image.setObjectName(_fromUtf8("cb_save_single_front_image"))
|
||||
self.verticalLayout.addWidget(self.cb_save_single_front_image)
|
||||
self.cb_approved_only = QtGui.QCheckBox(CaaOptions)
|
||||
self.cb_approved_only.setObjectName(_fromUtf8("cb_approved_only"))
|
||||
self.verticalLayout.addWidget(self.cb_approved_only)
|
||||
@@ -86,6 +89,7 @@ class Ui_CaaOptions(object):
|
||||
self.cb_image_size.setItemText(0, _("250 px"))
|
||||
self.cb_image_size.setItemText(1, _("500 px"))
|
||||
self.cb_image_size.setItemText(2, _("Full size"))
|
||||
self.cb_save_single_front_image.setText(_("Save only one front image as separate file"))
|
||||
self.cb_approved_only.setText(_("Download only approved images"))
|
||||
self.cb_type_as_filename.setText(_("Use the first image type as the filename. This will not change the filename of front images."))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user