Commit Graph

47 Commits

Author SHA1 Message Date
Anna Schumaker 328dce0be2 scanner: Fix scanner.update_library() function
We were scheduling the CheckTask, but not following up with a
DirectoryTask to scan for new files. I use this function during the
Gtk.Application startup to automatically update the libraries.

Implements #31 (Automatically update the database during startup)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-12-28 15:50:11 -05:00
Anna Schumaker 295202443f scanner: Add a function for clearing the TaskQueue
And call this function when closing the player

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-12-28 15:50:08 -05:00
Anna Schumaker b245b2073e scanner: Rename tests
To remove a bunch of redundant names from the test functions

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-12-28 15:49:52 -05:00
Anna Schumaker 7b89f54e8b scanner: Remove the ImportTask
It is no longer needed now that we have updated from the tagdb

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-12-28 15:49:52 -05:00
Anna Schumaker a85ac03517 db: Occasionally optimize the database
I do this whenever we commit during scanning, and during application
shutdown.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-12-09 22:09:40 -05:00
Anna Schumaker 0b818bc067 db: Attach release information to albums
This lets us sort albums by original release date, so if an artist
releases multiple albums in a year we can sort by month too.
Additionally, this helps us better handle albums with the same name that
were released in different years.

Implements: #40 (Store the full date in the year table)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker ea31e1539a scanner: Adjust timing for the DirectoryChooserWidget test
Adding a brief sleep when checking main_context iterations gives the
widget a chance to update the path so the test can pass more reliably.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 3d77e8cd2a scanner: Give ImportTasks a "playlists" argument
So users don't need to re-create their playlists when switching over to
the sqlite database.

Implements: #10 (Import user playlists)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 2ab67258e9 scanner: Create an EnableSwitch
For changing a library path's "enabled" property

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 8f98dfdde7 scanner: Create an EnableLibraryTask
For enabling or disabling library paths through an idle task

Implements: Issue #37 (Create an Idle Task to enable / disable library paths)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker b8da049be9 scanner: Create a commit() shortcut function
For scheduling a commit task

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 3afaea664b scanner: Set initial ProgressBar visibility based on queue length
ProgressBars might be created after tasks have been pushed onto the
queue. Instead of setting initial visibility to False unconditionally,
we can check if queue length is greater than 1

Fixes: Issue #9 (Fix ProgressBar initial visibility)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:24 -05:00
Anna Schumaker 53c61160bc scanner: Add release date to the track metadata parser
This gives us a datetime.date() structure filled in with the release
date of the track.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-11-18 10:20:23 -05:00
Anna Schumaker 932663f872 db: Remove the PlaylistMap objects
We can now do everything it did and more through the various user
playlist objects.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:25:02 -04:00
Anna Schumaker bba00b3d27 db: Remove the GenreMap object
We can now do everything it did and more through the Genre playlist
object.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-27 11:25:02 -04:00
Anna Schumaker 5ff03cf33f db: Give MappedPlaylists add_track() and remove_track() functions
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-18 15:50:07 -04:00
Anna Schumaker 063b93b66f db: Convert the TrackTable into a table.Table
Implements: Issue #11 (Cache database items fields)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-15 16:09:59 -04:00
Anna Schumaker 67238ed385 db: Give Albums a find_disc() function
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 17:03:19 -04:00
Anna Schumaker 737d135d41 db: Give Artists a find_album() function
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
Anna Schumaker a1f54839bb db: Convert the AlbumTable into a playlist.ChildModel
Implements: Issue #11 (Cache database items fields)
Implements: Issue #14 (Convert Tables into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
Anna Schumaker 0728579cc4 db: Convert the ArtistTable into a playlist.Model
Implements: Issue #11 (Cache database items fields)
Implements: Issue #14 (Convert Tables into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
Anna Schumaker 90c6593921 db: Give Decades a find_year() function
And adjust the Year table and Track table to take a Decade as an
argument.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
Anna Schumaker 4141ca211c db: Convert the YearTable into a playlist.ChildModel
Implements: Issue #11 (Cache database items fields)
Implements: Issue #14 (Convert Tables into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
Anna Schumaker e6a65f8fe3 db: Convert the LibraryTable into a table.Model
I actually turn it into a playlist.Model, which is a table.Model that
handles playlist states for us.

