pythoneyed3

Setting "Album Artist" using eyed3?


I'm trying to use eyed3, as a Python library, in order to change the artist name for a large collection of .MP3 files. I tried using the sample code of the project's web page (http://eyed3.nicfit.net/) and setsaudiofile.tag.artist changes the "Contributing Artist". According to the docs (at http://eyed3.nicfit.net/api/eyed3.html) there are no other artist fields for a tag object.

Is is possible to use eyed3 to actually change the Album Artist? If so, can you provide clear, concise Python code that does so?


Solution

  • For a large collection of MP3s, what you can do is put all of the songs of one artist in a particular folder. Eg:- All "Coldplay" songs go in the "Coldplay" folder

    If you are on Linux, you can do the following:-

    import os
    import eyed3
    folder = raw_input('Please enter the folder of music')
    files = os.listdir(folder) # This will give us a list of all of the MP3s in that folder
    artist = folder.split('/')[-1]
    
    for x in files:
        mp3 = eyed3.load(folder + '/' + x) # Loads each and every MP3
        mp3.tag.artist = unicode(artist, "UTF-8") # Sets the "artist" tag to the artist name 
        mp3.tag.save() # Saves tag
    

    Just edit the code by making all the slashes "/" into backslashes "" if you are on Windows.