Skip to main content

A parser and serializer for ID3v2 tags

Project description

An ID3 parser and serializer for Python 3.

Example Usage

Creating an ID3 tag from scratch

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'

Parsing an ID3 tag

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

Loading and saving an ID3 tag

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()

Querying frames

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

id3parse-0.1.1.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file id3parse-0.1.1.tar.gz.

File metadata

  • Download URL: id3parse-0.1.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for id3parse-0.1.1.tar.gz
Algorithm Hash digest
SHA256 af62e8d983d728404a63f68cd03cefbbe9523b60b9c200aaf245df17a7f67408
MD5 20611aca4ff0ceb7b94a3d0287267a10
BLAKE2b-256 d9faab128ac6534bd6ab2ecceaa9b71844d2d45245df2f746e82b19020c8fd26

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page