id3v2标记的解析器和序列化器

id3parse的Python项目详细描述


python 3的id3解析器和序列化程序。

示例用法

从头开始创建id3标记

输入:

from id3parse import ID3, ID3TextFrame

id3 = ID3.from_scratch()

id3.add_frame(ID3TextFrame.from_scratch('TIT2', 'Why Don\'t You Get A Job?'))
id3.add_frame(ID3TextFrame.from_scratch('TPE1', 'The Offspring'))

print(id3.serialize())

输出:

b'ID3\x04\x00\x00\x00\x00\x00=TIT2\x00\x00\x00\x1a\x00\x00\x03Why Don\'t You Get A Job?\x00TPE1\x00\x00\x00\x0f\x00\x00\x03The Offspring\x00'

分析id3标记

输入:

from id3parse import ID3

id3 = ID3.from_byte_array(b'ID3\x04\x00\x00\x00\x00\x00=TIT2\x00\x00\x00\x1a\x00\x00\x03Why Don\'t You Get A Job?\x00TPE1\x00\x00\x00\x0f\x00\x00\x03The Offspring\x00')

for f in id3.frames:
    print(f)

输出:

TIT2: Why Don't You Get A Job?
TPE1: The Offspring

加载和保存id3标签

from id3parse import ID3, ID3TextFrame

id3 = ID3.from_file('01 - The Offspring - Why Dont You Get A Job.mp3')

id3.add_frame(ID3TextFrame.from_scratch('TPE1', 'The Offspring'))
id3.add_frame(ID3TextFrame.from_scratch('TIT2', 'Why Don\'t You Get A Job?'))

id3.to_file()

查询帧

from id3parse import ID3, ID3TextFrame

id3 = ID3.from_file('01 - The Offspring - Why Dont You Get A Job.mp3')

tpe1 = id3.find_frame_by_name('TPE1')    # Returns a frame, fails if more than one
tpe1.text = 'The Offspring'              # frame with this name is available

privs = id3.find_frames_by_name('PRIV')  # Returns a list of frames
for priv in privs:
    print(priv)

id3.to_file()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
IE中的java跨域cookie问题   重复java中已经满足的循环   编译java RMI服务器时出错   JavaServlet POST中作为参数传递的javascript大型JSON数组数据为空   java片段未每次刷新/调用   java无法编译。错误消息   java如何构造大型类?   java Hibernate:TableThingsDB。事情并不存在   java如何操作从匹配项创建的数组。发现   循环以搜索和显示数组Java的某些部分   加载或注册SQLite JDBC驱动程序时出现java问题   活动和服务之间的java连接   JavaGWTG2D:ie8中的drawImage   java在安卓中设置hessian阈值   在Tomcat中使用Logback时发生java错误