I wrote a Python script for this job (requires mutagen):
import pathlib
import sys
import mutagen.id3
DATA_SEARCH_STR = "data=b'"
if __name__ == '__main__':
errorval = 0
try:
filearg = sys.argv[1]
except IndexError:
errorval = 1
print('ERROR: No file argument.')
else:
fp = pathlib.Path(filearg)
if not fp.is_file():
errorval = 2
print('ERROR: Not a file.')
else:
try:
I = mutagen.id3.ID3(fp)
except mutagen.id3.ID3NoHeaderError:
errorval = 3
print('ERROR: File has no ID3 tag.')
if errorval:
print('USAGE: python id3report.py myfile')
sys.exit(errorval)
L = [str(fp)]
print(L[-1])
L.append('ID3 version: ' + '.'.join(str(x) for x in I.version) + '\n')
print(L[-1])
for key in sorted(set(I.keys())):
L.append(f'key: "{key}"')
print(L[-1])
if hasattr(I[key], 'data'):
s0 = repr(I[key])
i0 = s0.find(DATA_SEARCH_STR)
i1 = s0.find("'", i0 + len(DATA_SEARCH_STR))
while s0[i1-1] == '\\':
i1 = s0.find("'", i1+1)
s1 = s0[:i0].rstrip(" ,") + s0[i1+1:]
L.append(f'value: {s1}')
print(L[-1])
L.append(f'data: {len(I[key].data)} bytes')
print(L[-1])
else:
L.append(f'value: {I[key]!r}')
print(L[-1])
L.append('')
print(L[-1])
outfile = fp.parent / f"{fp.stem}.id3report"
with outfile.open('w', encoding='utf-8') as _f:
_f.write('\n'.join(L))
This script print report to screen AND saves it next to the target file with .idreport
extension.
Example output:
Trinity's Breakfast - The Punk .mp3
ID3 version: 2.3.0
key: "GEOB:SfMarkers"
value: GEOB(encoding=<Encoding.LATIN1: 0>, mime='', filename='', desc='SfMarkers')
data: 12 bytes
key: "TCOM"
value: TCOM(encoding=<Encoding.UTF16: 1>, text=['Zoltán Maxi Marton'])
key: "TCON"
value: TCON(encoding=<Encoding.LATIN1: 0>, text=['Electronic'])
key: "TDRC"
value: TDRC(encoding=<Encoding.LATIN1: 0>, text=['2020'])
key: "TIT2"
value: TIT2(encoding=<Encoding.LATIN1: 0>, text=['The Punk'])
key: "TPE1"
value: TPE1(encoding=<Encoding.LATIN1: 0>, text=["Trinity's Breakfast"])
As you can see the script trims data to prevent flooding the terminal. You can easily make a full report version by removing the hasattr
condition.