phrydy package

Module contents

Submodules

phrydy.doc module

phrydy.doc.fields = {'acoustid_fingerprint': {'category': 'music_brainz', 'description': 'Acoustic ID fingerprint'}, 'acoustid_id': {'category': 'music_brainz', 'description': 'Acoustic ID'}, 'album': {'category': 'ordinary', 'description': 'album'}, 'albumartist': {'category': 'ordinary', 'description': 'The artist for the entire album, which may be different from the artists for the individual tracks'}, 'albumartist_credit': {'category': 'ordinary', 'description': 'albumartist_credit'}, 'albumartist_sort': {'category': 'ordinary', 'description': 'albumartist_sort'}, 'albumdisambig': {'category': 'ordinary', 'description': 'albumdisambig'}, 'albumstatus': {'category': 'ordinary', 'description': 'The status describes how "official" a release is. Possible values are: official, promotional, bootleg, pseudo-release'}, 'albumtype': {'category': 'ordinary', 'description': 'The MusicBrainz album type; the MusicBrainz wiki has a list of type names'}, 'arranger': {'category': 'ordinary', 'description': 'arranger'}, 'art': {'category': 'ordinary', 'description': 'art'}, 'artist': {'category': 'ordinary', 'description': 'artist'}, 'artist_credit': {'category': 'ordinary', 'description': 'The track-specific artist credit name, which may be a variation of the artist’s “canonical” name'}, 'artist_sort': {'category': 'ordinary', 'description': 'The “sort name” of the track artist (e.g., “Beatles, The” or “White, Jack”)'}, 'asin': {'category': 'ordinary', 'description': 'Amazon Standard Identification Number'}, 'bitdepth': {'category': 'audio', 'description': 'only available for some formats'}, 'bitrate': {'category': 'audio', 'description': 'in kilobits per second, with units: e.g., “192kbps”'}, 'bpm': {'category': 'ordinary', 'description': 'bpm'}, 'catalognum': {'category': 'ordinary', 'description': 'This is a number assigned to the release by the label which can often be found on the spine or near the barcode. There may be more than one, especially when multiple labels are involved. This is not the ASIN — there is a relationship for that — nor the label code.'}, 'channels': {'category': 'audio', 'description': 'channels'}, 'comments': {'category': 'ordinary', 'description': 'comments'}, 'comp': {'category': 'ordinary', 'description': 'Compilation flag'}, 'composer': {'category': 'ordinary', 'description': 'composer'}, 'composer_sort': {'category': 'ordinary', 'description': 'Composer name for sorting.'}, 'country': {'category': 'ordinary', 'description': 'The country the release was issued in.'}, 'date': {'category': 'date', 'description': 'date'}, 'day': {'category': 'date', 'description': 'The release day of the specific release'}, 'disc': {'category': 'ordinary', 'description': 'disc'}, 'disctitle': {'category': 'ordinary', 'description': 'disctitle'}, 'disctotal': {'category': 'ordinary', 'description': 'disctotal'}, 'encoder': {'category': 'ordinary', 'description': 'encoder'}, 'format': {'category': 'audio', 'description': 'e.g., “MP3” or “FLAC”'}, 'genre': {'category': 'ordinary', 'description': 'genre'}, 'genres': {'category': 'ordinary', 'description': 'genres'}, 'grouping': {'category': 'ordinary', 'description': 'grouping'}, 'images': {'category': 'ordinary', 'description': 'images'}, 'initial_key': {'category': 'ordinary', 'description': 'initial_key'}, 'label': {'category': 'ordinary', 'description': 'The label which issued the release. There may be more than one.'}, 'language': {'category': 'ordinary', 'description': 'The language a release’s track list is written in. The possible values are taken from the ISO 639-3 standard.'}, 'length': {'category': 'audio', 'description': 'in seconds'}, 'lyricist': {'category': 'ordinary', 'description': 'lyricist'}, 'lyrics': {'category': 'ordinary', 'description': 'lyrics'}, 'mb_albumartistid': {'category': 'music_brainz', 'description': 'MusicBrainz album artist ID'}, 'mb_albumid': {'category': 'music_brainz', 'description': 'MusicBrainz album ID'}, 'mb_artistid': {'category': 'music_brainz', 'description': 'MusicBrainz artist ID'}, 'mb_releasegroupid': {'category': 'music_brainz', 'description': 'MusicBrainz releasegroup ID'}, 'mb_releasetrackid': {'category': 'music_brainz', 'description': 'MusicBrainz release track ID'}, 'mb_trackid': {'category': 'music_brainz', 'description': 'MusicBrainz track ID'}, 'mb_workhierarchy_ids': {'category': 'music_brainz', 'description': 'All IDs in the work hierarchy. This field corresponds to the field `work_hierarchy`. The top level work ID appears first. As separator a slash (/) is used.Example: e208c5f5-5d37-3dfc-ac0b-999f207c9e46 / 5adc213f-700a-4435-9e95-831ed720f348 / eafec51f-47c5-3c66-8c36-a524246c85f8'}, 'mb_workid': {'category': 'music_brainz', 'description': 'MusicBrainz work ID'}, 'media': {'category': 'ordinary', 'description': 'media'}, 'month': {'category': 'date', 'description': 'The release month of the specific release'}, 'original_date': {'category': 'date', 'description': 'original_date'}, 'original_day': {'category': 'date', 'description': 'The release day of the original version of the album'}, 'original_month': {'category': 'date', 'description': 'The release month of the original version of the album'}, 'original_year': {'category': 'date', 'description': 'The release year of the original version of the album'}, 'r128_album_gain': {'category': 'rg', 'description': 'An optional gain for album normalization'}, 'r128_track_gain': {'category': 'rg', 'description': 'An optional gain for track normalization'}, 'releasegroup_types': {'category': 'music_brainz', 'description': 'This field collects all items in the MusicBrainz’ API related to type: `type`, `primary-type and `secondary-type-list`. Main usage of this field is to determine in a secure manner if the release is a soundtrack.'}, 'rg_album_gain': {'category': 'rg', 'description': 'rg_album_gain'}, 'rg_album_peak': {'category': 'rg', 'description': 'rg_album_peak'}, 'rg_track_gain': {'category': 'rg', 'description': 'rg_track_gain'}, 'rg_track_peak': {'category': 'rg', 'description': 'rg_track_peak'}, 'samplerate': {'category': 'audio', 'description': 'in kilohertz, with units: e.g., “48kHz”'}, 'script': {'category': 'ordinary', 'description': 'The script used to write the release’s track list. The possible values are taken from the ISO 15924 standard.'}, 'title': {'category': 'ordinary', 'description': 'The title of a audio file.'}, 'track': {'category': 'ordinary', 'description': 'track'}, 'tracktotal': {'category': 'ordinary', 'description': 'tracktotal'}, 'work': {'category': 'ordinary', 'description': 'The Musicbrainzs’ work entity.'}, 'work_hierarchy': {'category': 'music_brainz', 'description': 'The hierarchy of works: The top level work appears first. As separator is this string used: -->. Example: Die Zauberflöte, K. 620 --> Die Zauberflöte, K. 620: Akt I --> Die Zauberflöte, K. 620: Act I, Scene II. No. 2 Aria "Was hör ...'}, 'year': {'category': 'date', 'description': 'The release year of the specific release'}}