Implements: Issue #11 (Cache database items fields)
Implements: Issue #14 (Convert Tables into Gio.ListModels)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-14 13:22:57 -04:00
Anna Schumaker a4fbd5f2f3 db: Rename playlist.py -> user.py
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-11 11:58:43 -04:00
Anna Schumaker 9cf1df7c33 db: Move SQLite Connection stuff into a new file
I find this cleaner than importing from the toplevel module

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-10-07 13:58:09 -04:00
Anna Schumaker 98ef8bf3f3 scanner: Add shortcuts for creating widgets
These use the global queue instance to create appropriate widgets with
the same name.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-30 11:34:19 -04:00
Anna Schumaker 5f6f3f9f42 scanner: Create a global Queue instance
And some convenience functions for using it

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-30 11:13:49 -04:00
Anna Schumaker e09d892a46 scanner: Create a custom AddFolderButton widget
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-30 11:13:49 -04:00
Anna Schumaker 0157b1d4c0 scanner: Create a custom DirectoryChooser widget
It is set up to view and select directories only, with a shortcut added
for the user's Music directory.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-30 11:13:49 -04:00
Anna Schumaker 7535b71724 scanner: Create a custom UpdateAllButton widget
For updating all libraries in the database.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-30 11:13:49 -04:00
Anna Schumaker 8f837b40c1 scanner: Create a custom RemoveButton widget
For removing a specific library from the database.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-30 11:13:49 -04:00
Anna Schumaker 5e08088462 scanner: Create a custom UpdateButton widget
When clicked, it updates a specific Library instance

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-30 11:13:49 -04:00
Anna Schumaker 94b53aff5f scanner: Create a custom ProgressBar widget
For use tracking the progress we make through the TaskQueue

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-30 11:13:49 -04:00
Anna Schumaker a102087ece scanner: Create a TaskQueue
For running tasks with a GLib idle callback

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-30 11:13:48 -04:00
Anna Schumaker da78887783 scanner: Add a RemoveLibraryScheduler task
For breaking the tracklist into chunks, and then following up their
removal with a library table removal

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:11:12 -04:00
Anna Schumaker 88ebde085b scanner: Add a RemoveLibraryTask
For removing a library's database entry

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:11:08 -04:00
Anna Schumaker 0f57b10500 scanner: Add a RemoveTask
For unconditionally removing a list of tracks

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:11:05 -04:00
Anna Schumaker 19278af3b8 scanner: Add a CheckSchedulerTask
This task breaks a library's tracks into chunks and schedules a
CheckTask for each chunk.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:11:02 -04:00
Anna Schumaker 8946df3ce4 scanner: Add a CheckTask for checking if tracks still exist
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:10:59 -04:00
Anna Schumaker 7ea14392ec scanner: Add a DirectoryTask
For iterating through a directory and creating tasks based on the files
found. I had to add a subdirectory to the Test Album to make sure
subdirs are handled properly here.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:10:55 -04:00
Anna Schumaker 9cced017ad scanner: Add an ImportTask
For importing tracks from the tagdb

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:10:27 -04:00
Anna Schumaker 3402ce16ee scanner: Add a new FileTask for scanning music files
This task is also responsible for checking if the file already exists in
the database before scanning.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:06:58 -04:00
Anna Schumaker 91d0922518 scanner: Add a CommitTask
For committing the database during scanning

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:06:55 -04:00
Anna Schumaker 065c192714 scanner: Add a base class for queued Tasks
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:06:52 -04:00
Anna Schumaker 73646fc106 scanner: Have Metadata gracefully handle self.file == NULL
So we don't need to wrap the context manager in a try / except block

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:06:50 -04:00
Anna Schumaker a28d4d4b8e scanner: Copy the Metadata code from lib/
And add an extra function for disc subtitles.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-08-26 17:06:47 -04:00