(noob alert) why doesn't this work?

Scott David Daniels Scott.Daniels at Acm.Org
Tue Mar 22 12:21:49 EST 2005


Bouke Woudstra wrote:
> It turned out that some flac files have tags like Artist=artistname and others 
> have artist=artistname. Therefore it couldn't find the artist! So now I just 
> look for 'rtist=' which works great.

You might want try using something like this:

     wanted = set('artist album date title tracknumber genre'.split())
     ...

     def read_and_call(self, flac, source):
         parts = {}
         for line in source:
             try:
                 head, remainder = line.split('=', 1)
             except ValueError:
                 pass # No equal sign in the line
             else:
                 head = head.strip().lower()
                 if head in wanted:
                     parts[head] = remainder.strip()
         self.wav2mp3(flac, **parts)



More information about the Python-list mailing list