How to use the mediafile.MediaFile.fields function in mediafile

To help you get started, we’ve selected a few mediafile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beetbox / mediafile / test / test_mediafile.py View on Github external
def test_properties_from_fields(self):
        path = os.path.join(_common.RSRC, b'full.mp3')
        mediafile = MediaFile(path)
        for field in MediaFile.fields():
            self.assertTrue(hasattr(mediafile, field))
github beetbox / mediafile / test / test_mediafile_edge.py View on Github external
def setUp(self):
        self.create_temp_dir()
        self.key = "READ_ONLY_TEST"
        self.field = mediafile.MediaField(
            mediafile.MP3StorageStyle(self.key, read_only=True),
            mediafile.MP4StorageStyle(
                "----:com.apple.iTunes:" + self.key, read_only=True),
            mediafile.StorageStyle(self.key, read_only=True),
            mediafile.ASFStorageStyle(self.key, read_only=True),
        )

        if "read_only_test" not in mediafile.MediaFile.fields():
            mediafile.MediaFile.add_field("read_only_test", self.field)
github beetbox / mediafile / test / test_mediafile.py View on Github external
def test_fields_in_readable_fields(self):
        readable = MediaFile.readable_fields()
        for field in MediaFile.fields():
            self.assertIn(field, readable)
github beetbox / mediafile / test / test_mediafile.py View on Github external
def test_known_fields(self):
        fields = list(ReadWriteTestBase.tag_fields)
        fields.extend(('encoder', 'images', 'genres', 'albumtype'))
        assertCountEqual(self, MediaFile.fields(), fields)
github beetbox / beets / beets / library.py View on Github external
def __setitem__(self, key, value):
        """Set the item's value for a standard field or a flexattr.
        """
        # Encode unicode paths and read buffers.
        if key == 'path':
            if isinstance(value, six.text_type):
                value = bytestring_path(value)
            elif isinstance(value, BLOB_TYPE):
                value = bytes(value)

        changed = super(Item, self)._setitem(key, value)

        if changed and key in MediaFile.fields():
            self.mtime = 0  # Reset mtime on dirty.
github beetbox / beets / beetsplug / bpd / __init__.py View on Github external
VOLUME_MAX = 100

SAFE_COMMANDS = (
    # Commands that are available when unauthenticated.
    u'close', u'commands', u'notcommands', u'password', u'ping',
)

# List of subsystems/events used by the `idle` command.
SUBSYSTEMS = [
    u'update', u'player', u'mixer', u'options', u'playlist', u'database',
    # Related to unsupported commands:
    u'stored_playlist', u'output', u'subscription', u'sticker', u'message',
    u'partition',
]

ITEM_KEYS_WRITABLE = set(MediaFile.fields()).intersection(Item._fields.keys())


# Gstreamer import error.
class NoGstreamerError(Exception):
    pass


# Error-handling, exceptions, parameter parsing.

class BPDError(Exception):
    """An error that should be exposed to the client to the BPD
    server.
    """
    def __init__(self, code, message, cmd_name='', index=0):
        self.code = code
        self.message = message
github beetbox / beets / beets / library.py View on Github external
'album', 'albumartist', 'genre')

    _types = {
        'data_source': types.STRING,
    }

    _media_fields = set(MediaFile.readable_fields()) \
        .intersection(_fields.keys())
    """Set of item fields that are backed by `MediaFile` fields.

    Any kind of field (fixed, flexible, and computed) may be a media
    field. Only these fields are read from disk in `read` and written in
    `write`.
    """

    _media_tag_fields = set(MediaFile.fields()).intersection(_fields.keys())
    """Set of item fields that are backed by *writable* `MediaFile` tag
    fields.

    This excludes fields that represent audio data, such as `bitrate` or
    `length`.
    """

    _formatter = FormattedItemMapping

    _sorts = {'artist': SmartArtistSort}

    _format_config_key = 'format_item'

    @classmethod
    def _getters(cls):
        getters = plugins.item_field_getters()