diff --git a/picard/formats/vorbis.py b/picard/formats/vorbis.py index a5b9ea96c..d9683acbd 100644 --- a/picard/formats/vorbis.py +++ b/picard/formats/vorbis.py @@ -247,6 +247,14 @@ class VCommentFile(File): and not config.setting["preserve_images"])): file.clear_pictures() tags = {} + if is_flac and config.setting["fix_missing_seekpoints_flac"]: + if len(file.seektable.seekpoints) == 0: + if file.info.total_samples > 0: + file.seektable.seekpoints = [mutagen.flac.SeekPoint(0,0,1)] + file.seektable.write() + else: + log.error("Unable to fix seektable of file {} because the file has no samples!".format(filename)) + for name, value in metadata.items(): if name == '~rating': # Save rating according to http://code.google.com/p/quodlibet/wiki/Specs_VorbisComments diff --git a/picard/profile.py b/picard/profile.py index 9a247fb5e..5844d948f 100644 --- a/picard/profile.py +++ b/picard/profile.py @@ -79,6 +79,7 @@ class UserProfileGroups(): SettingDesc("preserve_images", N_("Keep embedded images when clearing tags"), ["preserve_images"]), SettingDesc("remove_id3_from_flac", N_("Remove ID3 tags from FLAC files"), ["remove_id3_from_flac"]), SettingDesc("remove_ape_from_mp3", N_("Remove APEv2 tags from MP3 files"), ["remove_ape_from_mp3"]), + SettingDesc("fix_missing_seekpoints_flac", N_("Fix missing seekpoints for FLAC files"), ["fix_missing_seekpoints_flac"]), SettingDesc("preserved_tags", N_("Preserved tags list"), ["preserved_tags"]), SettingDesc("aac_save_ape", N_("Save APEv2 tags to AAC"), ["aac_save_ape", "aac_no_tags"]), SettingDesc("remove_ape_from_aac", N_("Remove APEv2 tags from AAC files"), ["remove_ape_from_aac"]), diff --git a/picard/ui/options/tags.py b/picard/ui/options/tags.py index 483b0a4c0..19f90d441 100644 --- a/picard/ui/options/tags.py +++ b/picard/ui/options/tags.py @@ -56,6 +56,7 @@ class TagsOptionsPage(OptionsPage): BoolOption("setting", "preserve_images", False), BoolOption("setting", "remove_id3_from_flac", False), BoolOption("setting", "remove_ape_from_mp3", False), + BoolOption("setting", "fix_missing_seekpoints_flac", False), ListOption("setting", "preserved_tags", []), ] @@ -72,6 +73,7 @@ class TagsOptionsPage(OptionsPage): self.ui.preserve_images.setChecked(config.setting["preserve_images"]) self.ui.remove_ape_from_mp3.setChecked(config.setting["remove_ape_from_mp3"]) self.ui.remove_id3_from_flac.setChecked(config.setting["remove_id3_from_flac"]) + self.ui.fix_missing_seekpoints_flac.setChecked(config.setting["fix_missing_seekpoints_flac"]) self.ui.preserved_tags.update(config.setting["preserved_tags"]) self.ui.preserved_tags.set_user_sortable(False) @@ -86,6 +88,7 @@ class TagsOptionsPage(OptionsPage): config.setting["preserve_images"] = self.ui.preserve_images.isChecked() config.setting["remove_ape_from_mp3"] = self.ui.remove_ape_from_mp3.isChecked() config.setting["remove_id3_from_flac"] = self.ui.remove_id3_from_flac.isChecked() + config.setting["fix_missing_seekpoints_flac"] = self.ui.fix_missing_seekpoints_flac.isChecked() config.setting["preserved_tags"] = list(self.ui.preserved_tags.tags) self.tagger.window.enable_tag_saving_action.setChecked(not config.setting["dont_write_tags"]) diff --git a/picard/ui/ui_options_tags.py b/picard/ui/ui_options_tags.py index 0ee110133..54debcb94 100644 --- a/picard/ui/ui_options_tags.py +++ b/picard/ui/ui_options_tags.py @@ -38,6 +38,9 @@ class Ui_TagsOptionsPage(object): self.remove_ape_from_mp3 = QtWidgets.QCheckBox(self.before_tagging) self.remove_ape_from_mp3.setObjectName("remove_ape_from_mp3") self.vboxlayout1.addWidget(self.remove_ape_from_mp3) + self.fix_missing_seekpoints_flac = QtWidgets.QCheckBox(self.before_tagging) + self.fix_missing_seekpoints_flac.setObjectName("fix_missing_seekpoints_flac") + self.vboxlayout1.addWidget(self.fix_missing_seekpoints_flac) spacerItem = QtWidgets.QSpacerItem(20, 6, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) self.vboxlayout1.addItem(spacerItem) self.preserved_tags_label = QtWidgets.QLabel(self.before_tagging) @@ -61,6 +64,7 @@ class Ui_TagsOptionsPage(object): TagsOptionsPage.setTabOrder(self.clear_existing_tags, self.preserve_images) TagsOptionsPage.setTabOrder(self.preserve_images, self.remove_id3_from_flac) TagsOptionsPage.setTabOrder(self.remove_id3_from_flac, self.remove_ape_from_mp3) + TagsOptionsPage.setTabOrder(self.remove_ape_from_mp3, self.fix_missing_seekpoints_flac) def retranslateUi(self, TagsOptionsPage): _translate = QtCore.QCoreApplication.translate @@ -71,5 +75,6 @@ class Ui_TagsOptionsPage(object): self.preserve_images.setText(_("Keep embedded images when clearing tags")) self.remove_id3_from_flac.setText(_("Remove ID3 tags from FLAC files")) self.remove_ape_from_mp3.setText(_("Remove APEv2 tags from MP3 files")) + self.fix_missing_seekpoints_flac.setText(_("Fix missing seekpoints for FLAC files")) self.preserved_tags_label.setText(_("Preserve these tags from being cleared or overwritten with MusicBrainz data:")) from picard.ui.widgets.taglisteditor import TagListEditor diff --git a/test/formats/common.py b/test/formats/common.py index bb6a60e24..4d2907e67 100644 --- a/test/formats/common.py +++ b/test/formats/common.py @@ -50,6 +50,7 @@ settings = { 'rating_user_email': 'users@musicbrainz.org', 'remove_ape_from_mp3': False, 'remove_id3_from_flac': False, + 'fix_missing_seekpoints_flac': False, 'remove_images_from_tags': False, 'save_images_to_tags': True, 'write_id3v1': True, diff --git a/ui/options_tags.ui b/ui/options_tags.ui index 5fd6079c6..7328aedfb 100644 --- a/ui/options_tags.ui +++ b/ui/options_tags.ui @@ -71,6 +71,13 @@ + + + + Fix missing seekpoints for FLAC files + + + @@ -124,6 +131,7 @@ preserve_images remove_id3_from_flac remove_ape_from_mp3 + fix_missing_seekpoints_flac