(noob alert) why doesn't this work?

Stephen Thorne stephen.thorne at gmail.com
Tue Mar 22 19:18:05 EST 2005


On Tue, 22 Mar 2005 12:10:50 +0100, Bouke Woudstra
<bouke at gentoolinux.demon.nl> wrote:
>                 for flac in flacfiles:
>                         cmd = 'metaflac --export-tags=- "%s"' % flac
>                         for line in os.popen(cmd).readlines():
>                                 if 'Artist' in line:
>                                         artist = line[7:-1]
>                                 if 'Album' in line:
>                                         album = line[6:-1]
>                                 if 'Date' in line:
>                                         year = line[5:-1]
>                                 if 'Title' in line:
>                                         title = line[6:-1]
>                                 if 'Tracknumber' in line:
>                                         number = line[12:-1]
>                                 if 'Genre' in line:
>                                         genre = line[6:-1]
>                         self.wav2mp3(flac, title, artist, album, year, number, genre)

I'll point out, there's a bug here. If any flac file is missing any
one of these tags, but a previous one does have the tag, (i.e.
'Genre'), then the previous tag will be used, because you don't reset
the variables each time around the loop.


-- 
Stephen Thorne
Development Engineer, NetBoxBlue.com



More information about the Python-list mailing list