Setting "Album Artist" using eyed3?

Question:

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?

Asked By: MikeTheTall

||

Answers:

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

The above code works pretty well for me. Glad if I helped 🙂

Answered By: Prateek Alat

This is the command I wrote down some time ago to change that field:

eyeD3 --set-text-frame=TPE2:"Various Artists" filename.mp3

where “Various Artists” is the value you want in the “Album Artist” field.

Answered By: Jay

Related: If the album artist was empty, I wanted it to be set to the value of the artist field for my music library in Quod Libet. That worked with:

import os
import quodlibet.library

library_path = os.path.join(quodlibet.get_user_dir(), "songs")
library = quodlibet.library.init(library_path)

for song in library:
    if song('albumartist') == '':
        song['albumartist'] = song('artist')
        print(song['albumartist'])
    library.changed([song])

library.save()
Answered By: Tamriel
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.