@classmethod<EOL><INDENT>def from_filename(cls, filename):<DEDENT>
if not filename:<EOL><INDENT>logger.error('<STR_LIT>')<EOL>return None<EOL><DEDENT>if not os.path.exists(filename):<EOL><INDENT>logger.error("<STR_LIT>", filename)<EOL>return None<EOL><DEDENT>if os.path.isdir(filename):<EOL><INDENT>logger.error("<STR_LIT>", filename)<EOL>return None<EOL><DEDENT>try:<EOL><INDENT>audiofile = eyed3.load(filename)<EOL><DEDENT>except Exception as error:<EOL><INDENT>print(type(error), error)<EOL>return None<EOL><DEDENT>if audiofile is None:<EOL><INDENT>return None<EOL><DEDENT>tags = audiofile.tag<EOL>album = tags.album<EOL>title = tags.title<EOL>lyrics = '<STR_LIT>'.join([l.text for l in tags.lyrics])<EOL>artist = tags.album_artist<EOL>if not artist:<EOL><INDENT>artist = tags.artist<EOL><DEDENT>song = cls(artist, title, album, lyrics)<EOL>song.filename = filename<EOL>return song<EOL>
Class constructor using the path to the corresponding mp3 file. The
metadata will be read from this file to create the song object, so it
must at least contain valid ID3 tags for artist and title.