How to add tags to audio files on Mac with Python


I am user of Iphone, and I like to listen different audio books. Sometimes audiobooks have no album tag, so they are not grouped by Apple Music application.
To avoid this problem I decided to share my knowledge with others. Fo now it is the video on Ukrainian.



I use Mutagen to do the hard work. The script is pretty simple, such that beginners can use it.


   
from pathlib import Path
from mutagen.mp3 import EasyMP3 as MP3
 
 
folder = Path().home().joinpath('Documents').joinpath('mp3_Jeeves_and_Wooster')
 
assert folder.exists()
 
tracks = folder.glob('*.mp3')
 
 
for track in tracks:
    tag = MP3(track)
    tag['album'] = 'Jeeves & Wooster'
    tag['title'] = track.name.split('.')[0]
    print(tag.tags)
    tag.save()

Comments

Popular posts from this blog

Install Kubeflow locally

RabbitMQ and OpenShift