Created
April 3, 2012 16:13
-
-
Save intijk/2293266 to your computer and use it in GitHub Desktop.
方便你添加id3信息的一个脚本,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.7 | |
#encoding=utf8 | |
#Usage example : ./fillid3 run.mp3 | |
#This tool aim to tackle id3 v1 tags, v1 only support ISO-8859-1 encoding! | |
#Want other language support, convert to id3 v2 format. | |
from mutagen.mp3 import MP3 | |
from mutagen.id3 import ID3, TRCK, TIT2, TPE1, TALB, TDRC, TCON, COMM | |
from mutagen.easyid3 import EasyID3 | |
import sys | |
if len(sys.argv)<2: | |
sys.exit('Usage: {0} musicFile'.format(sys.argv[0])); | |
print("Modify file:\n" + sys.argv[1]) | |
audio=ID3(sys.argv[1]) | |
if "TIT2" not in audio: | |
audio.add(TIT2(encoding=3, text=u"Unknown"))#标题 | |
if "TPE1" not in audio: | |
audio.add(TPE1(encoding=3, text=u"Unknown"))#艺术家 | |
if "TALB" not in audio: | |
audio.add(TALB(encoding=3, text=u"Unknown"))#专辑 | |
audio.save() | |
#audio.add(TRCK(encoding=3, text=u"Unknown"))#年份 | |
#audio.add(TDRC(encoding=3, text=u"Unknown"))#年份 | |
#audio.add(TCON(encoding=3, text=u"Unknown"))#流派 | |
#audio.add(COMM(encoding=3, text=u"Unknown"))#评论 | |
audio = EasyID3(sys.argv[1]) | |
#Title | |
print("") | |
print("Title:") | |
print('Current: {0}'.format(audio["title"])) | |
mtitle=raw_input("") | |
if len(mtitle)>0: | |
audio["title"]=mtitle | |
#Artist | |
print('Artist:') | |
print('Current: {0}'.format(audio["artist"])) | |
martist=raw_input("") | |
if len(martist)>0: | |
audio["artist"]=martist | |
#Album | |
print('Album') | |
malbum="" | |
print('Current: {0}'.format(audio["album"])) | |
malbum=raw_input("") | |
if len(malbum)>0: | |
audio["album"]=malbum | |
#Save | |
audio.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently only support ASCII encoding characters.