From: epg <> Date: Thu, 29 Mar 2007 00:02:03 +0000 (+0000) Subject: (flac2mp3): Fix skip_until processing: stop pointless splitting the X-Git-Url: https://diplodocus.org/git/flac-archive/commitdiff_plain/082b54df18a7024d03047b437dd45c289c3272bf?ds=inline;hp=6c58deb659519e8e298a4e65e340a50ba37d6175 (flac2mp3): Fix skip_until processing: stop pointless splitting the list into two variables and other weird stuff! (Tags): Storing the global tags in the same dict meant that __len__ was incorrect (+1) for multi-track files. Keep them separate. --- diff --git a/flac2mp3 b/flac2mp3 index 999fd66..98558d9 100755 --- a/flac2mp3 +++ b/flac2mp3 @@ -67,11 +67,6 @@ def flac2mp3(fn, title, artist, album, date, track, skip_until, pics=None): if date == None: date = '' - try: - (skip_arg, until_arg) = skip_until - except ValueError: - skip_arg = until_arg = '' - if quiet: flac_options = '--silent' else: @@ -98,8 +93,8 @@ def flac2mp3(fn, title, artist, album, date, track, skip_until, pics=None): quoted_outfile = ('%s (%s) %02d %s.mp3' % (artist, album, track, title)).replace('/', '_') - run_or_die(3, "flac %s -cd %s %s '%s' | lame --add-id3v2 %s --tt '%s' --ta '%s' --tl '%s' --ty '%s' --tn %d - '%s'" - % (flac_options, skip_arg or '', until_arg or '', fn, + run_or_die(3, "flac %s -cd %s '%s' | lame --add-id3v2 %s --tt '%s' --ta '%s' --tl '%s' --ty '%s' --tn %d - '%s'" + % (flac_options, ' '.join(skip_until), fn, lame_options, title, artist, album, date, track, quoted_outfile)) @@ -155,18 +150,17 @@ def get_decode_args(fn): # get PART as part of the filelname, same as mp3s. class Tags(object): def __init__(self): + self._global = {} self._tags = {} def __len__(self): return len(self._tags) def get(self, key, track=None): key = key.upper() try: - if track == None: - return self._tags[None][key] try: return self._tags[track][key] except KeyError: - return self._tags[None][key] + return self._global[key] except KeyError: return None def gets(self, key, track=None): @@ -176,11 +170,16 @@ class Tags(object): return '\n'.join(value) def set(self, key, value, track=None): key = key.upper() - if track not in self._tags: - self._tags[track] = {} - if key not in self._tags[track]: - self._tags[track][key] = [] - self._tags[track][key].append(value) + if track == None: + tags = self._global + else: + try: + tags = self._tags[track] + except KeyError: + tags = self._tags[track] = {} + if key not in tags: + tags[key] = [] + tags[key].append(value) def get_tags(fn): '''Return the ARTIST, ALBUM, and DATE tags followed by the TITLE tags