Skip to main content

tagfiles

CI codecov Pypi Pyversions

A tagging interface for multiple audio formats and metadata containers.

The supported audio codecs and containers are:

  • FLAC in FLAC container
  • MP3 in MP3 container
  • AAC in MP4 container
  • Vorbis in Ogg container
  • Opus in Ogg container

Tag mappings are derived from https://picard.musicbrainz.org/docs/mappings/ .

Usage

>>> from tagfiles import TagFile, ArtistRoles
>>> from pprint import pprint
>>>
>>> tf = TagFile('/home/azuline/02. No Captain.m4a')
>>> print(tf.title)
No Captain
>>> pprint(tf.artist)
{<ArtistRoles.MAIN: 1>: ['Lane 8'],
 <ArtistRoles.FEATURE: 2>: ['Poliça'],
 <ArtistRoles.REMIXER: 3>: [],
 <ArtistRoles.PRODUCER: 4>: [],
 <ArtistRoles.COMPOSER: 5>: [''],
 <ArtistRoles.CONDUCTOR: 6>: [],
 <ArtistRoles.DJMIXER: 7>: []}
>>> print(tf.artist[ArtistRoles.MAIN])
['Lane 8']
>>> print(tf.date.year)
2015
>>> print(tf.date.date)
2015-01-19
>>>
>>> tf.date = '2018-01-19'  # Fixing the date!
>>> print(tf.date.date)
2018-01-19
>>> print(tf.date.year)
2018
>>> tf.save()
>>>
>>> tf = TagFile('/home/azuline/music.txt')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/azuline/devel/tagfiles/tagfiles/__init__.py", line 27, in TagFile
    raise UnsupportedFileType
tagfiles.errors.UnsupportedFileType

The TagFile function takes a filepath as a parameter and returns the class which corresponds to its container. If an unsupported filetype is passed in, the UnsupportedFileType error is raised. Each class presents the same metadata interface, which have the following attributes:

title: str
version: str
album: str
artist_album: List[str]
catalog_number: str
release_type: str
comment: str
date.year: int
date.date: str
track_number: str
track_total: str
disc_number: str
disc_total: str
genre: List[str]
label: str
artist = {
  ArtistRoles.MAIN: List[str]
  ArtistRoles.FEATURE: List[str]
  ArtistRoles.REMIXER: List[str]
  ArtistRoles.PRODUCER: List[str]
  ArtistRoles.COMPOSER: List[str]
  ArtistRoles.CONDUCTOR: List[str]
  ArtistRoles.DJMIXER: List[str]
}
image_mime: str
image: bytes

Fields can be edited by setting new values to the attributes of the TagFile. To edit the date, which is special, assign a string in the format of %Y-%m-%d or %Y to the date attribute. To save the changes made to the tags, call the save() method.

Note: Image field is not currently editable.

Metadata

Release files for tagfiles 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tagfiles 0.3.3
File Size Uploaded
tagfiles-0.3.3.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tagfiles 0.3.3
File Interpreter ABI Platform
tagfiles-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 25.4 kB

Release files / tagfiles-0.3.3.tar.gz

Download URL tagfiles-0.3.3.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
71e3da97b61ec2f6e2e07341ed107f38dd34514cd72542f24d7307cb60432245
BLAKE2b-256 checksum
How to use checksums
21d183e0cb33754bfcd034c428fe6305941d902a433b98e80646b2504b89c79c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Linux/5.10.7-1-default

Release files / tagfiles-0.3.3-py3-none-any.whl

Download URL tagfiles-0.3.3-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cac070795466923ab755a6924644bb74f2e18851f3787ab314f27541bfb9384f
BLAKE2b-256 checksum
How to use checksums
951c57ce8d8e30231eff25b51f77f21474521376052bb9045d24736ff7c85aa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Linux/5.10.7-1-default

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page