Commit Graph

1334 Commits

Author SHA1 Message Date
Anna Schumaker 1beb3cf869 curds: Replace track.add() with track.lookup()
Now that we have a "new-track" notification, we can replace the add
function with a lookup function that more closely mirrors how we look up
album tags.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-11 17:09:36 -04:00
Anna Schumaker 8a4d3219d2 curds: Create "new-album" and "new-track" notifications
And update the playlist manager to use the new-track, rather than
relying on "on-scan"

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-11 17:02:59 -04:00
Anna Schumaker 752ebece3d curds: Make playlist notifications more generic
We might want to use these outside of the playlist code, so let's move
this to a generic place so it can be easily used.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-11 16:48:51 -04:00
Anna Schumaker 64ab13718c trier: Fix path for a track
The slash in the filepath was being intepreted as a subdirectory, so
let's change it into an underscore so everything is where we expect.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-11 12:10:38 -04:00
Anna Schumaker 96ea582522 curds: Add a Collection playlist
This playlist collects all tracks that the user has added, across all
libraries.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-11 11:54:49 -04:00
Anna Schumaker f53eaa8028 curds: Only trigger "on-scan" when new tracks are created
This cuts down on unnecessary notifications for tracks that already
exist.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-11 11:21:38 -04:00
Anna Schumaker 7b1fac0bfb curds: Create a playlist manager class
This replaces the code in playlist/__init__.py and turns it into a
class. This should make things easier to handle during testing, since we
can easily tear down the old instance and create a new one.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-11 11:01:49 -04:00
Anna Schumaker 464631c0d6 curds: Clean up package imports
Create some shortcuts to make the interface easier to work with.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-11 10:09:24 -04:00
Anna Schumaker a751bb4f61 curds: Add a way to cancel notifications
I expect this will mostly get used by testing code as we create and
delete a bunch of different objects.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-11 09:39:32 -04:00
Anna Schumaker a2037d6c59 curds: Begin implementing a playlist manager
This will give us a single place for the UI to look up and control
playlists.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-08 16:33:48 -05:00
Anna Schumaker 713e8b2dd3 curds: Add a playlist notifications system
This is mostly needed by the UI but there are a few cases where we
might need it internally, such as adding newly creating tracks to all
the required playlists.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-08 10:58:35 -05:00
Anna Schumaker b9a563024f curds: Add library playlist
This playlist represents all tracks in a given subdirectory, and is how
we control adding or removing tracks.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-08 08:26:12 -05:00
Anna Schumaker e0763ec727 curds: Add basic playlist class
The intention is that different playlist types will create a subclass of
this class to do whatever work they need.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-07 17:00:58 -05:00
Anna Schumaker 99f103d345 curds: Make Tracks indexable
This lets us convert string fields into the corresponding track tag. I
intend to use this so playlists can have a custom sort function.

I eventually intend to add the matching __setitem__() function for
changing tags.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-07 09:28:04 -05:00
Anna Schumaker 2057721028 Add a toplevel script
I'll eventually need to be able to run everything as a single
application, so let's prepare for that now. This gives us a chance to
get the imports right from the start, rather than needing to go through
and fix things up again.

I also add a test to make sure everything works as expected.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-06 09:23:25 -05:00
Anna Schumaker 5908a8af50 curds: Add save() and load() functions
These functions pickle out the entire tag map onto disk. I also add a
stress test for the entire tags module that scans tracks using the
threadqueue, since that's how I intend everything to be used.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-05 16:50:01 -05:00
Anna Schumaker c28e06730b curds: Add helpful functions to the DataFile
There are cases, mostly during testing, where we might want to check if
a file exists or to remove it if it does.  Let's add those functions
now so we can use them.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-05 16:49:00 -05:00
Anna Schumaker 60f56ba3b7 curds: Add a Track Tag class
This is similar to the Album tag and stores its data in the same
dictionary.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-05 16:48:30 -05:00
Anna Schumaker 04ac4398e2 curds: Create a generic Tags class
I've decided that it would work best if Album and Track classes both
inherit from the same parent class. This will give them some
functionality overlap, and it'll also make it conceptually easier to
store them both in the same tag dictionary.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-05 15:51:51 -05:00
Anna Schumaker c4c0c09d46 Add coverage file to .gitignore
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-05 14:14:19 -05:00
Anna Schumaker a3fd248c94 curds: Create a ThreadQueue class
We'll use this for scanning tracks, searching musicbrainz, and fetching
album art. The web services are ratelimited, so it doesn't make sense to
use more than one thread in this case. Additionally, scanning tracks
works best as a single thread since we end up holding a lock the entire
function anyway to prevent duplicates.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-03 19:53:40 -05:00
Anna Schumaker 29608caddb curds: Remove the data_file_path() function
Now that we have the DataFile class we can remove this function as its
main use is now hidden from users.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-02 16:37:39 -05:00
Anna Schumaker 2c538771a3 curds: Add a class for pickling and unpickling objects
This gives us a convenient way to handle saved data. We use the 'with'
statment to handle any errors without crashing.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-03-02 16:24:52 -05:00
Anna Schumaker f56e6764a8 curds: Clean up unused code
I added a make target for code coverage, and used that to identify code
that isn't getting run.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-02-15 16:09:09 -05:00
Anna Schumaker 1eac742bc4 curds: Move the ThreadPoolExecutor into the track code
I think it makes sense to do this transparently through the Track code
so higher layers don't have to do as much work.  We'll just return a
Future-object corresponding to the track that will be added.

It makes sense to only have one thread in this case, since __add() needs
exclusive access to the track_list for its entire execution.  Anything
more would just create conflicts and actually increase execution time.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-02-15 15:54:00 -05:00
Anna Schumaker 2c022163ad curds: Create a single place to get a path to a data file
It's useful to have a way to override where data gets placed in the
filesystem so we don't accidentally clobber production data with test
data while running tests.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-02-14 08:08:42 -05:00
Anna Schumaker 0705f86d81 curds: Add a test for parallel track scanning
And add code for generating a large test library to make stress testing
possible.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-02-06 14:35:35 -05:00
Anna Schumaker 9b64c590cc curds: Switch to using the asyncio module for testing threading
I'm planning to use the asyncio code for running background threads, so
let's switch to it for now to get a feel for how it works.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-02-05 16:20:31 -05:00
Anna Schumaker 2a98aac6de curds: Keep a list of created tracks
We'll use this for scanning and updating the library later.  For now,
just keep everything in a list and do a uniqueness test whenever
something new is added.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-02-04 17:02:04 -05:00
Anna Schumaker c66405bd80 curds: Add basic track class
We account for some fallback values, and also attempt to detect
discnumbers from the album name.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-02-04 17:01:52 -05:00
Anna Schumaker a26e8867fe curds: Try to detect album names that embed a discnumber
We want to be able to pull out just the album name to make a more
accurate musicbrainz search, and so multiple discs link to the same
album object.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-01-28 17:00:40 -05:00
Anna Schumaker 306fa0f40c curds: Add function for album lookups
We want to share album objects whenever possible, so add a lookup
function for checking this.  Python built-in objects (like dictionaries)
are supposedly threadsafe, so we don't need a lock to access them but I
added the threadpool test anyway just in case.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-01-28 16:06:37 -05:00
Anna Schumaker 3b42ca233e curds: Add basic album class
We'll eventually pull out all the fields we need from a Mutagen
FileInfo class, but that has a dictionary-like interface so we can
easily fake one up for testing.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2019-01-24 16:27:25 -05:00
Anna Schumaker eecc32359f Initial commit 2019-01-24 09:35:41 -05:00