Exemple #1
0
    def configure(self, config):
        wl_filename = ui.config_val(config, 'lastgenre', 'whitelist', None)
        if not wl_filename:
            # No filename specified. Instead, use the whitelist that's included
            # with the plugin (inside the package).
            wl_filename = DEFAULT_WHITELIST
        wl_filename = normpath(wl_filename)

        # Read the whitelist file.
        whitelist = set()
        with open(wl_filename) as f:
            for line in f:
                line = line.decode('utf8').strip().lower()
                if line:
                    whitelist.add(line)
        options['whitelist'] = whitelist

        # Read the genres tree for canonicalization if enabled.
        c14n_filename = ui.config_val(config, 'lastgenre', 'canonical', None)
        if c14n_filename is not None:
            c14n_filename = c14n_filename.strip()
            if not c14n_filename:
                c14n_filename = C14N_TREE
            c14n_filename = normpath(c14n_filename)

            from yaml import load
            genres_tree = load(open(c14n_filename, 'r'))
            branches = []
            flatten_tree(genres_tree, [], branches) 
            options['branches'] = branches 
            options['c14n'] = True
Exemple #2
0
 def configure(self, config):
     options['host'] = \
         ui.config_val(config, 'mpdupdate', 'host', 'localhost')
     options['port'] = \
         int(ui.config_val(config, 'mpdupdate', 'port', '6600'))
     options['password'] = \
         ui.config_val(config, 'mpdupdate', 'password', '')
Exemple #3
0
    def configure(self, config):
        wl_filename = ui.config_val(config, 'lastgenre', 'whitelist', None)
        if not wl_filename:
            # No filename specified. Instead, use the whitelist that's included
            # with the plugin (inside the package).
            wl_filename = DEFAULT_WHITELIST
        wl_filename = normpath(wl_filename)

        # Read the whitelist file.
        whitelist = set()
        with open(wl_filename) as f:
            for line in f:
                line = line.decode('utf8').strip().lower()
                if line:
                    whitelist.add(line)
        options['whitelist'] = whitelist

        # Read the genres tree for canonicalization if enabled.
        c14n_filename = ui.config_val(config, 'lastgenre', 'canonical', None)
        if c14n_filename is not None:
            c14n_filename = c14n_filename.strip()
            if not c14n_filename:
                c14n_filename = C14N_TREE
            c14n_filename = normpath(c14n_filename)

            from yaml import load
            genres_tree = load(open(c14n_filename, 'r'))
            branches = []
            flatten_tree(genres_tree, [], branches)
            options['branches'] = branches
            options['c14n'] = True
 def configure(self, config):
     global AUTOFETCH
     AUTOFETCH = ui.config_val(config, 'echonest_tempo', 'autofetch', True,
                               bool)
     apikey = ui.config_val(config, 'echonest_tempo', 'apikey',
                            ECHONEST_APIKEY)
     pyechonest.config.ECHO_NEST_API_KEY = apikey
Exemple #5
0
 def configure(self, config):
     global AUTOFETCH
     AUTOFETCH = ui.config_val(config, 'echonest_tempo', 'autofetch', True,
                               bool)
     apikey = ui.config_val(config, 'echonest_tempo', 'apikey',
                            ECHONEST_APIKEY)
     pyechonest.config.ECHO_NEST_API_KEY = apikey
Exemple #6
0
 def configure(self, config):
     if not config.has_section('the'):
         self._log.debug(u'[the] plugin is not configured, using defaults')
         return
     self.the = ui.config_val(config, 'the', 'the', True, bool)
     self.a = ui.config_val(config, 'the', 'a', True, bool)
     self.format = ui.config_val(config, 'the', 'format', FORMAT)
     self.strip = ui.config_val(config, 'the', 'strip', False, bool)
     self.patterns = ui.config_val(config, 'the', 'patterns', '').split()
     for p in self.patterns:
         if p:
             try:
                 re.compile(p)
             except re.error:
                 self._log.error(u'[the] invalid pattern: {0}'.format(p))
             else:
                 if not (p.startswith('^') or p.endswith('$')):
                     self._log.warn(u'[the] warning: \"{0}\" will not '
                                    'match string start/end'.format(p))
     if self.a:
         self.patterns = [PATTERN_A] + self.patterns
     if self.the:
         self.patterns = [PATTERN_THE] + self.patterns
     if not self.patterns:
         self._log.warn(u'[the] no patterns defined!')
Exemple #7
0
 def configure(self, config):
     global AUTOFETCH, _echonest_apikey
     AUTOFETCH = ui.config_val(config, 'echonest_tempo', 'autofetch', True,
                               bool)
     _echonest_apikey = ui.config_val(config, 'echonest_tempo', 'apikey',
                                      None)
     pyechonest.config.ECHO_NEST_API_KEY = _echonest_apikey
