123456789101112131415161718192021222324 |
- from eyed3 import load
- import os
- import re
- def no_translate(s):
- return re.sub(r" ?\(.+\)", "", s)
- def set_meta(filename, song, album):
- audiofile = load(filename)
- audiofile.tag.artist = no_translate(song["artist"])
- audiofile.tag.album = no_translate(album["title"])
- audiofile.tag.album_artist = no_translate(album["artist"])
- audiofile.tag.title = no_translate(song["title"])
- audiofile.tag.track_num = song["number"]
- audiofile.tag.lyrics.set(song["lyrics"])
- cover = "\\".join(filename.split("\\")[:-1]) + "\\cover.jpg"
- if os.path.exists(cover):
- with open(cover, "rb") as f:
- audiofile.tag.images.set(3, f.read() , "image/jpeg", u"")
- audiofile.tag.save()
|