Objective
Create a Python program that reads ID3 v1 specification tags from an MP3 music file. You should also check if the ID tag corresponds to the TAG characters of version 1.
ID3 specifications apply to any audiovisual file or container. However, audio containers are generally applied mainly. There are three versions of the specification that are compatible. For example, a file can contain tags simultaneously version 1.1 and version 2.0. In this case, the media player must decide which ones are relevant.
ID3 version 1This first specification is very simple. It consists of attaching a block of fixed size of 128 bytes at the end of the file in question. This block contains the following tags:
- An identification header with the characters "TAG".
- Title: 30 characters.
- Artist: 30 characters.
- Album: 30 characters.
- Year: 4 characters.
- One comment: 30 characters.
- Genre (musical): a character.
All tags use ASCII characters, except the genre, which is an integer stored in a single byte. The musical genre associated with each byte is predefined in the standard and includes definitions of 80 genres, numbered from 0 to 79. Certain reproduction programs have expanded on their own the defined genres (from number 80).
Files: the file song.mp3 already exists. Open it in binary mode and check whether its last 128 bytes start with TAG. If they do, print one value per line, in this order: TAG, title, artist, album, year, comment and the genre as a number (the value of the genre byte). Texts are ASCII/Latin-1 and must be printed without the trailing zero bytes or spaces. If there is no tag, print No ID3v1 tag found.
TAG
Impact Moderato
Nauj Llopir
YouTube Audio Library
1993
Free music
17
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise