python 提取 mp3 信息

创建日期: 2024-01-09 15:17 | 作者: 风波 | 浏览次数: 17 | 分类: Python

方法1. 使用 eyed3

来源:https://www.codespeedy.com/access-mp3-metadata-in-python/

参考:https://stackoverflow.com/questions/69287671/how-to-get-a-custom-mp3-tag-via-python

安装 eyed3

pip install eyed3

提取 mp3 信息

import eyed3
audio=eyed3.load("Maacho.mp3")
print("Title:",audio.tag.title)
print("Artist:",audio.tag.artist)
print("Album:",audio.tag.album)
print("Album artist:",audio.tag.album_artist)
print("Composer:",audio.tag.composer)
print("Publisher:",audio.tag.publisher)

方法2. 使用 mutagen

来源:https://methodmatters.github.io/editing-id3-tags-mp3-meta-data-in-python/

安装 mutagen

pip install mutagen

提取信息

from mutagen.mp3 import MP3  
from mutagen.easyid3 import EasyID3  
import mutagen.id3  
from mutagen.id3 import ID3, TIT2, TIT3, TALB, TPE1, TRCK, TYER  

import glob  

import numpy as np  

# extract the file names (including folders)  
# for the mp3s in the album  
filez = glob.glob("/media/user/My Passport/ID3/1994 - Punk-O-Rama vol. 1/*.mp3")  
 # print the first element of filez:  
filez[0]  
17 浏览
12 爬虫
0 评论