Ejemplo n.º 1
0
 def __init__(self):
     super(CustomWrite, self).__init__()
     self.register_listener('write', self.loaded)
     self.register_listener('import_task_apply', self.choice)
     field = mediafile.MediaField(
         mediafile.MP3DescStorageStyle(u'customwrite'),
         mediafile.StorageStyle(u'customwrite'))
     self.add_media_field('customwrite', field)
 def __init__(self):
     super(RecordingDatePlugin, self).__init__()
     for recording_field in (u'recording_year', u'recording_month',
                             u'recording_day', u'recording_disambiguation'):
         field = mediafile.MediaField(
             mediafile.MP3DescStorageStyle(recording_field),
             mediafile.MP4StorageStyle(
                 '----:com.apple.iTunes:{}'.format(recording_field)),
             mediafile.StorageStyle(recording_field))
         self.add_media_field(recording_field, field)
Ejemplo n.º 3
0
    def __init__(self):
        super(UserRatingsPlugin, self).__init__()

        self.config.add({
            # Should we automatically import any values we find?
            'auto': True,
            # Should we overwrite an existing entry?
            'overwrite': False,
            # Should we sync others player ratings when updating a rating
            'sync_ratings': True
        })

        # Add importing ratings to the import process
        if self.config['auto']:
            self.import_stages = [self.imported]

        # Given the complexity of the storage style implementations, I
        # find it handy to allow them to do unified logging.
        userrating_field = mediafile.MediaField(
            MP3UserRatingStorageStyle(_log=self._log, _is_external=False),
            UserRatingStorageStyle(_log=self._log, _is_external=False),
            ASFRatingStorageStyle(_log=self._log, _is_external=False),
            out_type=int
        )

        externalrating_field = mediafile.MediaField(
            MP3UserRatingStorageStyle(_log=self._log, _is_external=True),
            UserRatingStorageStyle(_log=self._log, _is_external=True),
            ASFRatingStorageStyle(_log=self._log, _is_external=True),
            out_type=int
        )

        if 'userrating' not in mediafile.MediaFile.__dict__:
            self.add_media_field('userrating', userrating_field)

        # this is only to be able to import existing value to beet userrating
        # and export/sync updated values.
        if 'externalrating' not in mediafile.MediaFile.__dict__:
            self.add_media_field('externalrating', externalrating_field)
    def __init__(self):
        super(DiscogsData, self).__init__()
        self.item_types = {'performer': types.STRING}

        self.discogs_client = discogs_client.Client(
            'github.com/SimonPersson/beets-plugins/0.1',
            user_token=self.config['token'].get())
        self.separator = self.config['separator'].get()
        self.register_listener('album_imported', self.album_imported)
        try:
            self.add_media_field(
                'performer',
                mediafile.MediaField(mediafile.StorageStyle('PERFORMER')))
        except Exception:
            pass
        discogs_extra_init.func = self.all_album_init
Ejemplo n.º 5
0
 def __init__(self):
   super(VTAlbumArtist, self).__init__()
   
   self.albumartist = None
   self.should_set = False
   
   self.register_listener('import_task_choice', self._import_after_apply)
   self.register_listener('write', self._before_write)
   
   field = mediafile.MediaField(
       mediafile.MP3DescStorageStyle(u'VT Album Artist'),
       mediafile.MP4StorageStyle(u'----:com.apple.iTunes:VT Album Artist'),
       mediafile.ASFStorageStyle(u'VT/Album Artist'),
       mediafile.StorageStyle(u'VT_ALBUMARTIST')
   )
   self.add_media_field('vt_albumartist', field)
Ejemplo n.º 6
0
 def __init__(self):
     super(DiscogsPlugin, self).__init__()
     self.config.add({
         'apikey': 'rAzVUQYRaoFjeBjyWuWZ',
         'apisecret': 'plxtUTqoCzwxZpqdPysCwGuBSmZNdZVy',
         'tokenfile': 'discogs_token.json',
         'source_weight': 0.5,
         'user_token': '',
     })
     self.config['apikey'].redact = True
     self.config['apisecret'].redact = True
     self.config['user_token'].redact = True
     self.discogs_client = None
     self.register_listener('import_begin', self.setup)
     for style in [u'styleone', u'styletwo', u'stylethree']:
         field = mediafile.MediaField(mediafile.MP3DescStorageStyle(style),
                                      mediafile.StorageStyle(style))
         self.add_media_field(style, field)
Ejemplo n.º 7
0
 def test_overwrite_property(self):
     with self.assertRaises(ValueError) as cm:
         mediafile.MediaFile.add_field('artist', mediafile.MediaField())
     self.assertIn(u'property "artist" already exists',
                   six.text_type(cm.exception))
Ejemplo n.º 8
0
from __future__ import division, absolute_import, print_function

import os
import six
import shutil
import unittest

from test import _common
from beets.library import Item
from beets import mediafile
from beets.plugins import BeetsPlugin
from beets.util import bytestring_path

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


class ExtendedFieldTestMixin(_common.TestCase):
    def _mediafile_fixture(self, name, extension='mp3'):
        name = bytestring_path(name + '.' + extension)
        src = os.path.join(_common.RSRC, name)
        target = os.path.join(self.temp_dir, name)
        shutil.copy(src, target)
        return mediafile.MediaFile(target)

    def test_extended_field_write(self):
        plugin = BeetsPlugin()
        plugin.add_media_field('customtag', field_extension)
Ejemplo n.º 9
0
 def __init__(self):
     super(EventPlugin, self).__init__()
     event = mediafile.MediaField(mediafile.MP3DescStorageStyle(u'EVENT'),
                                  mediafile.StorageStyle('EVENT'))
     self.add_media_field('event', event)