Reputation: 21
I used to get songs with the artist and the song name in the file name (for example - "britney spears - oops i did it again". My script have 2 purposes: 1.add the artist name and song to his MP3's attributes (Using eyed3). 2.create a new folder to the artist in my main music folder (if I already don't have one).
My problem is that if the MP3 file have no attributes, I can't add it new ones..
Here is my code (It's my first one :-))..Thanks!
#That's the 0.2 ver of my code
import os
import shutil
import eyed3.id3
songs_path = raw_input("Please insert the path of your Songs: ")
music_path = raw_input("Please insert the path of your music folders location: ")
#That's function supposed to present the files in a path
def files_in_folder(m):
Files = os.listdir(m)
return Files
mp3_files_list = files_in_folder(downloads_path)
artist_list = files_in_folder(music_path)
for i in mp3_files_list:
song_artist, song_title = i.split(' - ')
if not os.path.exists(music_path + '\\' + song_artist):
os.mkdir(music_path + '\\' + song_artist, 0777 )
src_file = os.path.join(downloads_path, i)
dst_file = os.path.join(music_path + '\\' + song_artist + '\\' + song_title)
print src_file
print dst_file
shutil.move(src_file, dst_file)
track_mp3_file = eyed3.load(dst_file)
if track_mp3_file.tag is None:
track_mp3_file.tag = eyed3.id3.Tag()
track_mp3_file.tag.file_info = eyed3.id3.FileInfo(dst_file)
track_mp3_file.tag.artist = unicode(song_artist, "UTF-8")
print track_mp3_file.tag.artist
track_mp3_file.tag.title = unicode(song_title, "UTF-8")
track_mp3_file.tag.save()
Upvotes: 2
Views: 270
Reputation: 11
try to save the tag with another id3 version:
track_mp3_file.tag.save(version=(2, 3, 0))
from wikipedia:
Windows Explorer and Windows Media Player cannot handle ID3v2.4 tags in any version, up to and including Windows 8 / Windows Media Player 12. Windows can understand ID3v2 up to and including version 2.3
Upvotes: 1