Exemple #8
0
 def configure(self, config):
     if not config.has_section('the'):
         self._log.debug(u'[the] plugin is not configured, using defaults')
         return
     self.the = ui.config_val(config, 'the', 'the', True, bool)
     self.a = ui.config_val(config, 'the', 'a', True, bool)
     self.format = ui.config_val(config, 'the', 'format', FORMAT)
     self.strip = ui.config_val(config, 'the', 'strip', False, bool)
     self.patterns = ui.config_val(config, 'the', 'patterns', '').split()
     for p in self.patterns:
         if p:
             try:
                 re.compile(p)
             except re.error:
                 self._log.error(u'[the] invalid pattern: {0}'.format(p))
             else:
                 if not (p.startswith('^') or p.endswith('$')):
                     self._log.warn(u'[the] warning: \"{0}\" will not '
                                    'match string start/end'.format(p))
     if self.a:
         self.patterns = [PATTERN_A] + self.patterns
     if self.the:
         self.patterns = [PATTERN_THE] + self.patterns
     if not self.patterns:
         self._log.warn(u'[the] no patterns defined!')
Exemple #9
0
 def configure(self, config):
     options['host'] = \
         ui.config_val(config, 'mpdupdate', 'host', 'localhost')
     options['port'] = \
         int(ui.config_val(config, 'mpdupdate', 'port', '6600'))
     options['password'] = \
         ui.config_val(config, 'mpdupdate', 'password', '')
Exemple #10
0
 def configure(self, config):
     self.autofetch = ui.config_val(config, 'fetchart', 'autofetch', True,
                                    bool)
     self.maxwidth = int(ui.config_val(config, 'fetchart', 'maxwidth', '0'))
     if self.autofetch:
         # Enable two import hooks when fetching is enabled.
         self.import_stages = [self.fetch_art]
         self.register_listener('import_task_files', self.assign_art)
Exemple #11
0
 def configure(self, config):
     self.ref_level = ui.config_val(config, 'replaygain',
                                    'reference_loundess',
                                    DEFAULT_REFERENCE_LOUDNESS, int)
     self.mp3_format = ui.config_val(config, 'replaygain', 'mp3_format',
                                     DEFAULT_MP3_FORMAT)
     self.overwrite = ui.config_val(config, 'replaygain', 'overwrite',
                                    False)
Exemple #12
0
def list_func(lib, config, opts, args):
    fmt = opts.format
    if not fmt:
        # If no format is specified, fall back to a default.
        if opts.album:
            fmt = ui.config_val(config, "beets", "list_format_album", DEFAULT_LIST_FORMAT_ALBUM)
        else:
            fmt = ui.config_val(config, "beets", "list_format_item", DEFAULT_LIST_FORMAT_ITEM)
    list_items(lib, decargs(args), opts.album, opts.path, fmt)
Exemple #13
0
 def configure(self, config):
     self.autofetch = ui.config_val(config, 'fetchart',
                                    'autofetch', True, bool)
     self.maxwidth = int(ui.config_val(config, 'fetchart',
                                       'maxwidth', '0'))
     if self.autofetch:
         # Enable two import hooks when fetching is enabled.
         self.import_stages = [self.fetch_art]
         self.register_listener('import_task_files', self.assign_art)
Exemple #14
0
    def configure(self, config):
        options['autoembed'] = \
            ui.config_val(config, 'embedart', 'autoembed', True, bool)
        options['maxwidth'] = \
            int(ui.config_val(config, 'embedart', 'maxwidth', '0'))

        if options['maxwidth'] and not ArtResizer.shared.local:
            options['maxwidth'] = 0
            log.error("embedart: ImageMagick or PIL not found; "
                      "'maxwidth' option ignored")
Exemple #15
0
    def configure(self, config):
        options['autoembed'] = \
            ui.config_val(config, 'embedart', 'autoembed', True, bool)
        options['maxwidth'] = \
            int(ui.config_val(config, 'embedart', 'maxwidth', '0'))

        if options['maxwidth'] and not ArtResizer.shared.local:
            options['maxwidth'] = 0
            log.error("embedart: ImageMagick or PIL not found; "
                      "'maxwidth' option ignored")
Exemple #16
0
def list_func(lib, config, opts, args):
    fmt = opts.format
    if not fmt:
        # If no format is specified, fall back to a default.
        if opts.album:
            fmt = ui.config_val(config, 'beets', 'list_format_album',
                                DEFAULT_LIST_FORMAT_ALBUM)
        else:
            fmt = ui.config_val(config, 'beets', 'list_format_item',
                                DEFAULT_LIST_FORMAT_ITEM)
    list_items(lib, decargs(args), opts.album, opts.path, fmt)
Exemple #17
0
    def configure(self, config):
        global _feeds_formats, _feeds_dir, _m3u_name

        _feeds_formats = ui.config_val(config, 'importfeeds', 'feeds_formats',
                                       '').split()
        _feeds_dir = ui.config_val(config, 'importfeeds', 'feeds_dir', None)
        _m3u_name = ui.config_val(config, 'importfeeds', 'm3u_name', 
                                 M3U_DEFAULT_NAME)
        
        if _feeds_dir and not os.path.exists(_feeds_dir):
            os.makedirs(_feeds_dir)
Exemple #18
0
def modify_func(lib, config, opts, args):
    args = decargs(args)
    mods = [a for a in args if '=' in a]
    query = [a for a in args if '=' not in a]
    if not mods:
        raise ui.UserError('no modifications specified')
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    modify_items(lib, mods, query, write, opts.move, opts.album, color,
                 not opts.yes)
