我在理解 V2 ID3 标签的格式时遇到一点困难。我只想获取 MP3 文件的“流派”ID3 标签,但 id3v2 实用程序返回的信息比我需要的多,而且我不明白这些数据代表什么。
例如,我正在使用以下 bash 代码:
id3v2 -l "$FILE" | grep -i "content type"
返回的内容如下:
TCON(内容类型):Jazz (8)
我真的只是想知道我是否可以安全地假设这将永远是格式,因此我可以安全地执行以下操作吗?:
id3v2 -l "$FILE" | grep -i "content type" | sed "s/^.*: //" | sed "s/ (.*$//"
(这将导致“爵士乐”。)
我正在尝试找到获取 ID3“流派”标签的最佳方法。非常感谢您的任何建议。
最佳答案
我认为假设该行将以 TCON 为前缀是安全的,所以我宁愿搜索它(这也将是 i18n 安全的)。
id3v2 -l "$FILE" | sed -n '/^TCON/s/^.*: //p' | sed 's/ (.*//'
(不需要运行grep)
来自/usr/share/doc/id3lib-3.8.3/doc/id3v2.3.0.txt
TCON
The 'Content type', which previously was stored as a one byte numeric value only, is now a numeric string. You may use one or several of the types as ID3v1.1 did or, since the category list would be impossible to maintain with accurate and up to date categories, define your own.
References to the ID3v1 genres can be made by, as first byte, enter "(" followed by a number from the genres list (appendix A.) and ended with a ")" character. This is optionally followed by a refinement, e.g. "(21)" or "(4)Eurodisco". Several references can be made in the same frame, e.g. "(51)(39)". If the refinement should begin with a "(" character it should be replaced with "((", e.g. "((I can figure out any genre)" or "(55)((I think...)". The following new content types is defined in ID3v2 and is implemented in the same way as the numerig content types, e.g. "(RX)".
RX Remix CR Cover
关于bash - 使用 id3v2 获取 MP3 ID3 (V2) 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5285838/