def loadSettings(self): settings = PuddleConfig(os.path.join(CONFIGDIR, 'tagsources.conf')) get = lambda s, k, i=False: settings.get('tagsources', s, k, i) source = get('lastsource', 'Musicbrainz') self.__sourceFields = [ settings.get('tagsourcetags', ts.name, []) for ts in self.__sources ] index = self.sourcelist.findText(source) if index == -1: index = 0 self.sourcelist.setCurrentIndex(index) self.__fieldsEdit.setTags(self.__sourceFields[index]) df = get('trackpattern', u'%track% - %title%') self.listbox.trackPattern = df albumformat = get( 'albumpattern', u'%artist% - %album%$if(%__numtracks%, [%__numtracks%], "")') self.listbox.albumPattern = albumformat sort_options = get('sortoptions', [u'artist, album', u'album, artist']) sort_options = split_strip(sort_options) self.listbox.setSortOptions(sort_options) sortindex = get('lastsort', 0) self.listbox.sort(sort_options[sortindex]) filepath = os.path.join(CONFIGDIR, 'mappings') self.setMapping(audioinfo.loadmapping(filepath)) useragent = get('useragent', '') if useragent: set_useragent(useragent) checkstate = get('existing', False) self.__updateEmpty.setChecked(checkstate) checkstate = get('autoretrieve', False) self.__autoRetrieve.setChecked(checkstate) self.listbox.albumBound = get('album_bound', 70, True) / 100.0 self.listbox.trackBound = get('track_bound', 80, True) / 100.0 self.listbox.jfdi = bool(get('jfdi', True, True)) self.listbox.matchFields = get('match_fields', ['artist', 'title'])
def loadSettings(self): settings = PuddleConfig(os.path.join(CONFIGDIR, 'tagsources.conf')) get = lambda s, k, i=False: settings.get('tagsources', s, k, i) source = get('lastsource', 'Musicbrainz') self.__sourceFields = [settings.get('tagsourcetags', ts.name, []) for ts in self.__sources] index = self.sourcelist.findText(source) if index == -1: index = 0 self.sourcelist.setCurrentIndex(index) self.__fieldsEdit.setTags(self.__sourceFields[index]) df = get('trackpattern', u'%track% - %title%') self.listbox.trackPattern = df albumformat = get('albumpattern', u'%artist% - %album%$if(%__numtracks%, [%__numtracks%], "")') self.listbox.albumPattern = albumformat sort_options = get('sortoptions', [u'artist, album', u'album, artist']) sort_options = split_strip(sort_options) self.listbox.setSortOptions(sort_options) sortindex = get('lastsort', 0) self.listbox.sort(sort_options[sortindex]) filepath = os.path.join(CONFIGDIR, 'mappings') self.setMapping(audioinfo.loadmapping(filepath)) useragent = get('useragent', '') if useragent: set_useragent(useragent) checkstate = get('existing', False) self.__updateEmpty.setChecked(checkstate) checkstate = get('autoretrieve', False) self.__autoRetrieve.setChecked(checkstate) self.listbox.albumBound = get('album_bound', 70, True) / 100.0 self.listbox.trackBound = get('track_bound', 80, True) / 100.0 self.listbox.jfdi = bool(get('jfdi', True, True)) self.listbox.matchFields = get('match_fields', ['artist', 'title'])
def update_settings(): """Updates any out of date settings.""" #Mapping contains invalid case for ID3 cparser = PuddleConfig() filepath = os.path.join(cparser.savedir, 'mappings') mapping = audioinfo.loadmapping(filepath, {}) if "ID3" in mapping: id3 = mapping['ID3'] keys = {u'MusicBrainz Album ID': u'MusicBrainz Album Id', u'MusicBrainz Artist ID': u'MusicBrainz Artist Id'} for k in keys: if k in id3: id3[keys[k]] =id3[k] del(id3[k]) audioinfo.setmapping(mapping)
def update_settings(): """Updates any out of date settings.""" #Mapping contains invalid case for ID3 cparser = PuddleConfig() filepath = os.path.join(cparser.savedir, 'mappings') mapping = audioinfo.loadmapping(filepath, {}) if "ID3" in mapping: id3 = mapping['ID3'] keys = { u'MusicBrainz Album ID': u'MusicBrainz Album Id', u'MusicBrainz Artist ID': u'MusicBrainz Artist Id' } for k in keys: if k in id3: id3[keys[k]] = id3[k] del (id3[k]) audioinfo.setmapping(mapping)
def restoreSettings(self): scts = action_shortcuts.create_action_shortcuts( mainwin.funcs.applyaction, self) self.addShortcuts('&Actions', scts) connect_actions(scts, PuddleDock._controls) cparser = PuddleConfig() settings = QSettings(constants.QT_CONFIG, QSettings.IniFormat) gensettings = {} controls = PuddleDock._controls.values() for control in controls: if hasattr(control, 'loadSettings'): control.loadSettings() if hasattr(control, 'gensettings'): t = load_gen_settings(control.gensettings) gensettings[control] = dict(t) for control, val in gensettings.items(): control.applyGenSettings(val, 0) self._lastdir = [encode_fn(cparser.get( 'main', 'lastfolder', constants.HOMEDIR))] mapping = { u'VorbisComment': {u'date': u'year', u'tracknumber': u'track', u'musicbrainz_albumid': u'mbrainz_album_id', u'musicbrainz_artistid': u'mbrainz_artist_id', u'musicbrainz_trackid': u'mbrainz_track_id'}, u'MP4': {u'MusicBrainz Track Id': u'mbrainz_track_id', u'MusicBrainz Artist Id': u'mbrainz_artist_id', u'MusicBrainz Album Id': u'mbrainz_album_id'}, u'ID3': {u'ufid:http://musicbrainz.org': u'mbrainz_track_id', u'MusicBrainz Album Id': u'mbrainz_album_id', u'MusicBrainz Artist Id': u'mbrainz_artist_id'}, u'APEv2': {u'musicbrainz_albumid': u'mbrainz_album_id', u'musicbrainz_artistid': u'mbrainz_artist_id', u'musicbrainz_trackid': u'mbrainz_track_id'}} filepath = os.path.join(cparser.savedir, 'mappings') audioinfo.setmapping(audioinfo.loadmapping(filepath, mapping)) status['genres'] = genres.load_genres() connect_controls(controls + [mainwin.previews.obj]) cover_pattern = cparser.get('tags', 'cover_pattern', 'folder') status['cover_pattern'] = cover_pattern winsettings('mainwin', self) if cparser.get("main", "maximized", True): self.showMaximized() QApplication.processEvents() if constants.FS_ENC == "ascii": QMessageBox.warning(self, "puddletag", translate("Errors", "Your filesystem encoding was detected as <b>ASCII</b>. <br />" "You won't be able to rename files using accented, <br />" " cyrillic or any characters outside the ASCII alphabet.")) for control, val in gensettings.items(): control.applyGenSettings(val, 1) h = self._table.horizontalHeader() h.restoreState(settings.value('table/header').toByteArray()) self.restoreState(settings.value('main/state').toByteArray()) confirmations.load() shortcutsettings.ActionEditorDialog._loadSettings(status['actions']) update_settings() QApplication.processEvents()
def restoreSettings(self): scts = action_shortcuts.create_action_shortcuts( mainwin.funcs.applyaction, self) self.addShortcuts('&Actions', scts) connect_actions(scts, PuddleDock._controls) cparser = PuddleConfig() settings = QSettings(constants.QT_CONFIG, QSettings.IniFormat) gensettings = {} controls = PuddleDock._controls.values() for control in controls: if hasattr(control, 'loadSettings'): control.loadSettings() if hasattr(control, 'gensettings'): t = load_gen_settings(control.gensettings) gensettings[control] = dict(t) for control, val in gensettings.items(): control.applyGenSettings(val, 0) self._lastdir = [ encode_fn(cparser.get('main', 'lastfolder', constants.HOMEDIR)) ] mapping = { u'VorbisComment': { u'date': u'year', u'tracknumber': u'track', u'musicbrainz_albumid': u'mbrainz_album_id', u'musicbrainz_artistid': u'mbrainz_artist_id', u'musicbrainz_trackid': u'mbrainz_track_id' }, u'MP4': { u'MusicBrainz Track Id': u'mbrainz_track_id', u'MusicBrainz Artist Id': u'mbrainz_artist_id', u'MusicBrainz Album Id': u'mbrainz_album_id' }, u'ID3': { u'ufid:http://musicbrainz.org': u'mbrainz_track_id', u'MusicBrainz Album Id': u'mbrainz_album_id', u'MusicBrainz Artist Id': u'mbrainz_artist_id' }, u'APEv2': { u'musicbrainz_albumid': u'mbrainz_album_id', u'musicbrainz_artistid': u'mbrainz_artist_id', u'musicbrainz_trackid': u'mbrainz_track_id' } } filepath = os.path.join(cparser.savedir, 'mappings') audioinfo.setmapping(audioinfo.loadmapping(filepath, mapping)) status['genres'] = genres.load_genres() connect_controls(controls + [mainwin.previews.obj]) cover_pattern = cparser.get('tags', 'cover_pattern', 'folder') status['cover_pattern'] = cover_pattern winsettings('mainwin', self) if cparser.get("main", "maximized", True): self.showMaximized() QApplication.processEvents() if constants.FS_ENC == "ascii": QMessageBox.warning( self, "puddletag", translate( "Errors", "Your filesystem encoding was detected as <b>ASCII</b>. <br />" "You won't be able to rename files using accented, <br />" " cyrillic or any characters outside the ASCII alphabet.")) for control, val in gensettings.items(): control.applyGenSettings(val, 1) h = self._table.horizontalHeader() h.restoreState(settings.value('table/header').toByteArray()) self.restoreState(settings.value('main/state').toByteArray()) confirmations.load() shortcutsettings.ActionEditorDialog._loadSettings(status['actions']) update_settings() QApplication.processEvents()