The tag information (song name, album name, artist name, etc.) of the song file can be easily edited from various media players.
Especially in iTunes, it is very convenient to use Gracenote to automatically acquire tag information at the same time as importing from a CD.
However, in some cases, the acquired tag information may be __ not your favorite __.
To give an example
etc...
It is troublesome to edit these songs one by one, so I always wanted to be able to manipulate the tag information from the system. (Although you will also need CDDB that meets the above requirements ...)
This time, regarding the processing to get the tag information from the manipulating the tag information from the system, the result of verifying the library called JAudioTaggerwith the combination of theJava language and SpringBoot` is left as a memorandum.
Add the following dependencies to dependencies in pom.xml
<dependency>
<groupId>org</groupId>
<artifactId>jaudiotagger</artifactId>
<version>2.0.3</version>
</dependency>
First, check the tag information of the appropriate song imported into iTunes

Now let's actually read the tag information from the Java code (see below for the code)
AudioFile audioFile = AudioFileIO.read(File object that reads a music file);
Tag tag = audioFile.getTag();
System.out.println(tag.getFirst(FieldKey.TITLE));
System.out.println(tag.getFirst(FieldKey.ARTIST));
System.out.println(tag.getFirst(FieldKey.ALBUM_ARTIST));
System.out.println(tag.getFirst(FieldKey.ALBUM));
System.out.println(tag.getFirst(FieldKey.YEAR));
System.out.println(tag.getFirst(FieldKey.COMPOSER));
System.out.println(tag.getFirst(FieldKey.GENRE));
The output result is as follows.
Who will ring the bell?
Keyakizaka46
Keyakizaka46
Who will ring the bell?
2020
Yuki Tsujimura
J-POP
By the way, FieldKey seems to be able to get something like the following
| FieldKey | Tag information that can be obtained |
|---|---|
| TITLE | Song name |
| TITLE_SORT | Song name(Read) |
| ARTIST | artist name |
| ARTIST_SORT | artist name(Read) |
| ALBUM_ARTIST | Album artist |
| ALBUM_ARTIST_SORT | Album artist(Read) |
| ALBUM | Album name |
| ALBUM_SORT | Album name(Read) |
| YEAR | Album release year |
| COMPOSER | composer |
| COMPOSER_SORT | composer(Read) |
| GENRE | Genre |
It seems that you can get various other fields (Reference: Mapping table)
This time I verified getting tag information, but next I would like to verify writing tag information. Also, I would like to verify the operation of tag information in languages other than Java` when I have time.
Last but not least, with subscriptions becoming mainstream these days, manipulating local music files may be nonsense (laughs).
Recommended Posts