Reputation: 81
I have a small program for downloading youtube videos from playlist as an .mp3 I get the .mp3 file but sometimes they even have a title with the name of downloading website(yt5s.com): Image of file details
I want to fix this problem by either removing the title or changing the title. I tried:
from tinytag import TinyTag, TinyTagException
tracks = []
for root, dirs, files, in os.walk(path):
for name in files:
if name.endswith((".mp3",".m4a",".flac",".alac")):
tracks.append(name)
try:
temp_track = TinyTag.get(root + "\\" + name)
print(temp_track.artist, "-", temp_track.title)
except TinyTagException:
print("Error")
But I only managed to print out the artist and title.
Upvotes: 3
Views: 2255
Reputation: 81
I finally found the right module eyed3. This changes the title of every song in the directory:
import eyed3
import os
files = os.listdir(path)
for _ ,file in enumerate(files):
audiofile = eyed3.load(os.path.join(path, file))
audiofile.tag.title = "Title"
audiofile.tag.save()
You might want this:
from eyed3.id3.frames import ImageFrame
audiofile.tag.images.set(ImageFrame.FRONT_COVER, open(path2+file,'rb').read(), 'image/jpeg')
audiofile.tag.album = "Album"
audiofile.tag.album_artist = Artist
audiofile.tag.artist = Artist
Also, I met a few bugs resulting in me not seeing the cover of a song.
When album_artist and artist weren't the same person. When there was
more than one song in the same album with a different cover.
Also, it prints out message "Lame tag CRC check failed" but it doesn't do anything.
Upvotes: 5