Exemplo n.º 1
0
 def __init__(self):
     super(SplitPlugin, self).__init__()
     separator = self.config['separator'].get()
     fields = self.config['fields'].get()
     for f in fields:
         setattr(MediaFile, f,
                 MediaField(HackedStorageStyle(f.upper(), separator)))
Exemplo n.º 2
0
 def test_overwrite_property(self):
     with self.assertRaises(ValueError) as cm:
         MediaFile.add_field('artist', MediaField())
     self.assertIn(u'property "artist" already exists',
                   unicode(cm.exception))
Exemplo n.º 3
0
        mediafile = MediaFile(mediafile.path)
        self.assertEqual(mediafile.genre, u'one')

    def test_append_genre_list(self):
        mediafile = self._mediafile_fixture('full')
        self.assertEqual(mediafile.genre, u'the genre')
        mediafile.genres += [u'another']
        mediafile.save()

        mediafile = MediaFile(mediafile.path)
        self.assertItemsEqual(mediafile.genres, [u'the genre', u'another'])


field_extension = MediaField(
    MP3DescStorageStyle(b'customtag'),
    MP4StorageStyle(b'----:com.apple.iTunes:customtag'),
    StorageStyle(b'customtag'),
    ASFStorageStyle(b'customtag'),
)


class ExtendedFieldTestMixin(object):
    def test_extended_field_write(self):
        plugin = BeetsPlugin()
        plugin.add_media_field('customtag', field_extension)

        mediafile = self._mediafile_fixture('empty')
        mediafile.customtag = u'F#'
        mediafile.save()

        mediafile = MediaFile(mediafile.path)
        self.assertEqual(mediafile.customtag, u'F#')