A multidimensional dictionary documenting all metadata fields.

fields = {
    'field': {
        'description': 'Title',
        'category': 'Category',
    },
}
phrydy.doc.get_doc(additional_doc=False, field_prefix='$', field_suffix=':', indent=4)[source]

Return a formated string containing documentation about the audio fields.

phrydy.doc.get_max_field_length(fields)[source]

Get the length of the longest field in the dictionary fields.

Parameters:fields (dict) – A dictionary to search for the longest field.
phrydy.doc.merge_fields(*fields)[source]
phrydy.doc.print_debug(media_file, MediaClass, field_generator, color=False)[source]
phrydy.doc.print_dict_sorted(dictionary, color, align='right')[source]
phrydy.doc.print_section(text, color=False)[source]
phrydy.doc.fields = metadata description

A multidimensional dictionary documenting all metadata fields.

fields = {
    'field': {
        'description': 'Title',
        'category': 'Category',
    },
}

phrydy.mediafile module

This file originates from the file beets/mediafile.py of the beets project.

Handles low-level interfacing for files’ tags. Wraps Mutagen to automatically detect file types and provide a unified interface for a useful subset of music files’ tags.

Usage:

>>> f = MediaFile('Lucy.mp3')
>>> f.title
u'Lucy in the Sky with Diamonds'
>>> f.artist = 'The Beatles'
>>> f.save()

A field will always return a reasonable value of the correct type, even if no tag is present. If no value is available, the value will be false (e.g., zero or the empty string).

Internally MediaFile uses MediaField descriptors to access the data from the tags. In turn MediaField uses a number of StorageStyle strategies to handle format specific logic.

exception phrydy.mediafile.UnreadableFileError(path, msg)[source]

Bases: Exception

Mutagen is not able to extract information from the file.

exception phrydy.mediafile.FileTypeError(path, mutagen_type=None)[source]

Bases: phrydy.mediafile.UnreadableFileError

Reading this type of file is not supported.

If passed the mutagen_type argument this indicates that the mutagen type is not supported by Mediafile.

class phrydy.mediafile.MediaFile(path, id3v23=False)[source]

Bases: object

Represents a multimedia file on disk and provides access to its metadata.

classmethod _field_sort_name(name)[source]

Get a sort key for a field name that determines the order fields should be written in.

Fields names are kept unchanged, unless they are instances of DateItemField, in which case year, month, and day are replaced by date0, date1, and date2, respectively, to make them appear in that order.

acoustid_fingerprint

A descriptor providing access to a particular (abstract) metadata field.

acoustid_id

A descriptor providing access to a particular (abstract) metadata field.

classmethod add_field(name, descriptor)[source]

Add a field to store custom tags.

Parameters:
  • name – the name of the property the field is accessed through. It must not already exist on this class.
  • descriptor – an instance of MediaField.
album

A descriptor providing access to a particular (abstract) metadata field.

albumartist

A descriptor providing access to a particular (abstract) metadata field.

albumartist_credit

A descriptor providing access to a particular (abstract) metadata field.

albumartist_sort

A descriptor providing access to a particular (abstract) metadata field.

albumdisambig

A descriptor providing access to a particular (abstract) metadata field.

albumstatus

A descriptor providing access to a particular (abstract) metadata field.

albumtype

A descriptor providing access to a particular (abstract) metadata field.

arranger

A descriptor providing access to a particular (abstract) metadata field.

art

A descriptor that provides access to the raw image data for the cover image on a file. This is used for backwards compatibility: the full ImageListField provides richer Image objects.

When there are multiple images we try to pick the most likely to be a front cover.

artist

A descriptor providing access to a particular (abstract) metadata field.

artist_credit

A descriptor providing access to a particular (abstract) metadata field.

artist_sort

A descriptor providing access to a particular (abstract) metadata field.

asin

A descriptor providing access to a particular (abstract) metadata field.

bitdepth

The number of bits per sample in the audio encoding (an int). Only available for certain file formats (zero where unavailable).

bitrate

The number of bits per seconds used in the audio coding (an int). If this is provided explicitly by the compressed file format, this is a precise reflection of the encoding. Otherwise, it is estimated from the on-disk file size. In this case, some imprecision is possible because the file header is incorporated in the file size.

bpm

A descriptor providing access to a particular (abstract) metadata field.

catalognum

A descriptor providing access to a particular (abstract) metadata field.

channels

The number of channels in the audio (an int).

comments

A descriptor providing access to a particular (abstract) metadata field.

comp

A descriptor providing access to a particular (abstract) metadata field.

composer

A descriptor providing access to a particular (abstract) metadata field.

composer_sort

A descriptor providing access to a particular (abstract) metadata field.

country

A descriptor providing access to a particular (abstract) metadata field.

date

Descriptor that handles serializing and deserializing dates

The getter parses value from tags into a datetime.date instance and setter serializes such an instance into a string.

For granular access to year, month, and day, use the *_field methods to create corresponding DateItemField s.

day

Descriptor that gets and sets constituent parts of a DateField: the month, day, or year.

delete()[source]

Remove the current metadata tag from the file. May throw UnreadableFileError.

disc

A descriptor providing access to a particular (abstract) metadata field.

disctitle

A descriptor providing access to a particular (abstract) metadata field.

disctotal

A descriptor providing access to a particular (abstract) metadata field.

encoder

A descriptor providing access to a particular (abstract) metadata field.

classmethod fields()[source]

Get the names of all writable properties that reflect metadata tags (i.e., those that are instances of MediaField).

format

A string describing the file format/codec.

genre

A descriptor providing access to a particular (abstract) metadata field.

genres

Property descriptor that retrieves a list of multiple values from a tag.

Uses get_list and set_list`` methods of its StorageStyle strategies to do the actual work.

grouping

A descriptor providing access to a particular (abstract) metadata field.

images

Descriptor to access the list of images embedded in tags.

The getter returns a list of Image instances obtained from the tags. The setter accepts a list of Image instances to be written to the tags.

initial_key

A descriptor providing access to a particular (abstract) metadata field.

label

A descriptor providing access to a particular (abstract) metadata field.

language

A descriptor providing access to a particular (abstract) metadata field.

length

The duration of the audio in seconds (a float).

lyricist

A descriptor providing access to a particular (abstract) metadata field.

lyrics

A descriptor providing access to a particular (abstract) metadata field.

mb_albumartistid

A descriptor providing access to a particular (abstract) metadata field.

mb_albumid

A descriptor providing access to a particular (abstract) metadata field.

mb_artistid

A descriptor providing access to a particular (abstract) metadata field.

mb_releasegroupid

A descriptor providing access to a particular (abstract) metadata field.

mb_releasetrackid

A descriptor providing access to a particular (abstract) metadata field.

mb_trackid

A descriptor providing access to a particular (abstract) metadata field.

mb_workhierarchy_ids

All IDs in the work hierarchy. This field corresponds to the field work_hierarchy. The top level work ID appears first. As separator a slash (/) is used.

Example:

e208c5f5-5d37-3dfc-ac0b-999f207c9e46 / 5adc213f-700a-4435-9e95-831ed720f348 / eafec51f-47c5-3c66-8c36-a524246c85f8

mb_workid

The MusicBrainz’ Work ID

media

A descriptor providing access to a particular (abstract) metadata field.

month

Descriptor that gets and sets constituent parts of a DateField: the month, day, or year.

original_date

Descriptor that handles serializing and deserializing dates

The getter parses value from tags into a datetime.date instance and setter serializes such an instance into a string.

For granular access to year, month, and day, use the *_field methods to create corresponding DateItemField s.

original_day

Descriptor that gets and sets constituent parts of a DateField: the month, day, or year.

original_month

Descriptor that gets and sets constituent parts of a DateField: the month, day, or year.

original_year

Descriptor that gets and sets constituent parts of a DateField: the month, day, or year.

r128_album_gain

A descriptor providing access to a particular (abstract) metadata field.

r128_track_gain

A descriptor providing access to a particular (abstract) metadata field.

classmethod readable_fields()[source]

Get all metadata fields: the writable ones from fields() and also other audio properties.

releasegroup_types

This field collects all items in the MusicBrainz’ API related to type: type, primary-type and``secondary-type-list``. Main usage of this field is to determine in a secure manner if the release is a soundtrack.

"release-group": {
  "first-release-date": "1994-09-27",
  "secondary-type-list": [
    "Compilation",
    "Soundtrack"
  ],
  "primary-type": "Album",
  "title": "Pulp Fiction: Music From the Motion Picture",
  "type": "Soundtrack",
  "id": "1703cd63-9401-33c0-87c6-50c4ba2e0ba8"
}
rg_album_gain

A descriptor providing access to a particular (abstract) metadata field.

rg_album_peak

A descriptor providing access to a particular (abstract) metadata field.

rg_track_gain

A descriptor providing access to a particular (abstract) metadata field.

rg_track_peak

A descriptor providing access to a particular (abstract) metadata field.

samplerate

The audio’s sample rate (an int).

save()[source]

Write the object’s tags back to the file. May throw UnreadableFileError.

script

A descriptor providing access to a particular (abstract) metadata field.

classmethod sorted_fields()[source]

Get the names of all writable metadata fields, sorted in the order that they should be written.

This is a lexicographic order, except for instances of DateItemField, which are sorted in year-month-day order.

title

A descriptor providing access to a particular (abstract) metadata field.

track

A descriptor providing access to a particular (abstract) metadata field.

tracktotal

A descriptor providing access to a particular (abstract) metadata field.

update(dict)[source]

Set all field values from a dictionary.

For any key in dict that is also a field to store tags the method retrieves the corresponding value from dict and updates the MediaFile. If a key has the value None, the corresponding property is deleted from the MediaFile.

work

The last work in the work hierarchy.

work_hierarchy

The hierarchy of works: The top level work appears first. As separator is this string used: -->

Example:

Die Zauberflöte, K. 620 --> Die Zauberflöte, K. 620: Akt I --> Die Zauberflöte, K. 620: Act I, Scene II. No. 2 Aria "Was hör' ...

year

Descriptor that gets and sets constituent parts of a DateField: the month, day, or year.

phrydy.utils module

phrydy.utils._fsencoding()[source]

Get the system’s filesystem encoding. On Windows, this is always UTF-8 (not MBCS).

phrydy.utils.as_string(value)[source]

Convert a value to a Unicode object for matching with a query. None becomes the empty string. Bytestrings are silently decoded.

phrydy.utils.bytestring_path(path)[source]

Given a path, which is either a bytes or a unicode, returns a str path (ensuring that we never deal with Unicode pathnames).

phrydy.utils.displayable_path(path, separator='; ')[source]

Attempts to decode a bytestring path to a unicode object for the purpose of displaying it to the user. If the path argument is a list or a tuple, the elements are joined with separator.

phrydy.utils.syspath(path, prefix=True)[source]

Convert a path for use by the operating system. In particular, paths on Windows must receive a magic prefix and must be converted to Unicode before they are sent to the OS. To disable the magic prefix on Windows, set prefix to False—but only do this if you really know what you’re doing.