This repository was archived by the owner on Jun 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Lorenz Gorse edited this page Jun 23, 2014
·
2 revisions
An ID3 parser and serializer for Python 3.
Input:
from id3parse import ID3, ID3TextFrame
id3 = ID3.from_scratch()
id3.add_frame(ID3TextFrame.from_scratch('TIT2', 'Why Don\'t You Get A Job?'))
id3.add_frame(ID3TextFrame.from_scratch('TPE1', 'The Offspring'))
print(id3.serialize())Output:
b'ID3\x04\x00\x00\x00\x00\x00=TIT2\x00\x00\x00\x1a\x00\x00\x03Why Don\'t You Get A Job?\x00TPE1\x00\x00\x00\x0f\x00\x00\x03The Offspring\x00'
Input:
from id3parse import ID3
id3 = ID3.from_byte_array(b'ID3\x04\x00\x00\x00\x00\x00=TIT2\x00\x00\x00\x1a\x00\x00\x03Why Don\'t You Get A Job?\x00TPE1\x00\x00\x00\x0f\x00\x00\x03The Offspring\x00')
for f in id3.frames:
print(f)Output:
TIT2: Why Don't You Get A Job?
TPE1: The Offspring
from id3parse import ID3, ID3TextFrame
id3 = ID3.from_file('01 - The Offspring - Why Dont You Get A Job.mp3')
id3.add_frame(ID3TextFrame.from_scratch('TPE1', 'The Offspring'))
id3.add_frame(ID3TextFrame.from_scratch('TIT2', 'Why Don\'t You Get A Job?'))
id3.to_file()from id3parse import ID3, ID3TextFrame
id3 = ID3.from_file('01 - The Offspring - Why Dont You Get A Job.mp3')
tpe1 = id3.find_frame_by_name('TPE1') # Returns a frame, fails if more than one
tpe1.text = 'The Offspring' # frame with this name is available
privs = id3.find_frames_by_name('PRIV') # Returns a list of frames
for priv in privs:
print(priv)
id3.to_file()