How to use the beets.library.Library function in beets

To help you get started, we’ve selected a few beets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beetbox / beets / test / test_db.py View on Github external
def setUp(self):
        self.lib = beets.library.Library(':memory:')
        self.lib.directory = '/base'
        self.lib.path_formats = [('default', u'path')]

        self.i1 = item()
        self.i1.year = 2001
        self.lib.add_album([self.i1])
        self.i2 = item()
        self.i2.year = 2002
        self.lib.add_album([self.i2])
        self.lib.save()

        self._setf(u'foo%unique{albumartist album,year}/$title')
github beetbox / beets / test / test_query.py View on Github external
def setUp(self):
        self.lib = Library(':memory:')
github beetbox / beets / test / test_ui.py View on Github external
def setUp(self):
        self.lib = library.Library(':memory:')
        self.item = _common.item()
        self.item.path = 'xxx/yyy'
        self.lib.add(self.item)
        self.lib.add_album([self.item])
github beetbox / beets / test / test_files.py View on Github external
def setUp(self):
        super(RemoveTest, self).setUp()

        # Make library and item.
        self.lib = beets.library.Library(':memory:')
        self.libdir = os.path.join(self.temp_dir, b'testlibdir')
        self.lib.directory = self.libdir
        self.i = item(self.lib)
        self.i.path = self.i.destination()
        # Make a music file.
        util.mkdirall(self.i.path)
        touch(self.i.path)
        # Make an album with the item.
        self.ai = self.lib.add_album((self.i,))
github beetbox / beets / test / helper.py View on Github external
def run_command(self, *args):
        if hasattr(self, 'lib'):
            lib = self.lib
        else:
            lib = Library(':memory:')
        beets.ui._raw_main(list(args), lib)
github beetbox / beets / test / test_sort.py View on Github external
def setUp(self):
        super(DummyDataTestCase, self).setUp()
        self.lib = beets.library.Library(':memory:')

        albums = [_common.album() for _ in range(3)]
        albums[0].album = "Album A"
        albums[0].genre = "Rock"
        albums[0].year = 2001
        albums[0].flex1 = "Flex1-1"
        albums[0].flex2 = "Flex2-A"
        albums[0].albumartist = "Foo"
        albums[0].albumartist_sort = None
        albums[1].album = "Album B"
        albums[1].genre = "Rock"
        albums[1].year = 2001
        albums[1].flex1 = "Flex1-2"
        albums[1].flex2 = "Flex2-A"
        albums[1].albumartist = "Bar"
        albums[1].albumartist_sort = None
github beetbox / beets / test / test_library.py View on Github external
def setUp(self):
        super(PathStringTest, self).setUp()
        self.lib = beets.library.Library(':memory:')
        self.i = item(self.lib)
github clinton-hall / nzbToMedia / libs / beetsplug / ipfs.py View on Github external
self._log.error(msg)
                return False
        path = remote_libs + "/" + lib_name + ".db"
        if not os.path.exists(path):
            cmd = "ipfs get {0} -o".format(_hash).split()
            cmd.append(path)
            try:
                util.command_output(cmd)
            except (OSError, subprocess.CalledProcessError):
                self._log.error("Could not import {0}".format(_hash))
                return False

        # add all albums from remotes into a combined library
        jpath = remote_libs + "/joined.db"
        jlib = library.Library(jpath)
        nlib = library.Library(path)
        for album in nlib.albums():
            if not self.already_added(album, jlib):
                new_album = []
                for item in album.items():
                    item.id = None
                    new_album.append(item)
                added_album = jlib.add_album(new_album)
                added_album.ipfs = album.ipfs
                added_album.store()
github rembo10 / headphones / lib / beets / ui / __init__.py View on Github external
def _open_library(config):
    """Create a new library instance from the configuration.
    """
    dbpath = util.bytestring_path(config['library'].as_filename())
    try:
        lib = library.Library(
            dbpath,
            config['directory'].as_filename(),
            get_path_formats(),
            get_replacements(),
        )
        lib.get_item(0)  # Test database connection.
    except (sqlite3.OperationalError, sqlite3.DatabaseError):
        log.debug(u'{}', traceback.format_exc())
        raise UserError(u"database file {0} could not be opened".format(
            util.displayable_path(dbpath)
        ))
    log.debug(u'library database: {0}\n'
              u'library directory: {1}',
              util.displayable_path(lib.path),
              util.displayable_path(lib.directory))
    return lib