]> diplodocus.org Git - flac-archive/commitdiff
(flac2mp3): Fix skip_until processing: stop pointless splitting the
authorepg <>
Thu, 29 Mar 2007 00:02:03 +0000 (00:02 +0000)
committerepg <>
Thu, 29 Mar 2007 00:02:03 +0000 (00:02 +0000)
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.

flac2mp3

index 999fd66d6fe92b87225f67655c1d33c2f8f3afd1..98558d9a1fab94e19424bffbe7ae7f98f6707148 100755 (executable)
--- a/flac2mp3
+++ b/flac2mp3
@@ -67,11 +67,6 @@ def flac2mp3(fn, title, artist, album, date, track, skip_until, pics=None):
     if date == None:
         date = ''
 
     if date == None:
         date = ''
 
-    try:
-        (skip_arg, until_arg) = skip_until
-    except ValueError:
-        skip_arg = until_arg = ''
-
     if quiet:
         flac_options = '--silent'
     else:
     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('/', '_')
 
     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))
 
                   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):
 # 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:
         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:
             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):
         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()
         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
 
 def get_tags(fn):
     '''Return the ARTIST, ALBUM, and DATE tags followed by the TITLE tags