Example #1
0
        def embed_func(lib, opts, args):
            if opts.file:
                imagepath = normpath(opts.file)
                if not os.path.isfile(syspath(imagepath)):
                    raise ui.UserError(u'image file {0} not found'.format(
                        displayable_path(imagepath)))

                items = lib.items(decargs(args))

                # Confirm with user.
                if not opts.yes and not _confirm(items, not opts.file):
                    return

                for item in items:
                    art.embed_item(self._log, item, imagepath, maxwidth, None,
                                   compare_threshold, ifempty)
            else:
                albums = lib.albums(decargs(args))

                # Confirm with user.
                if not opts.yes and not _confirm(albums, not opts.file):
                    return

                for album in albums:
                    art.embed_album(self._log, album, maxwidth, False,
                                    compare_threshold, ifempty)
                    self.remove_artfile(album)
Example #2
0
        def embed_func(lib, opts, args):
            if opts.file:
                imagepath = normpath(opts.file)
                if not os.path.isfile(syspath(imagepath)):
                    raise ui.UserError(u'image file {0} not found'.format(
                        displayable_path(imagepath)
                    ))

                items = lib.items(decargs(args))

                # Confirm with user.
                if not opts.yes and not _confirm(items, not opts.file):
                    return

                for item in items:
                    art.embed_item(self._log, item, imagepath, maxwidth, None,
                                   compare_threshold, ifempty)
            else:
                albums = lib.albums(decargs(args))

                # Confirm with user.
                if not opts.yes and not _confirm(albums, not opts.file):
                    return

                for album in albums:
                    art.embed_album(self._log, album, maxwidth, False,
                                    compare_threshold, ifempty)
                    self.remove_artfile(album)
Example #3
0
 def process_album(self, album):
     """Automatically embed art after art has been set
     """
     if self.config['auto']:
         max_width = self.config['maxwidth'].get(int)
         art.embed_album(self._log, album, max_width, True,
                         self.config['compare_threshold'].get(int),
                         self.config['ifempty'].get(bool))
Example #4
0
 def process_album(self, album):
     """Automatically embed art after art has been set
     """
     if self.config['auto']:
         max_width = self.config['maxwidth'].get(int)
         art.embed_album(self._log, album, max_width, True,
                         self.config['compare_threshold'].get(int),
                         self.config['ifempty'].get(bool))
Example #5
0
 def embed_func(lib, opts, args):
     if opts.file:
         imagepath = normpath(opts.file)
         if not os.path.isfile(syspath(imagepath)):
             raise ui.UserError(u"image file {0} not found".format(displayable_path(imagepath)))
         for item in lib.items(decargs(args)):
             art.embed_item(self._log, item, imagepath, maxwidth, None, compare_threshold, ifempty)
     else:
         for album in lib.albums(decargs(args)):
             art.embed_album(self._log, album, maxwidth, False, compare_threshold, ifempty)
             self.remove_artfile(album)
Example #6
0
 def embed_func(lib, opts, args):
     if opts.file:
         imagepath = normpath(opts.file)
         if not os.path.isfile(syspath(imagepath)):
             raise ui.UserError(u'image file {0} not found'.format(
                 displayable_path(imagepath)))
         for item in lib.items(decargs(args)):
             art.embed_item(self._log, item, imagepath, maxwidth, None,
                            compare_threshold, ifempty)
     else:
         for album in lib.albums(decargs(args)):
             art.embed_album(self._log, album, maxwidth, False,
                             compare_threshold, ifempty)
Example #7
0
 def process_album(self, album):
     """Automatically embed art after art has been set
     """
     if self.config["auto"] and ui.should_write():
         max_width = self.config["maxwidth"].get(int)
         art.embed_album(
             self._log,
             album,
             max_width,
             True,
             self.config["compare_threshold"].get(int),
             self.config["ifempty"].get(bool),
         )
         self.remove_artfile(album)
Example #8
0
        def embed_func(lib, opts, args):
            if opts.file:
                imagepath = normpath(opts.file)
                if not os.path.isfile(syspath(imagepath)):
                    raise ui.UserError(u'image file {0} not found'.format(
                        displayable_path(imagepath)))
                for item in lib.items(decargs(args)):
                    art.embed_item(self._log, item, imagepath, maxwidth, None,
                                   compare_threshold, ifempty)
            else:
                for album in lib.albums(decargs(args)):
                    art.embed_album(self._log, album, maxwidth, False,
                                    compare_threshold, ifempty)

                    if remove_art_file and album.artpath is not None:
                        if os.path.isfile(album.artpath):
                            self._log.debug(
                                u'Removing album art file '
                                u'for {0}', album)
                            os.remove(album.artpath)
                            album.artpath = None
                            album.store()
Example #9
0
        def embed_func(lib, opts, args):
            if opts.file:
                imagepath = normpath(opts.file)
                if not os.path.isfile(syspath(imagepath)):
                    raise ui.UserError(u'image file {0} not found'.format(
                        displayable_path(imagepath)
                    ))
                for item in lib.items(decargs(args)):
                    art.embed_item(self._log, item, imagepath, maxwidth, None,
                                   compare_threshold, ifempty)
            else:
                for album in lib.albums(decargs(args)):
                    art.embed_album(self._log, album, maxwidth, False,
                                    compare_threshold, ifempty)

                    if remove_art_file and album.artpath is not None:
                        if os.path.isfile(album.artpath):
                            self._log.debug(u'Removing album art file '
                                            u'for {0}', album)
                            os.remove(album.artpath)
                            album.artpath = None
                            album.store()