Exemple #19
0
def modify_func(lib, config, opts, args):
    args = decargs(args)
    mods = [a for a in args if '=' in a]
    query = [a for a in args if '=' not in a]
    if not mods:
        raise ui.UserError('no modifications specified')
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    modify_items(lib, mods, query, write, opts.move, opts.album, color,
                 not opts.yes)
Exemple #20
0
    def configure(self, config):
        global _feeds_formats, _feeds_dir, _m3u_name

        _feeds_formats = ui.config_val(config, 'importfeeds', 'feeds_formats',
                                       '').split()
        _m3u_name = ui.config_val(config, 'importfeeds', 'm3u_name',
                                  M3U_DEFAULT_NAME)
        _feeds_dir = ui.config_val(config, 'importfeeds', 'feeds_dir', None)

        if _feeds_dir:
            _feeds_dir = os.path.expanduser(bytestring_path(_feeds_dir))
            if not os.path.exists(_feeds_dir):
                os.makedirs(syspath(_feeds_dir))
Exemple #21
0
    def lyrics_func(self, lib, config, opts, args):
        pass
        #load force option
        self.force = opts.force if opts.force is not None else \
            ui.config_val(config, 'lyrics', 'force',
                DEFAULT_LYRICS_FORCE, bool)

        #load process count
        self.processcount = opts.processes if opts.processes is not None else \
        int(ui.config_val(  config, 'lyrics', 'processes', DEFAULT_PROCESS_COUNT))

        if len(args) != 0:
            self.process_path(args)
Exemple #22
0
def modify_func(lib, config, opts, args):
    args = decargs(args)
    mods = [a for a in args if "=" in a]
    query = [a for a in args if "=" not in a]
    if not mods:
        raise ui.UserError("no modifications specified")
    write = (
        opts.write
        if opts.write is not None
        else ui.config_val(config, "beets", "import_write", DEFAULT_IMPORT_WRITE, bool)
    )
    color = ui.config_val(config, "beets", "color", DEFAULT_COLOR, bool)
    modify_items(lib, mods, query, write, opts.move, opts.album, color, not opts.yes)
Exemple #23
0
    def configure(self, config):
        global _feeds_formats, _feeds_dir, _m3u_name

        _feeds_formats = ui.config_val(config, 'importfeeds', 'feeds_formats',
                                       '').split()
        _m3u_name = ui.config_val(config, 'importfeeds', 'm3u_name',
                                 M3U_DEFAULT_NAME)
        _feeds_dir = ui.config_val(config, 'importfeeds', 'feeds_dir', None)
        
        if _feeds_dir: 
            _feeds_dir = os.path.expanduser(bytestring_path(_feeds_dir))
            if not os.path.exists(_feeds_dir):
                os.makedirs(syspath(_feeds_dir))
Exemple #24
0
 def configure(self, config):
     if not config.has_section('zero'):
         self._log.debug('[zero] plugin is not configured')
         return
     for f in ui.config_val(config, 'zero', 'fields', '').split():
         if f not in ITEM_KEYS:
             self._log.error('[zero] invalid field: {0}'.format(f))
         else:
             self.fields.append(f)
             p = ui.config_val(config, 'zero', f, '').split()
             if p:
                 self.patterns[f] = p
             else:
                 self.patterns[f] = ['.']
Exemple #25
0
 def configure(self, config):
     if not config.has_section('zero'):
         self._log.debug(u'[zero] plugin is not configured')
         return
     for f in ui.config_val(config, 'zero', 'fields', '').split():
         if f not in ITEM_KEYS:
             self._log.error(u'[zero] invalid field: {0}'.format(f))
         else:
             self.fields.append(f)
             p = ui.config_val(config, 'zero', f, '').split()
             if p:
                 self.patterns[f] = p
             else:
                 self.patterns[f] = ['.']
Exemple #26
0
    def configure(self, config):
        self.on_import = ui.config_val(config, 'lyrics', 'on_import', DEFAULT_ON_IMPORT, bool)
        self.processcount = int(ui.config_val(config, 'lyrics', 'processes', DEFAULT_PROCESS_COUNT))

        #load engine options
        engine_names = ui.config_val(config, 'lyrics', 'engines', '').split()
        if( len(engine_names) == 0):
            engine_names = DEFAULT_ENGINES

        #load all requested engines
        for eng_name in engine_names:
            try:
                self.engines.append( getattr(import_module(".engine_%s"%eng_name, 'beetsplug.lyrics.engines'),eng_name)(self.proxy, 'utf-8')  )
            except Exception,e:
                print e
Exemple #27
0
        def func(lib, config, opts, args):
            write = ui.config_val(config, "beets", "import_write", commands.DEFAULT_IMPORT_WRITE, bool)

            if opts.album:
                # Analyze albums.
                for album in lib.albums(ui.decargs(args)):
                    log.info("analyzing {0} - {1}".format(album.albumartist, album.album))
                    items = list(album.items())
                    results = self.compute_rgain(items, True)
                    if results:
                        self.store_gain(lib, items, results, album)

                    if write:
                        for item in items:
                            item.write()

            else:
                # Analyze individual tracks.
                for item in lib.items(ui.decargs(args)):
                    log.info("analyzing {0} - {1}".format(item.artist, item.title))
                    results = self.compute_rgain([item], False)
                    if results:
                        self.store_gain(lib, [item], results, None)

                    if write:
                        item.write()
