python抽取数据库元数据_tinytag:一个用来读取文件音乐元数据的python库

tinytag

tinytag is a library for reading music meta data of MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave files with python

3f53f68289fb2c1a8cee9c76ff20ae91.png68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f773979326b673937383639673165646a3f7376673d747275657e48809f587ab1a568eec02036a493c8.png

Install

pip install tinytag

Features:

Read tags, length and IDv3 cover images of music files

supported formats

MP3 (ID3 v1, v1.1, v2.2, v2.3+)

Wave/RIFF

OGG

OPUS

FLAC

WMA

MP4/M4A/M4B

pure python

supports python 2.6+ and 3.2+

is tested

Just a few hundred lines of code (just include it in your project!)

tinytag only provides the minimum needed for reading MP3, OGG, OPUS, MP4, M4A, FLAC, WMA and Wave meta-data. It can determine track number, total tracks, title, artist, album, year, duration and more.

from tinytag import TinyTag

tag = TinyTag.get('/some/music.mp3')

print('This track is by %s.' % tag.artist)

print('It is %f seconds long.' % tag.duration)

List of possible attributes you can get with TinyTag:

tag.album # album as string

tag.albumartist # album artist as string

tag.artist # artist name as string

tag.audio_offset # number of bytes before audio data begins

tag.bitrate # bitrate in kBits/s

tag.comment # file comment as string

tag.composer # composer as string

tag.disc # disc number

tag.disc_total # the total number of discs

tag.duration # duration of the song in seconds

tag.filesize # file size in bytes

tag.genre # genre as string

tag.samplerate # samples per second

tag.title # title of the song

tag.track # track number as string

tag.track_total # total number of tracks as string

tag.year # year or data as string

Additionally you can also get cover images from ID3 tags:

tag = TinyTag.get('/some/music.mp3', image=True)

image_data = tag.get_image()

supported python versions:

2.7+

3.4+

pypy

and possibly more.

Changelog:

1.4.0 (2020-04-23):

detecting file types based on their magic header bytes, #85

fixed opus duration being wrong for files with lower sample rate #81

implemented support for binary paths #72

always cast mp3 bitrates to int, so that CBR and VBR output behaves the sam

made str deterministic and use json as output format

1.3.0 (2020-03-09):

added option to ignore encoding errors ignore_errors #73

Improved text decoding for many malformed files

1.2.2 (2019-04-13):

Improved stability when reading corrupted mp3 files

1.2.1 (2019-04-13):

fixed wav files not correctly reporting the number of channels #61

1.2.0 (2019-04-13):

using setup.cfg instead of setup.py (thanks to scivision)

added support for calling TinyTag.get with pathlib.Path (thanks to scivision)

added appveyor windows test CI (thanks to scivision)

using pytest instead of nosetest (thanks to scivision)

1.1.0 (2019-04-13):

added new field "composer" (Thanks to Phil Borman)

1.0.1 (2019-04-13):

fixed ID3 loading for files with corrupt header (thanks to Ian Homer)

fixed parsing of duration in wav file (thanks to Ian Homer)

1.0.0 (2018-12-12):

added comment field

added wav-riff format support

use MP4 parser for m4b files

added simple cli tool

fix parsing of FLAC files with ID3 header (thanks to minus7)

added method TinyTag.is_supported(filename)

0.19.0 (2018-02-11):

fixed corrupted images for some mp3s (#45)

0.18.0 (2017-04-29):

fixed wrong bitrate and crash when parsing xing header

0.17.0 (2016-10-02):

supporting ID3v2.2 images

0.16.0 (2016-08-06):

MP4 cover image support

0.15.2 (2016-08-06):

fixed crash for malformed MP4 files (#34)

0.15.0 (2016-08-06):

fixed decoding of UTF-16LE ID3v2 Tags, improved overall stability

0.14.0 (2016-06-05):

MP4/M4A and Opus support

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值