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

To help you get started, we’ve selected a few beets 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 / beets / test / test_mediafile_edge.py View on Github external
def _make_test(self, ext='mp3', id3v23=False):
        self.create_temp_dir()
        src = os.path.join(_common.RSRC, 'full.{0}'.format(ext))
        self.path = os.path.join(self.temp_dir, 'test.{0}'.format(ext))
        shutil.copy(src, self.path)
        return beets.mediafile.MediaFile(self.path, id3v23=id3v23)
github beetbox / beets / test / test_library.py View on Github external
def test_write_date_field(self):
        # Since `date` is not a MediaField, this should do nothing.
        item = self.add_item_fixture()
        clean_year = item.year
        item.date = u'foo'
        item.write()
        self.assertEqual(MediaFile(syspath(item.path)).year, clean_year)
github beetbox / beets / test / test_mediafile.py View on Github external
def test_delete_partial_date(self):
        mediafile = self._mediafile_fixture('empty')

        mediafile.date = datetime.date(2001, 12, 3)
        mediafile.save()
        mediafile = MediaFile(mediafile.path)
        self.assertIsNotNone(mediafile.date)
        self.assertIsNotNone(mediafile.year)
        self.assertIsNotNone(mediafile.month)
        self.assertIsNotNone(mediafile.day)

        delattr(mediafile, 'month')
        mediafile.save()
        mediafile = MediaFile(mediafile.path)
        self.assertIsNotNone(mediafile.date)
        self.assertIsNotNone(mediafile.year)
        self.assertIsNone(mediafile.month)
        self.assertIsNone(mediafile.day)
github beetbox / beets / test / test_mediafile_edge.py View on Github external
def test_unicode_label_in_m4a(self):
        self.mf.label = u'foo\xe8bar'
        self.mf.save()
        new_mf = beets.mediafile.MediaFile(self.path)
        self.assertEqual(new_mf.label, u'foo\xe8bar')
github beetbox / beets / test / test_mediafile.py View on Github external
def setUp(self):
        super(TypeTest, self).setUp()
        path = os.path.join(_common.RSRC, 'full.mp3')
        self.mf = beets.mediafile.MediaFile(path)
github beetbox / beets / test / test_mediafile.py View on Github external
def test_update_empty(self):
        mediafile = self._mediafile_fixture('empty')
        tags = self._generate_tags()

        mediafile.update(tags)
        mediafile.save()

        mediafile = MediaFile(mediafile.path)
        self.assertTags(mediafile, tags)
github beetbox / beets / beets / art.py View on Github external
def get_art(log, item):
    # Extract the art.
    try:
        mf = mediafile.MediaFile(syspath(item.path))
    except mediafile.UnreadableFileError as exc:
        log.warning(u'Could not extract art from {0}: {1}',
                    displayable_path(item.path), exc)
        return

    return mf.art
github clinton-hall / nzbToMedia / libs / beetsplug / zero.py View on Github external
def validate_config(self, mode):
        """Check whether fields in the configuration are valid.

        `mode` should either be "fields" or "keep_fields", indicating
        the section of the configuration to validate.
        """
        for field in self.config[mode].as_str_seq():
            if field not in MediaFile.fields():
                self._log.error(u'invalid field: {0}', field)
                continue
            if mode == 'fields' and field in ('id', 'path', 'album_id'):
                self._log.warn(u'field \'{0}\' ignored, zeroing '
                               u'it would be dangerous', field)
                continue
github clinton-hall / nzbToMedia / libs / beetsplug / info.py View on Github external
def emitter():
        fields = list(mediafile.MediaFile.readable_fields())
        fields.remove('images')
        mf = mediafile.MediaFile(syspath(path))
        tags = {}
        for field in fields:
            tags[field] = getattr(mf, field)
        tags['art'] = mf.art is not None
        # create a temporary Item to take advantage of __format__
        item = Item.from_path(syspath(path))

        return tags, item
    return emitter