Exemple #28
0
        def func(lib, config, opts, args):
            write = ui.config_val(config, 'beets', 'import_write',
                                  commands.DEFAULT_IMPORT_WRITE, bool)

            if opts.album:
                # Analyze albums.
                for album in lib.albums(ui.decargs(args)):
                    log.info(u'analyzing {0} - {1}'.format(
                        album.albumartist, album.album))
                    items = list(album.items())
                    results = self.compute_rgain(items, True)
                    if results:
                        self.store_gain(lib, items, results, album)

                    if write:
                        for item in items:
                            item.write()

            else:
                # Analyze individual tracks.
                for item in lib.items(ui.decargs(args)):
                    log.info(u'analyzing {0} - {1}'.format(
                        item.artist, item.title))
                    results = self.compute_rgain([item], False)
                    if results:
                        self.store_gain(lib, [item], results, None)

                    if write:
                        item.write()
Exemple #29
0
        def lastgenre_func(lib, config, opts, args):
            # The "write to files" option corresponds to the
            # import_write config value.
            write = ui.config_val(config, 'beets', 'import_write',
                                  commands.DEFAULT_IMPORT_WRITE, bool)
            for album in lib.albums(ui.decargs(args)):
                tags = []
                lastfm_obj = LASTFM.get_album(album.albumartist, album.album)
                if album.genre:
                    tags.append(album.genre)

                tags.extend(_tags_for(lastfm_obj))
                genre = _tags_to_genre(tags)

                if not genre and fallback_str != None:
                    genre = fallback_str
                    log.debug(u'no last.fm genre found: fallback to %s' %
                              genre)

                if genre is not None:
                    log.debug(u'adding last.fm album genre: %s' % genre)
                    album.genre = genre
                    if write:
                        for item in album.items():
                            item.write()
Exemple #30
0
 def func(lib, config, opts, args):
     # The "write to files" option corresponds to the
     # import_write config value.
     write = ui.config_val(config, "beets", "import_write", commands.DEFAULT_IMPORT_WRITE, bool)
     for item in lib.items(ui.decargs(args)):
         fetch_item_lyrics(lib, logging.INFO, item, write)
         if opts.printlyr and item.lyrics:
             ui.print_(item.lyrics)
Exemple #31
0
    def configure(self, config):
        global fallback_str
        global genres
        
        gl_filename = ui.config_val(config, 'genrelist', 'listfile', None)
        # Read the genres tree for canonicalization if enabled.
        if gl_filename is not None:
            gl_filename = gl_filename.strip()
            if not gl_filename:
                gl_filename = DEFAULT_GENRELIST
            gl_filename = normpath(gl_filename)

            from yaml import load
            genres_tree = load(open(gl_filename, 'r'))
            genres=reverse_dict(genres_tree)

        fallback_str = ui.config_val(config, 'genrelist', 'fallback_str', None)
Exemple #32
0
    def configure(self, config):
        self.overwrite = ui.config_val(config, 'replaygain', 'overwrite',
                                       False, bool)
        self.albumgain = ui.config_val(config, 'replaygain', 'albumgain',
                                       False, bool)
        self.noclip = ui.config_val(config, 'replaygain', 'noclip', True, bool)
        self.apply_gain = ui.config_val(config, 'replaygain', 'apply_gain',
                                        False, bool)
        target_level = float(
            ui.config_val(config, 'replaygain', 'targetlevel',
                          DEFAULT_REFERENCE_LOUDNESS))
        self.gain_offset = int(target_level - DEFAULT_REFERENCE_LOUDNESS)
        self.automatic = ui.config_val(config, 'replaygain', 'automatic', True,
                                       bool)

        self.command = ui.config_val(config, 'replaygain', 'command', None)
        if self.command:
            # Explicit executable path.
            if not os.path.isfile(self.command):
                raise ui.UserError(
                    'replaygain command does not exist: {0}'.format(
                        self.command))
        else:
            # Check whether the program is in $PATH.
            for cmd in ('mp3gain', 'aacgain'):
                try:
                    call([cmd, '-v'])
                    self.command = cmd
                except OSError:
                    pass
        if not self.command:
            raise ui.UserError(
                'no replaygain command found: install mp3gain or aacgain')
Exemple #33
0
 def func(lib, config, opts, args):
     # The "write to files" option corresponds to the
     # import_write config value.
     write = ui.config_val(config, 'beets', 'import_write',
                           commands.DEFAULT_IMPORT_WRITE, bool)
     for item in lib.items(ui.decargs(args)):
         fetch_item_lyrics(lib, logging.INFO, item, write)
         if opts.printlyr and item.lyrics:
             ui.print_(item.lyrics)
Exemple #34
0
        def func(lib, config, opts, args):
            # The "write to files" option corresponds to the
            # import_write config value.
            write = ui.config_val(config, 'beets', 'import_write',
                                  commands.DEFAULT_IMPORT_WRITE, bool)

            for item in lib.items(ui.decargs(args)):
                fetch_item_tempo(lib, logging.INFO, item, write)
                if opts.printbpm and item.bpm:
                    ui.print_('{0} BPM'.format(item.bpm))
