我正在尝试利用Wordpress'3.6对getID3()的支持,但我在编写ID3标签时遇到麻烦。这是我正在使用的代码:
if ( ! class_exists( 'getID3' ) ) {
require(ABSPATH.WPINC.'/ID3/getid3.php' );
}
# I had to custom install the write library because WP doesn't include it by default, evidently
getid3_lib::IncludeDependency(TEMPLATEPATH.'/lib/getid3/write.php', __FILE__);
$testfile = "/Users/jplew/Sites/dev.example.com/content/uploads/mp3.mp3";
$tagwriter = new getid3_writetags;
$tagwriter->filename = $testfile;
$tagwriter->tagformats = array('id3v2.4');
$TagData['title'][] = 'My Heart Will Go On';
$TagData['artist'][] = 'Celine Dion';
$TagData['genre'][] = '90s Classics';
$tagwriter->tag_data = $TagData;
if ($tagwriter->WriteTags()) {
echo 'success';
} else {
echo 'failure';
}
我一直在'失败'。 getid3_writetags
函数的路径很好。我知道这一点,因为当我print_r($tagwriter);
时,它会按照指定输出所有数组。然而,'warnings'和'errors'数组都是空的。
此外,当我执行以下操作时,它会成功返回所有正确的标记信息:
$data = $getid3->analyze( $testfile );
print_r($data)
我还应该注意,演示中包含的demo.write.php
在运行时也会失败。它会到starting to write tag(s)
然后停止。
有什么想法吗?我将在getid3.org论坛上发帖,但我的IP被列入黑名单。 :(
答案 0 :(得分:1)
Wordpress在实施时不包含整个GetID3库。他们只使用这些文件来获取最流行的视频和音频标签。