Is there a Perl or Python library for ID3 metadata

2020-02-26 03:20发布

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.

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?

标签: python perl id3
7条回答
仙女界的扛把子
2楼-- · 2020-02-26 03:50

I've had good luck with MP3::Info.

一纸荒年 Trace。
3楼-- · 2020-02-26 03:51

CPAN Search turns up several Perl modules when you search for ID3. The answer to almost any Perl question that starts with "Is there a library..." is to check CPAN.

I tend to like MP3::Tag, but old people like me tend to find something suitable and ignore all advances in technology until we are forced to change.

你好瞎i
4楼-- · 2020-02-26 03:52

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
查看更多
等我变得足够好
7楼-- · 2020-02-26 04:09

The Python Package Index has a list of python packages matching a search for 'id3' here, the top several of which appear to be related to your needs. As with brian's answer above, the answer to any "is there a python module that..." probably starts with PyPI.

登录 后发表回答