db: Give Artists a find_album() function
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
a1f54839bb
commit
737d135d41
|
@ -18,10 +18,7 @@ def make_fake_track(trackno, length, title, path, lib="/a/b/c", art="Test Artist
|
|||
alb="Test Album", disk=1, subtitle=None, yeer=2021):
|
||||
lib = library.Table.find(pathlib.Path(lib))
|
||||
art = artist.Table.find(art, art)
|
||||
if (album.Table.lookup(art, alb)) == None:
|
||||
alb = album.Table.insert(art, alb)
|
||||
else:
|
||||
alb = album.Table.lookup(art, alb)
|
||||
alb = art.find_album(alb)
|
||||
disk = disc.Table.find(alb, disk, subtitle)
|
||||
dec = decade.Table.find((yeer // 10) * 10)
|
||||
yeer = dec.find_year(yeer)
|
||||
|
|
|
@ -22,6 +22,8 @@ class Artist(playlist.ParentPlaylist):
|
|||
@GObject.Property
|
||||
def name(self): return self._name
|
||||
|
||||
def find_album(self, name): return self.find_child(name)
|
||||
|
||||
def get_child_table(self): return album.Table
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class TestAlbum(unittest.TestCase):
|
|||
|
||||
def test_init(self):
|
||||
artist = db.artist.Table.find("Test Artist", "Test Sort")
|
||||
album = db.album.Table.insert(artist, "Test Album")
|
||||
album = artist.find_album("Test Album")
|
||||
self.assertIsInstance(album, db.playlist.ParentPlaylist)
|
||||
self.assertEqual(album.get_property("name"), "Test Album")
|
||||
self.assertEqual(album.get_child_table(), db.disc.Table)
|
||||
|
@ -32,7 +32,7 @@ class TestAlbumTable(unittest.TestCase):
|
|||
|
||||
def test_insert(self):
|
||||
artist = db.artist.Table.insert("Test Artist", "Test Sort")
|
||||
album = db.album.Table.insert(artist, "Test Album")
|
||||
album = artist.find_album("Test Album")
|
||||
|
||||
self.assertIsInstance(album, db.album.Album)
|
||||
self.assertEqual(album._name, "Test Album")
|
||||
|
@ -42,6 +42,6 @@ class TestAlbumTable(unittest.TestCase):
|
|||
|
||||
def test_lookup(self):
|
||||
artist = db.artist.Table.insert("Test Artist", "Test Sort")
|
||||
album = db.album.Table.insert(artist, "Test Album")
|
||||
album = artist.find_album("Test Album")
|
||||
self.assertEqual(db.album.Table.lookup(artist, "Test Album"), album)
|
||||
self.assertIsNone(db.album.Table.lookup(artist, "none"))
|
||||
|
|
|
@ -14,6 +14,11 @@ class TestArtist(unittest.TestCase):
|
|||
self.assertEqual(artist.get_property("name"), "Test Artist")
|
||||
self.assertEqual(artist.get_child_table(), db.album.Table)
|
||||
|
||||
def test_find_album(self):
|
||||
artist = db.artist.Table.find("Test Artist", "Test Sort")
|
||||
album = artist.find_album("Test Album")
|
||||
self.assertIsInstance(album, db.album.Album)
|
||||
|
||||
|
||||
class TestArtistTable(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -15,7 +15,7 @@ class TestDiscTable(unittest.TestCase):
|
|||
|
||||
def test_disc_table_insert(self):
|
||||
artist = db.artist.Table.insert("Test Artist", "Test Sort")
|
||||
album = db.album.Table.insert(artist, "Test Album")
|
||||
album = artist.find_album("Test Album")
|
||||
disc = db.disc.Table.insert(album, 1, "subtitle")
|
||||
|
||||
self.assertIsInstance(disc, db.disc.Disc)
|
||||
|
@ -40,7 +40,7 @@ class TestDiscTable(unittest.TestCase):
|
|||
|
||||
def test_disc_table_delete(self):
|
||||
artist = db.artist.Table.find("Test Artist", "Test Sort")
|
||||
album = db.album.Table.insert(artist, "Test Album")
|
||||
album = artist.find_album("Test Album")
|
||||
disc = db.disc.Table.find(album, 1, "subtitle")
|
||||
state = disc.playlist_state
|
||||
|
||||
|
@ -50,21 +50,21 @@ class TestDiscTable(unittest.TestCase):
|
|||
|
||||
def test_disc_table_get(self):
|
||||
artist = db.artist.Table.insert("Test Artist", "Test Sort")
|
||||
album = db.album.Table.insert(artist, "Test Album")
|
||||
album = artist.find_album("Test Album")
|
||||
disc = db.disc.Table.insert(album, 1, None)
|
||||
self.assertEqual(db.disc.Table.get(1), disc)
|
||||
self.assertIsNone(db.disc.Table.get(2))
|
||||
|
||||
def test_disc_table_lookup(self):
|
||||
artist = db.artist.Table.insert("Test Artist", "Test Sort")
|
||||
album = db.album.Table.insert(artist, "Test Album")
|
||||
album = artist.find_album("Test Album")
|
||||
disc = db.disc.Table.insert(album, 1, None)
|
||||
self.assertEqual(db.disc.Table.lookup(album, 1), disc)
|
||||
self.assertIsNone(db.disc.Table.lookup(album, "none"))
|
||||
|
||||
def test_disc_compare(self):
|
||||
artist = db.artist.Table.insert("Test Artist", "Test Sort")
|
||||
album = db.album.Table.insert(artist, "Test Album")
|
||||
album = artist.find_album("Test Album")
|
||||
disc1 = db.disc.Table.insert(album, 1, "subtitle")
|
||||
disc2 = db.disc.Table.insert(album, 2, "subtitle")
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class TestTrackTable(unittest.TestCase):
|
|||
def test_track_table_insert(self):
|
||||
library = db.library.Table.find(pathlib.Path("/a/b/c"))
|
||||
artist = db.artist.Table.find("Test Artist", "test artist")
|
||||
album = db.album.Table.insert(artist, "Test Album")
|
||||
album = artist.find_album("Test Album")
|
||||
disc = db.disc.Table.find(album, 1, None)
|
||||
decade = db.decade.Table.find(2020)
|
||||
year = decade.find_year(2021)
|
||||
|
|
|
@ -23,8 +23,7 @@ class FileTask(Task):
|
|||
|
||||
with metadata.Metadata(self.filepath) as meta:
|
||||
artist = db.artist.Table.find(meta.artist(), meta.artistsort())
|
||||
if (album := db.album.Table.lookup(artist, meta.album())) == None:
|
||||
album = db.album.Table.insert(artist, meta.album())
|
||||
album = artist.find_album(meta.album())
|
||||
disc = db.disc.Table.find(album, meta.discnumber(), meta.discsubtitle())
|
||||
decade = db.decade.Table.find(meta.decade())
|
||||
year = decade.find_year(meta.year())
|
||||
|
|
Loading…
Reference in New Issue