Exemple #35
0
        def func(lib, config, opts, args):
            # The "write to files" option corresponds to the
            # import_write config value.
            if not _echonest_apikey:
                raise ui.UserError('no EchoNest user API key provided')

            write = ui.config_val(config, 'beets', 'import_write',
                                  commands.DEFAULT_IMPORT_WRITE, bool)

            for item in lib.items(ui.decargs(args)):
                fetch_item_tempo(lib, logging.INFO, item, write)
                if opts.printlyr and item.bpm:
                    ui.print_(item.bpm)
Exemple #36
0
        def func(lib, config, opts, args):
            # The "write to files" option corresponds to the
            # import_write config value.
            if not _echonest_apikey:
                raise ui.UserError('no EchoNest user API key provided')

            write = ui.config_val(config, 'beets', 'import_write',
                                  commands.DEFAULT_IMPORT_WRITE, bool)

            for item in lib.items(ui.decargs(args)):
                fetch_item_tempo(lib, logging.INFO, item, write)
                if opts.printlyr and item.bpm:
                    ui.print_(item.bpm)
Exemple #37
0
 def configure(self, config):
     conf['dest'] = ui.config_val(config, 'convert', 'dest', None)
     conf['threads'] = int(ui.config_val(config, 'convert', 'threads',
         util.cpu_count()))
     conf['flac'] = ui.config_val(config, 'convert', 'flac', 'flac')
     conf['lame'] = ui.config_val(config, 'convert', 'lame', 'lame')
     conf['opts'] = ui.config_val(config, 'convert',
                                  'opts', '-V2').split(' ')
     conf['max_bitrate'] = int(ui.config_val(config, 'convert',
                                             'max_bitrate', '500'))
     conf['embed'] = ui.config_val(config, 'convert', 'embed', True,
                                   vtype=bool)
Exemple #38
0
 def configure(self, config):
     if not config.has_section('ihate'):
         self._log.debug('[ihate] plugin is not configured')
         return
     self.warn_genre = ui.config_val(config, 'ihate', 'warn_genre', 
                                     '').split()
     self.warn_artist = ui.config_val(config, 'ihate', 'warn_artist', 
                                      '').split()
     self.warn_album = ui.config_val(config, 'ihate', 'warn_album', 
                                     '').split()
     self.warn_whitelist = ui.config_val(config, 'ihate', 'warn_whitelist', 
                                    '').split()
     self.skip_genre = ui.config_val(config, 'ihate', 'skip_genre', 
                                     '').split()
     self.skip_artist = ui.config_val(config, 'ihate', 'skip_artist', 
                                      '').split()
     self.skip_album = ui.config_val(config, 'ihate', 'skip_album', 
                                     '').split()
     self.skip_whitelist = ui.config_val(config, 'ihate', 'skip_whitelist', 
                                    '').split()
Exemple #39
0
 def configure(self, config):
     if not config.has_section('ihate'):
         self._log.warn('[ihate] plugin is not configured')
         return
     self.warn_genre = ui.config_val(config, 'ihate', 'warn_genre', 
                                     '').split()
     self.warn_artist = ui.config_val(config, 'ihate', 'warn_artist', 
                                      '').split()
     self.warn_album = ui.config_val(config, 'ihate', 'warn_album', 
                                     '').split()
     self.warn_whitelist = ui.config_val(config, 'ihate', 'warn_whitelist', 
                                    '').split()
     self.skip_genre = ui.config_val(config, 'ihate', 'skip_genre', 
                                     '').split()
     self.skip_artist = ui.config_val(config, 'ihate', 'skip_artist', 
                                      '').split()
     self.skip_album = ui.config_val(config, 'ihate', 'skip_album', 
                                     '').split()
     self.skip_whitelist = ui.config_val(config, 'ihate', 'skip_whitelist', 
                                    '').split()
