是否有用于 ID3 元数据的 Perl 或 Python 库? [英] Is there a Perl or Python library for ID3 metadata?

查看:57
本文介绍了是否有用于 ID3 元数据的 Perl 或 Python 库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我从我兄弟的 iPod 中提取了一堆音乐文件,这些文件保留了它们的元数据,但 iPod 似乎喜欢将它们存储在那些绝对可怕的四个字符名称下.我想我会写一个不错的、快速的脚本来按照我的意愿重命名它们,但我很好奇任何用于读取 ID3 元数据的好库.我更喜欢 Perl 或 Python.我对 Perl 很满意,因为我在工作中使用它,而 Python 我需要更多的练习,它会让我的 Python 布道者朋友们开心.

Basically, I've got a bunch of music files yoinked from my brother's iPod that retain their metadata but have those absolutely horrendous four character names the iPod seems to like storing them under. I figured I'd write a nice, quick script to just rename them as I wished, but I'm curious about any good libraries for reading ID3 metadata. I'd prefer either Perl or Python. I'm comfortable with Perl since I use it at work, whereas Python I need more practice in and it'll make my Python evangelist friends happy.

无论如何,缩短版本:你能为 Python 或 Perl 命名一个好的库/模块,让我可以轻松地从一堆 mp3 中提取 ID3 元数据吗?

Anyway, shortened version: Can you name a good library/module for either Python or Perl that will allow me to easily extract ID3 metadata from a pile of mp3s?

推荐答案

MP3::Tag 也很棒.同样,如果您正在寻找 Perl 模块,请先前往 search.cpan.org.

MP3::Tag is a also great. Again, if you are looking for a Perl module, head over to search.cpan.org first.

 use MP3::Tag;

  $mp3 = MP3::Tag->new($filename);

  # get some information about the file in the easiest way
  ($title, $track, $artist, $album, $comment, $year, $genre) = $mp3->autoinfo();
  # Or:
  $comment = $mp3->comment();
  $dedicated_to
    = $mp3->select_id3v2_frame_by_descr('COMM(fre,fra,eng,#0)[dedicated to]');

  $mp3->title_set('New title');         # Edit in-memory copy
  $mp3->select_id3v2_frame_by_descr('TALB', 'New album name'); # Edit in memory
  $mp3->select_id3v2_frame_by_descr('RBUF', $n1, $n2, $n3);    # Edit in memory
  $mp3->update_tags(year => 1866);      # Edit in-memory, and commit to file
  $mp3->update_tags();                  # Commit to file

这篇关于是否有用于 ID3 元数据的 Perl 或 Python 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