使用外部文本文件管理音频文件元数据
kantag的Python项目详细描述
简介
kantag是一组用于管理音频文件(flac, ogg vorbis、mp3和m4a)使用称为“kantag”的外部文本文件的元数据 文件”。无论音频文件类型如何,文件的格式都是相同的。 包含一个工具,用于从现有的标记、路径和 MusicBrainz数据,initkan;编写 音频文件标记的元数据,applykan;以及显示元数据的工具, showkan。典型的kantag文件的行看起来像 这个:
# Album / common track info a AlbumArtist=Rush a AlbumArtistSort=Rush a Album=2112 a Date=1976-03-12 a Composer=Geddy Lee a ComposerSort=Lee, Geddy t 01-05 Composer=Alex Lifeson t 01-05 ComposerSort=Lifeson, Alex t 01-03,06 Lyricist=Neil Peart t 01-03,06 LyricistSort=Peart, Neil t 01 Title=2112 t 01 Part=1. Overture t 01 Part=2. The Temples of Syrinx t 01 Part=3. Discovery t 01 Part=4. Presentation t 01 Part=5. Oracle: The Dream t 01 Part=6. Soliloquy t 01 Part=7. Grand Finale
典型用法
在典型的kantag工作流中,用户将拥有音频文件的相册, 是否从CD中翻录,从网上商店购买,从 或者其他来源。在大多数情况下,文件已经包含 元数据标记。MusicBrainz Picard是 建议您选择设置初始元数据,特别是对于已撕毁的文件 从物理媒体。工具initkan将为 一组音频文件:
$ initkan -v -b=y -M=y *.ogg > tags.kan
输出通常作为文件保存在音频所在的文件夹中 文件,如上面的示例所示。然后,文件可以由任何可用的 文本编辑器,满足用户的个人口味。注意,还有 由kantag工具识别的标记,这些工具不需要由 initkan。要将标记写回音频文件,请使用applykan:
$ applykan -v tags.kan *.ogg
安装
警告
一些linux发行版不鼓励安装系统级python 由于与 系统包管理器。在这些情况下,应该安装依赖项 如果可能,通过包管理器,或选择用户文件夹 安装方法。
使用pip
安装如果您的系统已安装pip,并且您有权在 系统包,然后kantagkan作为管理员从 PyPI:
# pip install kantag
如果您没有安装系统软件包的权限,或不希望安装 在系统位置,它可以安装在用户文件夹中:
$ pip install --user kantag
从源安装
或者从 Downloads页,和 打开包装:
$ tar zxvf kantag-1.1.0.tar.gz
或者从Mercurial存储库获取最新的源代码:
$ hg clone https://bitbucket.org/dgasaway/kantag
如果您有权在系统包中安装软件,则可以 以管理员身份安装:
# python setup.py install
如果您没有安装系统软件包的权限,或不希望安装 在系统位置,它可以安装在用户文件夹中:
$ python setup.py install --user
文件格式
总的来说,如果kantag文件包含任何非ascii字符,它应该是 无bom编码的utf-8。每一行按照下面的规则进行分析。 允许并忽略空行。
行格式
行的第一个字符表示行类型:
Char | Description |
---|---|
# | A comment line that will be ignored. |
a | A tag that will be applied to all files. |
d | A tag that will be applied to selected discs. |
t | A tag that will be applied to selected tracks. |
对于磁盘和磁道类型,接下来是一个空格,后面是磁盘/磁道列表 标签适用的数字。列表以逗号分隔,可以 包含由连字符表示的范围。一些示例:
Selector | Description |
---|---|
t 10 | Applies to track 10. |
d 2 | Applies to all tracks on disc 2. |
d 1-3 | Applies to all tracks on discs 1, 2, and 3. |
t 01,05-07,10 | Applies to tracks 1, 5, 6, 7, and 10. |
如果 音频文件名中填充了0号光盘或曲目。这也取决于 在设置中,--path-regex选项传递给applykan。默认情况下 在kantag文件和 在文件名中。此外,当使用多碟发行版时,曲目编号 应该在前面加上光盘号,如以下示例所示:
Selector | Description |
---|---|
t 101-103 | Applies to tracks 1 to 3 of disc 1. |
t 105,201-202 | Applies to track 5 of disc 1, and tracks 1 and 2 of disc 2. |
接下来是一个空格和由等号分隔的标记名/值对。 第一个等号之前的任何内容都将用作标记名,任何内容 在这条线的后面和最后是E值。把所有的东西放在一起,你 有这样的东西:
t 07 Composer=Jaromír Weinberger
不支持多行值。相反,使用多个 标签:
t 07 Comment=Work premièred in 1927. t 07 Comment=Known in English as "Švanda the Bagpiper" or "Schwanda the Bagpiper".