def __init__(self, *args, **kwargs):
        super(CanonicalPlugin, self).__init__(*args, **kwargs)
        self.config.add({
            'artist_credit': False,
            'albumartist_credit': False,
            'original_date': False,
            'album_disambig': False
        })
        self.register_listener('album_imported', self.album_imported)
        self.register_listener('write', self.write)

        for field in self.artists_fields:
            canonical = field + u'_canonical'
            canonical_desc = ' '.join(s.capitalize()
                                      for s in canonical.split(u'_'))
            media_field = mediafile.MediaField(
                mediafile.MP3DescStorageStyle(canonical_desc),
                mediafile.MP4StorageStyle(
                    u"----:com.apple.iTunes:{}".format(canonical_desc)),
                mediafile.StorageStyle(canonical.upper()),
                mediafile.ASFStorageStyle('beets/{}'.format(canonical_desc)),
            )
            self.add_media_field(canonical, media_field)
        date_canonical = mediafile.DateField(
            mediafile.MP3DescStorageStyle(u'Date Canonical'),
            mediafile.MP4StorageStyle('----:com.apple.iTunes:Date Canonical'),
            mediafile.StorageStyle('DATE_CANONICAL'),
            mediafile.ASFStorageStyle('WM/Date Canonical'))
        for df in ('year', 'month', 'day'):
            self.add_media_field(
                '{}_canonical'.format(df),
                getattr(date_canonical, '{}_field'.format(df))())
Beispiel #2
0
    def __init__(self, *args, **kwargs):
        album_sort_field = mediafile.MediaField(
            mediafile.MP3StorageStyle(u"TSOA"),
            mediafile.MP4StorageStyle(u"soal"),
            mediafile.StorageStyle(u"Album Sort")
        )
        self.add_media_field("album_sort", album_sort_field)

        self.register_listener("write", self.write)

        super().__init__(*args, **kwargs)
    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)
Beispiel #4
0
    def __init__(self):
        super(iTunesAdvisoryPlugin, self).__init__()

        self.config.add({
            'auto': True,
        })

        field = mediafile.MediaField(
            mediafile.MP3DescStorageStyle(u'ITUNESADVISORY'),
            mediafile.MP4StorageStyle(u'rtng'),
            mediafile.StorageStyle(u'ITUNESADVISORY'),
            mediafile.ASFStorageStyle(u'ITUNESADVISORY'),
            out_type=int,
        )
        mediafile.MediaFile.add_field('itunesadvisory', field)

        if self.config['auto'].get():
            self.import_stages = [self.imported]
Beispiel #5
0
    def __init__(self):
        super(OldestDatePlugin, self).__init__()
        self.import_stages = [self._on_import]
        self.config.add({
            'auto': True,  # Run during import phase
            'ignore_track_id': False,  # During import, ignore existing track_id
            'filter_on_import': True,  # During import, weight down candidates with no work_id
            'prompt_missing_work_id': True,  # During import, prompt to fix work_id if missing
            'force': False,  # Run even if already processed
            'overwrite_year': False,  # Overwrite year field in tags
            'filter_recordings': True,  # Skip recordings with attributes before fetching them
            'approach': 'releases',  # recordings, releases, hybrid, both
            'release_types': None,  # Filter by release type, e.g. ['Official']
            'use_file_date': False  # Also use file's embedded date when looking for oldest date
        })

        if self.config['ignore_track_id']:
            self.register_listener('import_task_created', self._import_task_created)
        if self.config['prompt_missing_work_id']:
            self.register_listener('import_task_choice', self._import_task_choice)
        if self.config['filter_on_import']:
            self.register_listener('trackinfo_received', self._import_trackinfo)
            # Add heavy weight for missing work_id from a track
            config['match']['distance_weights'].add({'work_id': 4})

        # Get global MusicBrainz host setting
        musicbrainzngs.set_hostname(config['musicbrainz']['host'].get())
        musicbrainzngs.set_rate_limit(1, config['musicbrainz']['ratelimit'].get())

        for recording_field in (
                'recording_year',
                'recording_month',
                'recording_day',
                '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)
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
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()