Exemple #40
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
                           DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    art = opts.art if opts.art is not None else \
        ui.config_val(config, 'beets', 'import_art',
            DEFAULT_IMPORT_ART, bool)
    threaded = ui.config_val(config, 'beets', 'threaded', DEFAULT_THREADED,
                             bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, 'beets',
                                       'import_quiet_fallback',
                                       DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    interactive_autotag = opts.interactive_autotag if opts.interactive_autotag is not None else DEFAULT_IMPORT_INT_AUTOT

    # Resume has three options: yes, no, and "ask" (None).
    resume = opts.resume if opts.resume is not None else \
        ui.config_val(config, 'beets', 'import_resume', DEFAULT_IMPORT_RESUME)
    if isinstance(resume, basestring):
        if resume.lower() in ('yes', 'true', 't', 'y', '1'):
            resume = True
        elif resume.lower() in ('no', 'false', 'f', 'n', '0'):
            resume = False
        else:
            resume = None

    if quiet_fallback_str == 'asis':
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP
    import_files(lib, args, copy, write, autot, opts.logpath, art, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons,
                 interactive_autotag)
Exemple #41
0
 def configure(self, config):
     conf['dest'] = ui.config_val(config, 'convert', 'dest', None)
     conf['threads'] = int(
         ui.config_val(config, 'convert', 'threads', util.cpu_count()))
     conf['ffmpeg'] = ui.config_val(config, 'convert', 'ffmpeg', 'ffmpeg')
     conf['opts'] = ui.config_val(config, 'convert', 'opts',
                                  '-aq 2').split(' ')
     conf['max_bitrate'] = int(
         ui.config_val(config, 'convert', 'max_bitrate', '500'))
     conf['embed'] = ui.config_val(config,
                                   'convert',
                                   'embed',
                                   True,
                                   vtype=bool)
Exemple #42
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
            DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    art = opts.art if opts.art is not None else \
        ui.config_val(config, 'beets', 'import_art',
            DEFAULT_IMPORT_ART, bool)
    threaded = ui.config_val(config, 'beets', 'threaded',
            DEFAULT_THREADED, bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, 'beets', 'import_quiet_fallback',
            DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    interactive_autotag = opts.interactive_autotag if opts.interactive_autotag is not None else DEFAULT_IMPORT_INT_AUTOT

    # Resume has three options: yes, no, and "ask" (None).
    resume = opts.resume if opts.resume is not None else \
        ui.config_val(config, 'beets', 'import_resume', DEFAULT_IMPORT_RESUME)
    if isinstance(resume, basestring):
        if resume.lower() in ('yes', 'true', 't', 'y', '1'):
            resume = True
        elif resume.lower() in ('no', 'false', 'f', 'n', '0'):
            resume = False
        else:
            resume = None

    if quiet_fallback_str == 'asis':
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP
    import_files(lib, args, copy, write, autot, opts.logpath, art, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons, interactive_autotag)
Exemple #43
0
        def lastgenre_func(lib, config, opts, args):
            # The "write to files" option corresponds to the
            # import_write config value.
            write = ui.config_val(config, 'beets', 'import_write',
                                  commands.DEFAULT_IMPORT_WRITE, bool)
            for album in lib.albums(ui.decargs(args)):
                tags = []    
                lastfm_obj = LASTFM.get_album(album.albumartist, album.album)
                if album.genre:
                    tags.append(album.genre)

                tags.extend(_tags_for(lastfm_obj))
                genre = _tags_to_genre(tags)

                if not genre and fallback_str != None:
                    genre = fallback_str
                    log.debug(u'no last.fm genre found: fallback to %s' % genre)

                if genre is not None:
                    log.debug(u'adding last.fm album genre: %s' % genre)
                    album.genre = genre
                    if write:
                        for item in album.items():
                            item.write()
Exemple #44
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
            DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    art = opts.art if opts.art is not None else \
        ui.config_val(config, 'beets', 'import_art',
            DEFAULT_IMPORT_ART, bool)
    threaded = ui.config_val(config, 'beets', 'threaded',
            DEFAULT_THREADED, bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    import_files(lib, args, copy, write, autot,
                 opts.logpath, art, threaded, color, delete, quiet)
Exemple #45
0
    def configure(self, config):
        self.overwrite = ui.config_val(config, 'replaygain',
                                       'overwrite', False, bool)
        self.albumgain = ui.config_val(config, 'replaygain',
                                       'albumgain', False, bool)
        self.noclip = ui.config_val(config, 'replaygain',
                                    'noclip', True, bool)
        self.apply_gain = ui.config_val(config, 'replaygain',
                                        'apply_gain', False, bool)
        target_level = float(ui.config_val(config, 'replaygain',
                                           'targetlevel',
                                           DEFAULT_REFERENCE_LOUDNESS))
        self.gain_offset = int(target_level - DEFAULT_REFERENCE_LOUDNESS)
        self.automatic = ui.config_val(config, 'replaygain',
                                       'automatic', True, bool)

        self.command = ui.config_val(config,'replaygain','command', None)
        if self.command:
            # Explicit executable path.
            if not os.path.isfile(self.command):
                raise ui.UserError(
                    'replaygain command does not exist: {0}'.format(
                        self.command
                    )
                )
        else:
            # Check whether the program is in $PATH.
            for cmd in ('mp3gain', 'aacgain'):
                try:
                    call([cmd, '-v'])
                    self.command = cmd
                except OSError:
                    pass
        if not self.command:
            raise ui.UserError(
                'no replaygain command found: install mp3gain or aacgain'
            )
Exemple #46
0
    def configure(self, config):
        self.overwrite = ui.config_val(config, "replaygain", "overwrite", False, bool)
        self.noclip = ui.config_val(config, "replaygain", "noclip", True, bool)
        self.apply_gain = ui.config_val(config, "replaygain", "apply_gain", False, bool)
        target_level = float(ui.config_val(config, "replaygain", "targetlevel", DEFAULT_REFERENCE_LOUDNESS))
        self.gain_offset = int(target_level - DEFAULT_REFERENCE_LOUDNESS)
        self.automatic = ui.config_val(config, "replaygain", "automatic", True, bool)

        self.command = ui.config_val(config, "replaygain", "command", None)
        if self.command:
            # Explicit executable path.
            if not os.path.isfile(self.command):
                raise ui.UserError("replaygain command does not exist: {0}".format(self.command))
        else:
            # Check whether the program is in $PATH.
            for cmd in ("mp3gain", "aacgain"):
                try:
                    call([cmd, "-v"])
                    self.command = cmd
                except OSError:
                    pass
        if not self.command:
            raise ui.UserError("no replaygain command found: install mp3gain or aacgain")
Exemple #47
0
def update_func(lib, config, opts, args):
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    update_items(lib, decargs(args), opts.album, opts.move, color, opts.pretend)
Exemple #48
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    move  = ui.config_val(config, 'beets', 'import_move',
                          DEFAULT_IMPORT_MOVE, bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
            DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    art = opts.art if opts.art is not None else \
        ui.config_val(config, 'beets', 'import_art',
            DEFAULT_IMPORT_ART, bool)
    threaded = ui.config_val(config, 'beets', 'threaded',
            DEFAULT_THREADED, bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, 'beets', 'import_quiet_fallback',
            DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    timid = opts.timid if opts.timid is not None else \
        ui.config_val(config, 'beets', 'import_timid',
            DEFAULT_IMPORT_TIMID, bool)
    logpath = opts.logpath if opts.logpath is not None else \
        ui.config_val(config, 'beets', 'import_log', None)
    incremental = opts.incremental if opts.incremental is not None else \
        ui.config_val(config, 'beets', 'import_incremental',
            DEFAULT_IMPORT_INCREMENTAL, bool)
    ignore = ui.config_val(config, 'beets', 'ignore', DEFAULT_IGNORE, list)
    per_disc_numbering = ui.config_val(config, 'beets', 'per_disc_numbering',
                                       DEFAULT_PER_DISC_NUMBERING, bool)

    # Resume has three options: yes, no, and "ask" (None).
    resume = opts.resume if opts.resume is not None else \
        ui.config_val(config, 'beets', 'import_resume', DEFAULT_IMPORT_RESUME)
    if isinstance(resume, basestring):
        if resume.lower() in ('yes', 'true', 't', 'y', '1'):
            resume = True
        elif resume.lower() in ('no', 'false', 'f', 'n', '0'):
            resume = False
        else:
            resume = None

    # Special case: --copy flag suppresses import_move (which would
    # otherwise take precedence).
    if opts.copy:
        move = False

    if quiet_fallback_str == 'asis':
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP

    if opts.library:
        query = args
        paths = []
    else:
        query = None
        paths = args

    import_files(lib, paths, copy, move, write, autot, logpath, art, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons,
                 timid, query, incremental, ignore, per_disc_numbering)
Exemple #49
0
def update_func(lib, config, opts, args):
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    update_items(lib, decargs(args), opts.album, opts.move, color,
                 opts.pretend)
Exemple #50
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
                           DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    art = opts.art if opts.art is not None else \
        ui.config_val(config, 'beets', 'import_art',
            DEFAULT_IMPORT_ART, bool)
    threaded = ui.config_val(config, 'beets', 'threaded', DEFAULT_THREADED,
                             bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, 'beets',
                                       'import_quiet_fallback',
                                       DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    timid = opts.timid if opts.timid is not None else \
        ui.config_val(config, 'beets', 'import_timid',
            DEFAULT_IMPORT_TIMID, bool)
    logpath = opts.logpath if opts.logpath is not None else \
        ui.config_val(config, 'beets', 'import_log', None)
    incremental = opts.incremental if opts.incremental is not None else \
        ui.config_val(config, 'beets', 'import_incremental',
            DEFAULT_IMPORT_INCREMENTAL, bool)
    ignore = ui.config_val(config, 'beets', 'ignore', DEFAULT_IGNORE, list)

    # Resume has three options: yes, no, and "ask" (None).
    resume = opts.resume if opts.resume is not None else \
        ui.config_val(config, 'beets', 'import_resume', DEFAULT_IMPORT_RESUME)
    if isinstance(resume, basestring):
        if resume.lower() in ('yes', 'true', 't', 'y', '1'):
            resume = True
        elif resume.lower() in ('no', 'false', 'f', 'n', '0'):
            resume = False
        else:
            resume = None

    if quiet_fallback_str == 'asis':
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP

    if opts.library:
        query = args
        paths = []
    else:
        query = None
        paths = args

    import_files(lib, paths, copy, write, autot, logpath, art, threaded, color,
                 delete, quiet, resume, quiet_fallback, singletons, timid,
                 query, incremental, ignore)
Exemple #51
0
def import_func(lib, config, opts, args):
    copy  = opts.copy  if opts.copy  is not None else \
        ui.config_val(config, 'beets', 'import_copy',
            DEFAULT_IMPORT_COPY, bool)
    move = ui.config_val(config, 'beets', 'import_move', DEFAULT_IMPORT_MOVE,
                         bool)
    write = opts.write if opts.write is not None else \
        ui.config_val(config, 'beets', 'import_write',
            DEFAULT_IMPORT_WRITE, bool)
    delete = ui.config_val(config, 'beets', 'import_delete',
                           DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    threaded = ui.config_val(config, 'beets', 'threaded', DEFAULT_THREADED,
                             bool)
    color = ui.config_val(config, 'beets', 'color', DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, 'beets',
                                       'import_quiet_fallback',
                                       DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    timid = opts.timid if opts.timid is not None else \
        ui.config_val(config, 'beets', 'import_timid',
            DEFAULT_IMPORT_TIMID, bool)
    logpath = opts.logpath if opts.logpath is not None else \
        ui.config_val(config, 'beets', 'import_log', None)
    incremental = opts.incremental if opts.incremental is not None else \
        ui.config_val(config, 'beets', 'import_incremental',
            DEFAULT_IMPORT_INCREMENTAL, bool)
    ignore = ui.config_val(config, 'beets', 'ignore', DEFAULT_IGNORE, list)
    per_disc_numbering = ui.config_val(config, 'beets', 'per_disc_numbering',
                                       DEFAULT_PER_DISC_NUMBERING, bool)

    # Resume has three options: yes, no, and "ask" (None).
    resume = opts.resume if opts.resume is not None else \
        ui.config_val(config, 'beets', 'import_resume', DEFAULT_IMPORT_RESUME)
    if isinstance(resume, basestring):
        if resume.lower() in ('yes', 'true', 't', 'y', '1'):
            resume = True
        elif resume.lower() in ('no', 'false', 'f', 'n', '0'):
            resume = False
        else:
            resume = None

    # Special case: --copy flag suppresses import_move (which would
    # otherwise take precedence).
    if opts.copy:
        move = False

    if quiet_fallback_str == 'asis':
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP

    if opts.library:
        query = decargs(args)
        paths = []
    else:
        query = None
        paths = args

    import_files(lib, paths, copy, move, write, autot, logpath, threaded,
                 color, delete, quiet, resume, quiet_fallback, singletons,
                 timid, query, incremental, ignore, per_disc_numbering)
Exemple #52
0
def import_func(lib, config, opts, args):
    copy = (
        opts.copy if opts.copy is not None else ui.config_val(config, "beets", "import_copy", DEFAULT_IMPORT_COPY, bool)
    )
    move = ui.config_val(config, "beets", "import_move", DEFAULT_IMPORT_MOVE, bool)
    write = (
        opts.write
        if opts.write is not None
        else ui.config_val(config, "beets", "import_write", DEFAULT_IMPORT_WRITE, bool)
    )
    delete = ui.config_val(config, "beets", "import_delete", DEFAULT_IMPORT_DELETE, bool)
    autot = opts.autotag if opts.autotag is not None else DEFAULT_IMPORT_AUTOT
    threaded = ui.config_val(config, "beets", "threaded", DEFAULT_THREADED, bool)
    color = ui.config_val(config, "beets", "color", DEFAULT_COLOR, bool)
    quiet = opts.quiet if opts.quiet is not None else DEFAULT_IMPORT_QUIET
    quiet_fallback_str = ui.config_val(config, "beets", "import_quiet_fallback", DEFAULT_IMPORT_QUIET_FALLBACK)
    singletons = opts.singletons
    timid = (
        opts.timid
        if opts.timid is not None
        else ui.config_val(config, "beets", "import_timid", DEFAULT_IMPORT_TIMID, bool)
    )
    logpath = opts.logpath if opts.logpath is not None else ui.config_val(config, "beets", "import_log", None)
    incremental = (
        opts.incremental
        if opts.incremental is not None
        else ui.config_val(config, "beets", "import_incremental", DEFAULT_IMPORT_INCREMENTAL, bool)
    )
    ignore = ui.config_val(config, "beets", "ignore", DEFAULT_IGNORE, list)
    per_disc_numbering = ui.config_val(config, "beets", "per_disc_numbering", DEFAULT_PER_DISC_NUMBERING, bool)

    # Resume has three options: yes, no, and "ask" (None).
    resume = (
        opts.resume
        if opts.resume is not None
        else ui.config_val(config, "beets", "import_resume", DEFAULT_IMPORT_RESUME)
    )
    if isinstance(resume, basestring):
        if resume.lower() in ("yes", "true", "t", "y", "1"):
            resume = True
        elif resume.lower() in ("no", "false", "f", "n", "0"):
            resume = False
        else:
            resume = None

    # Special case: --copy flag suppresses import_move (which would
    # otherwise take precedence).
    if opts.copy:
        move = False

    if quiet_fallback_str == "asis":
        quiet_fallback = importer.action.ASIS
    else:
        quiet_fallback = importer.action.SKIP

    if opts.library:
        query = args
        paths = []
    else:
        query = None
        paths = args

    import_files(
        lib,
        paths,
        copy,
        move,
        write,
        autot,
        logpath,
        threaded,
        color,
        delete,
        quiet,
        resume,
        quiet_fallback,
        singletons,
        timid,
        query,
        incremental,
        ignore,
        per_disc_numbering,
    )
Exemple #53
0
 def configure(self, config):
     options['autoembed'] = \
         ui.config_val(config, 'embedart', 'autoembed', True, bool)
Exemple #54
0
 def configure(self, config):
     global _userkey
     _userkey = ui.config_val(config, 'acoustid', 'apikey', None)
Exemple #55
0
 def configure(self, config):
     global AUTOFETCH
     AUTOFETCH = ui.config_val(config, 'lyrics', 'autofetch', True, bool)
Exemple #56
0
 def configure(self, config):
     self.overwrite = ui.config_val(config, 'replaygain', 'overwrite',
                                    False)
Exemple #57
0
 def configure(self, config):
     options[AUTOSCRUB_KEY] = \
         ui.config_val(config, 'scrub', AUTOSCRUB_KEY, True, bool)
Exemple #58
0
 def configure(self, config):
     global _userkey
     _userkey = ui.config_val(config, 'acoustid', 'apikey', None)
Exemple #59
0
 def configure(self, config):
     username = ui.config_val(config, 'musicbrainz', 'user', '')
     password = ui.config_val(config, 'musicbrainz', 'pass', '')
     musicbrainzngs.auth(username, password)