python-通过eyeD3更改MP3文件中的歌词

我正在尝试用Python创建一个程序,该程序可自动检索MP3特定文件夹的歌词. [我从azlyrics.com
得到歌词]

到目前为止,除了将歌词实际嵌入“歌词”标签中之外,我已经成功完成了所有操作.

您回答了一个有关从here的标签中读取歌词的问题.

我想知道您是否可以帮助我设置歌词.这是我的代码.

import urllib2 # For downloading webpage
import time # For pausing
import eyed3 # For MP3s
import re # For replacing characters
import os # For reading folders


path = raw_input('Please enter folder of music') # TODO Must make GUI PATH SELECTION


files = os.listdir(path) 
for x in files:
    # Must make the program stop for a while to minimize server load
    time.sleep(3)
    # Opening MP3
    mp3 = eyed3.load(path + '/' + x)
    # Setting Values
    artist = mp3.tag.artist.lower()
    raw_song = str(mp3.tag.title).lower()
    song = re.sub('[^0-9a-zA-Z]+', '', raw_song) #Stripping songs of anything other than alpha-numeric characters
    # Generating A-Z Lyrics URL
    url = "http://www.azlyrics.com/lyrics/" + artist + "/" + song + ".html"
    # Getting Source and extracting lyrics
    text = urllib2.urlopen(url).read()
    where_start = text.find('<!-- start of lyrics -->')
    start = where_start + 26
    where_end = text.find('<!-- end of lyrics -->')
    end = where_end - 2
    lyrics = unicode(text[start:end].replace('<br />', ''), "UTF8")
    # Setting Lyrics to the ID3 "lyrics" tag
    mp3.tag.lyrics = lyrics ### RUNNING INTO PROBLEMS HERE
    mp3.tag.save()

执行倒数第二行后,我遇到以下错误:-

Traceback (most recent call last):
File "<pyshell#62>", line 31, in <module>
mp3.tag.lyrics = lyrics
AttributeError: can't set attribute

我也想让您知道我今年15岁,已经学习Python大约一年了.我到处搜索并尝试了所有内容,但我想我现在需要一些帮助.

预先感谢您的所有帮助!

解决方法:

chcp 65001

eyeD3-编码utf8 –add-lyrics“ 001-001.txt” 001-001.mp3

上一篇:C#-将两个mp3音频文件合并为一个


下一篇:stm32 mp3软件音频解码案例分析流程(一)