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第三方库


热门话题
java数据未插入SQLite数据库   Java中内存有效的对象创建   java在方法内部使用“this”(不用于调用方法、构造函数或变量)   java为什么这里会出现NullPointerException?   在REST中使用HATEOAS导致的java循环依赖   java如何定制spring boot横幅?   Java数字基数计算器(即基数10到基数5)   如果在Kotlin vs Java中声明,用作全局上下文的安卓 MainApplication类将崩溃   用于过滤对象的Java lambda函数   java从字符串数组中获取整数列表   java为什么Maven找不到org。json JPMS自动模块?   java将字符串数组转换为int   仅当与阈值字节匹配时,java才会在映射中填充字符串值