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()Handles IPLS frames and all frames beginning with T except TXXX.
ID3TextFrame.from_scratch('TIT2', 'Have You Ever')text- The text of the frame
Handles COMM frames.
ID3CommentFrame.from_scratch('deu', 'a short description', 'the actual comment')language- The language of the commentdescription- A short description of the commentcomment- The actual comment
Handles POPM frames.
ID3PopularimeterFrame.from_scratch('john@doe.com', 106, 32)email- The email address of the person who rated the contentrating- The rating of the content, an integer between 0 and 255, inclusiveplay_counter- A counter of arbitrary size, indicating how often the conten has been played
Handles PCNT frames.
ID3PlayCounterFrame.from_scratch(32)play_counter- A counter of arbitrary size, indicating how often the conten has been played
Handles all frames
ID3UnknownFrame.from_scratch('APIC', b'....')raw_bytes- The raw content of the frame body