I Was looking for a way to scan mp3 meta-data yesterday and i found this code snippet on the Internet
def getID3(filename):
fp = open(filename, 'r')
fp.seek(-128, 2)
fp.read(3) # TAG iniziale
title = fp.read(30)
artist = fp.read(30)
album = fp.read(30)
fp.close()
return {'title':title, 'artist':artist, 'album':album}
it totally works and all but the problem is that every time i use it, this --->\x00
<---shows up at the end of the title, album, or artist. For example;
>>> import getid as id
>>> import os
>>> music = 'D:/Muzic'
>>> os.chdir(music)
>>> meta = id.getID3('04 - Mayday Parade - Your Song.mp3')
>>> meta
{'album': 'Tales Told By Dead Friends\x00\x00\x00\x00', 'artist': 'Mayday Parade\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'title': 'Your Song\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}
Anyone Know how to get rid of it?
btw it happens to all of the music i currently tried.