Compare commits

...

1195 Commits

Author SHA1 Message Date
Keith Edmunds
8956642e05 Remove unused import. 2026-01-04 13:58:57 +00:00
Keith Edmunds
791fad680a Clean up old error logging; log excessive jitter. 2026-01-04 13:54:14 +00:00
Keith Edmunds
8c60d6a03d Jitter monitor phase 0 2026-01-03 21:37:50 +00:00
Keith Edmunds
7391b4e61c Start header in column zero 2026-01-03 18:44:36 +00:00
Keith Edmunds
266be281d0 Don't run update_track_times twice on starting track 2026-01-02 14:34:28 +00:00
Keith Edmunds
ac487a5fa5 Make vlc volume default 100 2026-01-01 17:18:58 +00:00
Keith Edmunds
7d1bb0d3f7 Escape double quotes in filename 2025-12-14 15:58:35 +00:00
Keith Edmunds
e8d9cf8f00 Ensure track marked as played in playlist
Fixes #295
2025-09-26 00:38:44 +01:00
Keith Edmunds
7e7ae7dddf Tidy config 2025-09-25 15:07:30 +01:00
Keith Edmunds
25cb444335 Set default volumen to 80% 2025-09-25 14:53:30 +01:00
Keith Edmunds
fa14fc7c52 Fixup reloading track from Audacity 2025-08-23 12:18:06 +01:00
Keith Edmunds
6e51e65ba8 Add .gitattibutes to define python diffing 2025-08-23 12:17:42 +01:00
Keith Edmunds
19b1bf3fde Fix type hint error 2025-08-17 18:42:01 +01:00
Keith Edmunds
316b4708c6 Check import filetype; install black 2025-08-17 18:26:53 +01:00
Keith Edmunds
4fd9a0381f Hide tracks, not sections 2025-08-16 15:10:45 +01:00
Keith Edmunds
88cce738d7 Move AudacityController management from playlists to musicmuster
Fixes: #292
2025-08-16 15:10:15 +01:00
Keith Edmunds
9720c11ecc Don't track kae.py in git 2025-03-29 18:20:13 +00:00
Keith Edmunds
ca4c490091 Add log_call decorator and issue 287 logging 2025-03-29 18:19:14 +00:00
Keith Edmunds
1749f0a0b8 Actually add tracks chosen from query 2025-03-13 10:41:56 +00:00
Keith Edmunds
c9ff1aa668 Improver performance loading playlists 2025-03-09 19:23:55 +00:00
Keith Edmunds
49776731bf Merge branch 'dev' 2025-03-09 17:26:10 +00:00
Keith Edmunds
9bf1ab29a8 Fixup tests after data() return type fixups 2025-03-09 16:41:28 +00:00
Keith Edmunds
4e51b44b44 More work on data() return types 2025-03-09 16:40:19 +00:00
Keith Edmunds
582803dccc Put more info in ApplicationError dialog
Show it after dumping error to stderr
2025-03-09 16:34:53 +00:00
Keith Edmunds
5f9fd31dfd Merge branch 'issue285' into dev 2025-03-08 21:38:11 +00:00
Keith Edmunds
74402f640f Only invalidate required roles 2025-03-08 21:36:09 +00:00
Keith Edmunds
963da0b5d0 No db calls when servicing data() except for caching 2025-03-08 21:30:37 +00:00
Keith Edmunds
85493de179 Remove profiling decorators 2025-03-08 12:03:47 +00:00
Keith Edmunds
2f8afeb814 WIP Issue 285 2025-03-08 12:02:07 +00:00
Keith Edmunds
3b004567df Implement dogpile cache for Notecolours 2025-03-08 11:45:38 +00:00
Keith Edmunds
76039aa5e6 Only try to show ApplicationError dialog when we have a QApplication 2025-03-08 11:42:59 +00:00
Keith Edmunds
1f10692c15 Make notes substring unique 2025-03-08 09:57:04 +00:00
Keith Edmunds
6dd34b292f Improve ApplicationError reporting 2025-03-07 15:44:21 +00:00
Keith Edmunds
77a9baa34f Merge branch 'dev' 2025-03-07 10:00:09 +00:00
Keith Edmunds
6e2ad86fb2 Merge branch 'mark_preview' into dev 2025-03-07 09:59:32 +00:00
Keith Edmunds
be54187b48 Remove old files 2025-03-07 09:46:49 +00:00
Keith Edmunds
6d56a94bca Don't track .venv 2025-03-07 09:43:19 +00:00
Keith Edmunds
ccc1737f2d Issue 285: additional logging and profiling 2025-03-07 09:30:23 +00:00
Keith Edmunds
58e244af21 Add profiling information for moving rows 2025-03-06 14:30:03 +00:00
Keith Edmunds
93839c69e2 Remove main_window_ui.py 2025-03-06 14:27:42 +00:00
Keith Edmunds
61b00d8531 Put preview track details in status bar 2025-03-06 14:26:47 +00:00
Keith Edmunds
63b1d0dff4 mypy fixups 2025-03-06 11:33:53 +00:00
Keith Edmunds
2293c663b9 Migrate from poetry to uv 2025-03-05 19:05:13 +00:00
Keith Edmunds
f5c77ddffd Merge query tabs 2025-03-05 15:16:24 +00:00
Keith Edmunds
1cf75a5d42 More query tests and remove Optional from Filter 2025-03-05 14:27:19 +00:00
Keith Edmunds
7fd655f96f WIP: queries working, tests so far good 2025-03-05 09:00:41 +00:00
Keith Edmunds
096889d6cb Fix up tests in light of recent changes 2025-03-04 13:22:29 +00:00
Keith Edmunds
67c48f5022 Select from query working (may need tidying) 2025-03-04 10:32:11 +00:00
Keith Edmunds
8e48d63ebb WIP: queries management
Menus and management working. Wrong tracks showing up in queries.
2025-03-02 19:14:53 +00:00
Keith Edmunds
aa6ab03555 Make manage queries and manage templates into classes 2025-02-28 11:25:29 +00:00
Keith Edmunds
fc02a4aa7e Merge branch 'bug283' into dev 2025-02-28 09:21:47 +00:00
Keith Edmunds
6223ef0ef0 Don't allow deletion of current or next track
Fixes: #283
2025-02-28 09:21:22 +00:00
Keith Edmunds
76e6084419 Try to speed up tab switching 2025-02-27 18:21:55 +00:00
Keith Edmunds
90d72464cb Clean up handling of separators in dynamic menu 2025-02-27 08:13:29 +00:00
Keith Edmunds
82e707a6f6 Make filter field in queries table non-nullable 2025-02-27 08:12:48 +00:00
Keith Edmunds
b4f5d92f5d WIP: query management 2025-02-26 13:58:13 +00:00
Keith Edmunds
985629446a Create queries table 2025-02-26 13:34:10 +00:00
Keith Edmunds
64ccb485b5 Fix playdates cascade deletes 2025-02-26 13:29:42 +00:00
Keith Edmunds
3f248d363f rebase from dev 2025-02-23 21:06:42 +00:00
Keith Edmunds
40756469ec WIP query tabs 2025-02-23 21:06:42 +00:00
Keith Edmunds
306ab103b6 Add favourite to queries table 2025-02-23 21:06:42 +00:00
Keith Edmunds
994d510ed9 Move querylistmodel from SQL to filter 2025-02-23 21:06:42 +00:00
Keith Edmunds
8b8edba64d Add Filter class to classes 2025-02-23 21:06:42 +00:00
Keith Edmunds
678515403c Guard against erroneous SQL statements in queries 2025-02-23 21:06:42 +00:00
Keith Edmunds
e6404d075e Query searches working
More UI needed
2025-02-23 21:06:42 +00:00
Keith Edmunds
7c0db00b75 Create databases in dbmanager 2025-02-23 21:06:42 +00:00
Keith Edmunds
e4e061cf1c Add open querylist menu 2025-02-23 21:06:42 +00:00
Keith Edmunds
61021b33b8 Fix hide played button 2025-02-23 21:06:42 +00:00
Keith Edmunds
a33589a9a1 "=" header fixes
Fixes: #276
2025-02-23 21:06:42 +00:00
Keith Edmunds
3547046cc1 Misc cleanups from query_tabs branch 2025-02-23 21:06:41 +00:00
Keith Edmunds
95983c73b1 Log to stderr timer10 stop/start 2025-02-23 21:06:41 +00:00
Keith Edmunds
499c0c6b70 Fix "=" header
Fixes: #276
2025-02-23 21:06:41 +00:00
Keith Edmunds
33e2c4bf31 Fix order of playdates on hover
Fixes: #275
2025-02-23 21:06:41 +00:00
Keith Edmunds
589a664971 New template from manage templates correctly marked in db 2025-02-23 17:34:23 +00:00
Keith Edmunds
67bf926ed8 Refactor musicmuster and template management 2025-02-23 17:28:03 +00:00
Keith Edmunds
040020e7ed Refactor playlist management functions 2025-02-23 17:26:43 +00:00
Keith Edmunds
911859ef49 Show red start in tab of templates 2025-02-23 17:24:47 +00:00
Keith Edmunds
68bdff53cf Move menu.yaml into app/ 2025-02-23 09:20:30 +00:00
Keith Edmunds
632937101a WIP dynamic menu for playlist
New playlist shows faves on submenu
2025-02-22 22:27:05 +00:00
Keith Edmunds
639f006a10 Add favourite to playlists 2025-02-22 20:23:07 +00:00
Keith Edmunds
9e27418f80 Remove queries table definition
It mistakenly was introduced to the wrong branch. It persists on the
query_tabs branch.
2025-02-22 20:13:44 +00:00
Keith Edmunds
c1448dfdd5 WIP: manage templates: template rows have different background 2025-02-22 19:42:48 +00:00
Keith Edmunds
5f396a0993 WIP: template management: new, rename, delete working 2025-02-22 19:16:42 +00:00
Keith Edmunds
e10c2adafe WIP: template management: edit and delete working 2025-02-22 11:34:36 +00:00
Keith Edmunds
b0f6e4e819 Framework for dynamic submenus 2025-02-21 15:18:45 +00:00
Keith Edmunds
afd3be608c Move menu definitions to YAML file 2025-02-21 14:16:34 +00:00
Keith Edmunds
aef8cb5cb5 Fix hide played button 2025-02-15 10:39:26 +00:00
Keith Edmunds
53664857c1 "=" header fixes
Fixes: #276
2025-02-14 21:45:23 +00:00
Keith Edmunds
c8b571b38f Misc cleanups from query_tabs branch 2025-02-14 21:44:20 +00:00
Keith Edmunds
b3bd93d71c Only have one db.create_all(), and that in dbmanager 2025-02-14 21:39:10 +00:00
Keith Edmunds
57ffa71c86 Log to stderr timer10 stop/start 2025-02-14 19:49:13 +00:00
Keith Edmunds
a8a38fa5b7 Fix "=" header
Fixes: #276
2025-02-14 19:38:06 +00:00
Keith Edmunds
24b5cb5fe0 Fix order of playdates on hover
Fixes: #275
2025-02-14 19:27:47 +00:00
Keith Edmunds
955bea2037 Query tabs WIP 2025-02-11 21:11:56 +00:00
Keith Edmunds
5ed7b822e1 Put menus in correct order 2025-02-11 19:55:07 +00:00
Keith Edmunds
b40c81e79a Split UI into section files; remove infotabs 2025-02-11 18:18:25 +00:00
Keith Edmunds
7a98fe3920 Create queries table; set up cascade deletes 2025-02-07 16:58:26 +00:00
Keith Edmunds
6792b2a628 Better management of hiding played sections
Only scroll if top visible line is above current header.
2025-02-07 12:54:44 +00:00
Keith Edmunds
c12b30a956 Add pyyaml 2025-02-06 12:56:59 +00:00
Keith Edmunds
256de377cf Update environment 2025-02-06 12:54:01 +00:00
Keith Edmunds
a3c405912a Fixup logging when no module log.debug output specifed 2025-02-05 18:07:22 +00:00
Keith Edmunds
4e73ea6e6a Black formatting 2025-02-05 17:46:16 +00:00
Keith Edmunds
c9b45848dd Refine and fix file_importer tests 2025-02-05 17:43:38 +00:00
Keith Edmunds
fd0d8b15f7 Poetry only for dependency management 2025-02-02 17:54:44 +00:00
Keith Edmunds
7d0e1c809f Update environment 2025-02-02 17:52:15 +00:00
Keith Edmunds
5cae8e4b19 File importer - more tests 2025-02-01 22:11:01 +00:00
Keith Edmunds
8177e03387 Tweak pyproject.toml for v2 2025-01-31 10:00:55 +00:00
Keith Edmunds
f4923314d8 Remove spurious logging. Start 10ms timer at a better time.
The 10ms timer was paused for five seconds when starting a track to
avoid a short pause (issue #223). That fixed the problem. However, it
doesn't need to be started until the fade graph starts changing, so we
now don't start it until then. It's possible that this may help the
occasional 'slow to refresh after moving tracks' issue that has been
seen which may be caused by timer ticks piling up and needing to be
serviced.
2025-01-31 09:55:21 +00:00
Keith Edmunds
24787578bc Tweaks to FileImporter and tests 2025-01-31 09:55:21 +00:00
Keith Edmunds
1f4e7cb054 Cleanup around new logging 2025-01-31 09:55:21 +00:00
Keith Edmunds
92e1a1cac8 New FileImporter working, tests to be written 2025-01-31 09:55:21 +00:00
Keith Edmunds
52a773176c Refine module and function logging to stderr 2025-01-31 09:55:21 +00:00
Keith Edmunds
cedc7180d4 WIP: FileImporter runs but needs more testing 2025-01-31 09:55:21 +00:00
Keith Edmunds
728ac0f8dc Add function name to console log output 2025-01-31 09:55:21 +00:00
Keith Edmunds
4741c1d33f Make failure to connect to OBS a warning, not error 2025-01-31 09:55:21 +00:00
Keith Edmunds
aa52f33d58 Fixup new logging 2025-01-31 09:55:21 +00:00
Keith Edmunds
2f18ef5f44 Cascade deleted tracks to playlist_rows and playdates 2025-01-31 09:55:21 +00:00
Keith Edmunds
4927f237ab Use locking when creating singleton 2025-01-31 09:55:21 +00:00
Keith Edmunds
d3a709642b Migrate pyproject.toml to v2 2025-01-31 09:54:14 +00:00
Keith Edmunds
3afcfd5856 Move to YAML-configured logging 2025-01-27 12:13:13 +00:00
Keith Edmunds
342c0a2285 Add type hints for pyyaml 2025-01-27 12:13:13 +00:00
Keith Edmunds
8161fb00b3 Add pyyaml; update poetry environment 2025-01-27 12:13:13 +00:00
Keith Edmunds
f9943dc1c4 WIP file_importer rewrite, one test written and working 2025-01-21 21:26:06 +00:00
Keith Edmunds
b2000169b3 Add index to notecolours 2025-01-18 11:02:56 +00:00
Keith Edmunds
5e72f17793 Clean up type hints 2025-01-17 21:35:29 +00:00
Keith Edmunds
4a4058d211 Import rewrite WIP 2025-01-13 15:29:50 +00:00
Keith Edmunds
3b71041b66 Remove profiling calls (again) 2025-01-10 20:37:49 +00:00
Keith Edmunds
d30bf49c88 Don't select unplayable track as next track 2025-01-10 20:27:26 +00:00
Keith Edmunds
3a3b1b712d Much improved file importer 2025-01-10 19:50:53 +00:00
Keith Edmunds
85cfebe0f7 Fix crash importing files 2025-01-01 13:13:54 +00:00
Keith Edmunds
e23f6e2cc8 Make getting current row safer 2024-12-30 08:39:01 +00:00
Keith Edmunds
68e524594d Recover from git cockup: reimplement template management 2024-12-29 18:34:44 +00:00
Keith Edmunds
a8931e8b2b Remove references to 'deleted' column 2024-12-29 18:18:39 +00:00
Keith Edmunds
6c05ed8c6f Revert "Implement template management"
This reverts commit 02c0c9c861.

Bugfix to be added
2024-12-29 18:15:27 +00:00
Keith Edmunds
02c0c9c861 Implement template management
Allow template edits and deletions. Deletions are now true deletes,
not just flagged in database as deletes, and this applies to all
playlists. Includes schema changes to cascade deletes.
2024-12-29 18:06:31 +00:00
Keith Edmunds
72930605db Implement File|New to create from template (possibly empty) 2024-12-29 14:32:32 +00:00
Keith Edmunds
712c965095 Clean up data structures in musicmuster.py
Replace self.playlists and self.selection with self.current and a new
Current() class
2024-12-28 17:16:19 +00:00
Keith Edmunds
4bff1a8b59 Update musicmuster to use self.selection 2024-12-28 12:53:19 +00:00
Keith Edmunds
e55fab71cf Clean up direct references to playlist tab from musicmuster 2024-12-28 10:06:33 +00:00
Keith Edmunds
7ce07c1cc7 Handle hide sections/tracks better 2024-12-27 20:01:46 +00:00
Keith Edmunds
839467a5e3 Resove active/proxy model coding 2024-12-27 19:48:16 +00:00
Keith Edmunds
e5dc3dbf03 Fix adding duplicate track and merging comments
Fixes #271
2024-12-26 15:05:07 +00:00
Keith Edmunds
3fde474a5b Save proxy model example in archive 2024-12-26 14:10:26 +00:00
Keith Edmunds
b14b90396f Major update: correct use of proxy model
Fixes #273
2024-12-26 14:09:21 +00:00
Keith Edmunds
937f3cd074 Fix search
Fixed #272
2024-12-23 21:20:59 +00:00
Keith Edmunds
cb16a07451 Menu reorganised. Other minor cleanups. 2024-12-23 19:19:01 +00:00
Keith Edmunds
6da6f7044b Add tooltip to radio buttons on import file choices 2024-12-22 17:26:33 +00:00
Keith Edmunds
a1709e92ae Misc tidying 2024-12-22 15:23:22 +00:00
Keith Edmunds
b389a348c1 Remove mtime from Track 2024-12-22 15:23:04 +00:00
Keith Edmunds
4c53791f4d Rewrite file importer 2024-12-22 15:22:21 +00:00
Keith Edmunds
d400ba3957 Make AudioMetadata a NamedTuple 2024-12-22 15:16:02 +00:00
Keith Edmunds
6e258a0ee2 Split music_manager from classes 2024-12-22 15:14:00 +00:00
Keith Edmunds
205667faa1 Tighten up AudacityController type hints 2024-12-22 15:11:30 +00:00
Keith Edmunds
d9abf72f6a Fix section hiding
We were suppressing hiding when section contained previous track.

Now, when all are played, we hide.
2024-12-21 16:40:51 +00:00
Keith Edmunds
96807a945c Resize rows in config-defined chunks 2024-12-17 20:55:25 +00:00
Keith Edmunds
b9cb7cc326 Fixup section hiding 2024-12-16 22:23:01 +00:00
Keith Edmunds
efde8fe7bc Implement hiding played sections 2024-12-14 20:46:19 +00:00
Keith Edmunds
b16845f352 Add return type hint 2024-12-14 19:42:14 +00:00
Keith Edmunds
42b5c2413c Fix "=" subtotal line 2024-12-14 17:34:46 +00:00
Keith Edmunds
2ce6eb95ed Remove "ago" from last played string 2024-12-14 17:11:35 +00:00
Keith Edmunds
734960e0f3 Set row padding in preferences 2024-12-14 17:11:16 +00:00
Keith Edmunds
17d88ca8fe Optionally remove colour codes from non-timing headers 2024-12-14 15:37:33 +00:00
Keith Edmunds
954b404031 Don't show deleted templates 2024-12-14 14:56:27 +00:00
Keith Edmunds
0391eed88e Optionally remove header colour directives from header 2024-12-14 14:49:07 +00:00
Keith Edmunds
f7f4cdc622 Implement header row foreground colour 2024-12-14 12:01:41 +00:00
Keith Edmunds
b7b825f0ef Restart Alembic migations
Alembic was generating empty migraiton files. Restart Alembic
from scracth which resolved problem.
2024-12-14 11:58:54 +00:00
Keith Edmunds
3c8f5910df Add notes to .envrc 2024-12-14 11:56:37 +00:00
Keith Edmunds
cc01d04fb8 Remove section timing marks from displayed headers 2024-12-14 10:22:25 +00:00
Keith Edmunds
ac18773ebd Merge branch 'dev' 2024-12-13 21:37:11 +00:00
Keith Edmunds
61dcf7fc91 Don't bring Audacity to focus when starting app 2024-12-13 12:54:48 +00:00
Keith Edmunds
d0d3d5b09a Allow combined +- in header rows 2024-12-13 12:48:05 +00:00
Keith Edmunds
ba32473f06 Fix header row heights too large 2024-12-13 12:45:42 +00:00
Keith Edmunds
642e8523a2 Add profiling for drop_event 2024-12-13 10:02:13 +00:00
Keith Edmunds
2a93113c3f merge in expanding edit box changes 2024-12-12 18:08:05 +00:00
Keith Edmunds
e29c7ed0ff Add in delegate for spinbox 2024-12-12 18:02:58 +00:00
Keith Edmunds
0b30a02dde Row resizing WIP
Resizing works, code is clean, rows not too tall, IntegerDelegate to
be provided still.
2024-12-11 22:37:39 +00:00
Keith Edmunds
07d8ce9c41 Add type hints for profiling calls 2024-12-11 22:35:11 +00:00
Keith Edmunds
4860c9f188 Expang edit box working, code untidy 2024-12-11 15:34:48 +00:00
Keith Edmunds
d7751008bd Merge dev 2024-12-11 12:49:01 +00:00
Keith Edmunds
558554d086 Implement "remove comments"
Fixes #185
2024-12-09 08:45:41 +00:00
Keith Edmunds
417bff8663 Put mark/move on context menu 2024-12-08 22:36:05 +00:00
Keith Edmunds
eaac2ef4ca Handle moving next track between playlists
Fixes #266
2024-12-08 17:00:22 +00:00
Keith Edmunds
17ab9c1c65 Temp changes for profiling 2024-12-07 21:10:24 +00:00
Keith Edmunds
2c19981cd8 Add icons to playlist tabs
Green on tab currently playing
Yellow on next tab if different

Fixes #245
2024-12-07 21:09:54 +00:00
Keith Edmunds
27261ff871 Only highlight current/next track in correct playlist
Fixes #259
2024-12-06 21:55:04 +00:00
Keith Edmunds
57765a64a7 Temp changes for profiling 2024-12-05 17:42:46 +00:00
Keith Edmunds
c7253e2211 Fix MariaDB bug workaround
Fixes #265
2024-12-02 18:56:00 +00:00
Keith Edmunds
ecd5c65695 Put cursor at click position on edit
Fixes #150
2024-12-01 15:31:43 +00:00
Keith Edmunds
8c33db170d Add profiling calls 2024-11-28 06:59:10 +00:00
Keith Edmunds
5d5277b028 Minor Audacity interface cleanups 2024-11-27 13:01:10 +00:00
Keith Edmunds
28897500c8 Improve Audacity connections
Replace pipeclient with much simpler audacity_controller
Better error checking
Deal with Audacity going away
Fixes #264
2024-11-27 10:54:04 +00:00
Keith Edmunds
ac2e811ed6 Remove all profiling calls 2024-11-24 21:56:12 +00:00
Keith Edmunds
0737c58dff Add indexes to PlaylistRowsTable 2024-11-23 07:27:49 +00:00
Keith Edmunds
fabf3e18bf Re-add profiling calls 2024-11-23 07:24:03 +00:00
Keith Edmunds
f19fc2e8c0 Remove dummy_for_profiling parameters 2024-11-16 13:06:35 +00:00
Keith Edmunds
40b5fc020d Fix playlist_rows row_number corruption 2024-11-16 13:04:39 +00:00
Keith Edmunds
98a8e20baa Move track to under current makes it next track
Fixes #261
2024-11-16 13:04:11 +00:00
Keith Edmunds
3cec08db85 Remove profiler decorations 2024-11-16 13:03:10 +00:00
Keith Edmunds
f5b26028f5 Improve RowAndTrack repr 2024-11-16 13:02:21 +00:00
Keith Edmunds
4c420d01ca Preserve row order when moving rows 2024-11-16 10:44:30 +00:00
Keith Edmunds
7cfd2a45a2 Speed up moving rows
Fixes #262
Fixed #260
2024-11-16 09:58:08 +00:00
Keith Edmunds
b4fcd5f2c9 Don't try to move rows if no rows selected
Fixes #263
2024-11-15 21:38:24 +00:00
Keith Edmunds
ff81447902 Update environment 2024-11-10 14:59:00 +00:00
Keith Edmunds
00b4f9ac54 Ignore profile_output files 2024-11-08 09:33:15 +00:00
Keith Edmunds
61adc43b45 Add profiling to paste_rows and related functions 2024-11-01 15:18:47 +00:00
Keith Edmunds
3783996ba4 Handle file not found when scanning track 2024-11-01 11:47:38 +00:00
Keith Edmunds
2ce7f671ba Ensure new playlists are marked as open 2024-10-27 19:35:41 +00:00
Keith Edmunds
2fb1974598 Upgrade environment; remove snoop 2024-10-11 15:33:56 +01:00
Keith Edmunds
3d83de20c2 Show Wikipedia/Songfacts on next track if none selected 2024-08-18 11:13:20 +01:00
Keith Edmunds
42ebf2fa7b Remove deep_rows query
Aim to fix sometimes slow moving of rows. Data from the 'deep' part is
no longer used anyway.

Fixes #258
2024-08-09 12:55:43 +01:00
Keith Edmunds
0bcb785b30 Update and clean dependencies 2024-08-05 12:46:10 +01:00
Keith Edmunds
84798fb1c5 Update and clean dependencies 2024-08-05 12:45:52 +01:00
Keith Edmunds
8f94dc6c4f Black formatting and mypy fixups 2024-08-05 08:24:54 +01:00
Keith Edmunds
8ce5c037ef Fix non-release of player when at natural end of track 2024-08-05 08:24:54 +01:00
Keith Edmunds
7ca104e53d Update black 2024-08-05 08:24:54 +01:00
Keith Edmunds
ff76d8eb7e Fix resource leak
After around 1.5h of operation, we'd get messages such as:

vlcpulse audio output error: PulseAudio server connection failure: Connection terminated

Tracked down to not correctly releasing vlc player resources when
track had finished playing. Fixed now, and much simplified the fadeout
code as well.
2024-08-05 08:24:54 +01:00
Keith Edmunds
973096ba3f . 2024-08-05 08:24:54 +01:00
Keith Edmunds
b8fcc79f8e Black formatting and mypy fixups 2024-08-04 17:18:08 +01:00
Keith Edmunds
27012a9658 Fix non-release of player when at natural end of track 2024-08-04 11:57:46 +01:00
Keith Edmunds
1d5fe3e57e Update black 2024-08-04 11:51:53 +01:00
Keith Edmunds
40cad1c98f Fix resource leak
After around 1.5h of operation, we'd get messages such as:

vlcpulse audio output error: PulseAudio server connection failure: Connection terminated

Tracked down to not correctly releasing vlc player resources when
track had finished playing. Fixed now, and much simplified the fadeout
code as well.
2024-08-02 18:35:33 +01:00
Keith Edmunds
5f5bb27a5f . 2024-08-02 18:35:33 +01:00
Keith Edmunds
50d1e8bd4a Fix unmarking row as played
Fixes #254
2024-07-31 13:16:06 +01:00
Keith Edmunds
feb8f0b6d7 Unmark row zero when no longer next track
Fixes #253
2024-07-31 13:16:06 +01:00
Keith Edmunds
1825e48e92 Fix unmarking row as played
Fixes #254
2024-07-31 13:04:04 +01:00
Keith Edmunds
2b8a911a78 Unmark row zero when no longer next track
Fixes #253
2024-07-31 12:57:51 +01:00
Keith Edmunds
a95ded1551 More log quietening 2024-07-30 17:13:30 +01:00
Keith Edmunds
2d582738e3 More log quietening 2024-07-30 16:54:00 +01:00
Keith Edmunds
0c76227bbc Quieten logging: move many info to debug 2024-07-30 16:51:53 +01:00
Keith Edmunds
bd7fb79610 Clear fade graph when clearing next track 2024-07-30 16:36:29 +01:00
Keith Edmunds
59b6b87186 Fixup typos in playlistmodel.py 2024-07-30 04:21:04 +01:00
Keith Edmunds
b15687a4c6 Clean up playlists.py 2024-07-30 04:12:35 +01:00
Keith Edmunds
076451ff89 Cleanup of playlistmodel.py 2024-07-29 21:49:17 +01:00
Keith Edmunds
d6f55c5987 Rewrite of track handling
Combine the old track_manager and playlist data structures into
RowAndTrack data structure.
2024-07-29 18:52:02 +01:00
Keith Edmunds
4a85d7ea84 Fix repr typo 2024-07-28 19:47:05 +01:00
Keith Edmunds
3c01fb63c3 Implement VLC logging 2024-07-28 19:45:55 +01:00
Keith Edmunds
b423ab0624 Log.debug production stackprinter messages 2024-07-26 18:10:53 +01:00
Keith Edmunds
051d8cf0ef Log releasing player and keep player count
Working on issue #251
2024-07-26 11:49:38 +01:00
Keith Edmunds
1513ad96d8 Fix track times bug
When update_track_times runs, it looks as track_sequence.current and
.next, but didn't check that those tracks referred to the current
playlist, which could cause a KeyError.

Fixes #252
2024-07-26 11:38:33 +01:00
Keith Edmunds
04c2c6377a Increase play debounce time 500ms → 1000ms 2024-07-26 11:20:15 +01:00
Keith Edmunds
9973f00055 Enhance debugging for failed fade graph creation 2024-07-26 11:18:29 +01:00
Keith Edmunds
53e169ae6b Add x bit to musicmuster.py 2024-07-23 17:50:14 +01:00
Keith Edmunds
234f6fcdbb Typo fixed 2024-07-23 17:47:18 +01:00
Keith Edmunds
7658dc354c More track timing cleanups 2024-07-22 18:47:29 +01:00
Keith Edmunds
3c884e54ca Refactor set track times 2024-07-22 16:29:17 +01:00
Keith Edmunds
d7a37151b7 Fixup type hints, renamed function 2024-07-22 16:27:31 +01:00
Keith Edmunds
96080cdca0 Simply musicmuster:play_next
Split out return_pressed_in_error()
2024-07-21 09:49:18 +01:00
Keith Edmunds
434e45b080 Reduce complexity of playlistmodel:headerData 2024-07-21 08:58:49 +01:00
Keith Edmunds
829172177c Implement external browser 2024-07-19 19:59:18 +01:00
Keith Edmunds
30d8b0d5c8 Rework track hiding logic
Fixes #248
2024-07-19 15:58:58 +01:00
Keith Edmunds
a51dd3a998 Show preview time in m:ss
Fixes #250
2024-07-19 15:06:22 +01:00
Keith Edmunds
7a6c8a0f95 Mark playlist last used on creation
Fixes #249
2024-07-19 12:46:10 +01:00
Keith Edmunds
faf18f431e Update dependencies 2024-07-08 19:13:42 +01:00
Keith Edmunds
5f3119be1f Tighter mypy testing, fixed up type hints 2024-07-08 19:03:35 +01:00
Keith Edmunds
2394327d38 Make load playlists the last init action 2024-07-07 11:57:24 +01:00
Keith Edmunds
c7d6ae4cb6 Fix end of track signalling 2024-07-07 11:16:49 +01:00
Keith Edmunds
7333fd570f Error checking, type annotations, minor edits 2024-07-07 10:19:17 +01:00
Keith Edmunds
68a253bc7c Improve type hints, other minor edits 2024-07-06 20:35:06 +01:00
Keith Edmunds
c11573906a Make tick_100ms more efficient 2024-07-06 19:01:27 +01:00
Keith Edmunds
87d2d7adae Add issue 223 debugging and quicklog function 2024-07-06 14:26:29 +01:00
Keith Edmunds
dc3b46d2d6 Unload pygame music file after use 2024-07-06 12:37:15 +01:00
Keith Edmunds
f2867deb2f mypy linting 2024-07-03 18:03:41 +01:00
Keith Edmunds
553376a99e Preview with pygame working 2024-07-03 17:55:09 +01:00
Keith Edmunds
e3d7ae8e0f WIP: preview forward/back working 2024-07-03 16:11:13 +01:00
Keith Edmunds
9656bac49f WIP: preview via pygame working 2024-07-03 15:41:14 +01:00
Keith Edmunds
a971298982 WIP: remove some references to preview track manager 2024-07-03 14:01:34 +01:00
Keith Edmunds
4fe6e9186c Merge branch 'sounddevice' into dev 2024-07-03 13:50:46 +01:00
Keith Edmunds
8bc41f2fcd Fix error message 2024-07-03 13:50:40 +01:00
Keith Edmunds
92eb3fc953 Fix inability to close playlists 2024-07-03 12:52:46 +01:00
Keith Edmunds
a8f709d2da Quieten logging 2024-06-27 21:41:15 +01:00
Keith Edmunds
e711ab84ab Move some logging from info to debug 2024-06-27 20:43:38 +01:00
Keith Edmunds
67bc3377cb Fix logging error 2024-06-27 20:41:56 +01:00
Keith Edmunds
8618813197 Tidy up function 2024-06-23 14:35:05 +01:00
Keith Edmunds
c139215603 Improve drag and drop targetting 2024-06-22 21:52:08 +01:00
Keith Edmunds
3831ebb01d File header, type hints, Black 2024-06-22 21:51:41 +01:00
Keith Edmunds
0cd5d97405 Make default syslog level DEBUG 2024-06-21 23:17:00 +01:00
Keith Edmunds
a8fad358b9 Fix database URL reference 2024-06-20 18:23:04 +01:00
Keith Edmunds
6e4c386fe2 Manage deleting rows better
Fix incorrect updating of track_sequence row numbers.
2024-06-18 19:45:12 +01:00
Keith Edmunds
a4174e84ce Make use of get_tags more resilient 2024-06-17 16:31:23 +01:00
Keith Edmunds
fe8537c9c1 replace_files.py functionality now in musicmuster 2024-06-17 16:18:06 +01:00
Keith Edmunds
5e4277646b Black formatting 2024-06-16 08:40:45 +01:00
Keith Edmunds
71257e4d67 Ensure one db instance only
Ensure testing db is correctly set to sqlite
2024-06-16 08:40:03 +01:00
Keith Edmunds
c0b7bf76f5 Clean up tmpdir after normalise tests 2024-06-16 08:18:24 +01:00
Keith Edmunds
5624d77519 Remove pygame dependency 2024-06-16 08:17:09 +01:00
Keith Edmunds
21156d8fa1 Improve getting/setting of Settings 2024-06-16 08:16:24 +01:00
Keith Edmunds
a46b9a3d6f Return True/False on set_next_row 2024-06-03 20:29:50 +01:00
Keith Edmunds
1ee9a1ae22 Speed up moving rows 2024-06-03 20:29:17 +01:00
Keith Edmunds
e884201df4 Don't accept unreadable track into _TrackManager 2024-06-03 19:06:00 +01:00
Keith Edmunds
2f32f2e914 Update fade graph when starting next track before current has finished 2024-06-03 19:05:19 +01:00
Keith Edmunds
1d51edc50f Most recent track first in tooltips 2024-06-02 21:05:09 +01:00
Keith Edmunds
35b5402853 Fix: end of preview caused main play end of track actions 2024-06-02 20:53:26 +01:00
Keith Edmunds
2a1d9e94bc All tests pass 2024-06-02 19:33:41 +01:00
Keith Edmunds
9f7af072dc Remove carts from tests 2024-06-02 19:28:26 +01:00
Keith Edmunds
648ef76234 Resume working 2024-06-02 19:19:35 +01:00
Keith Edmunds
909fb27bed All preview/intro management working 2024-06-02 17:58:20 +01:00
Keith Edmunds
09fdd7e4dc Display of countdown timer works 2024-06-02 16:50:49 +01:00
Keith Edmunds
983716e009 Row times updating working 2024-06-02 16:34:30 +01:00
Keith Edmunds
4ec1c0e09c Fade graph no longer lagging 2024-06-02 14:31:14 +01:00
Keith Edmunds
0361d25c7b WIP: fade graph working, slightly laggy 2024-06-02 13:33:57 +01:00
Keith Edmunds
c5ca1469dc Remove all carts code 2024-06-02 12:04:26 +01:00
Keith Edmunds
5278b124ca WIP: implemented trackmanager, tracks play, clocks work 2024-06-02 11:57:45 +01:00
Keith Edmunds
fbcedb6c3b Create trackmanager.py
music.py is fully absorbed into trackmanager.py and thus removed
Substantial parts of classes.py are absorbed into trackmanager.py
2024-06-02 10:00:31 +01:00
Keith Edmunds
8ea0a0dad5 WIP: moving player to PlaylistTrack. Player works. 2024-06-01 17:41:22 +01:00
Keith Edmunds
b1f682d2e6 Uncheck preview armed at end of preview 2024-05-25 09:36:19 +01:00
Keith Edmunds
3d3df85845 PoC: added intro time display and editing 2024-05-25 09:29:03 +01:00
Keith Edmunds
8ebaa2798f Set intro timer background colour 2024-05-24 16:48:48 +01:00
Keith Edmunds
afc3014b18 Much improved stderr reporting on exceptions 2024-05-24 15:04:07 +01:00
Keith Edmunds
45a22c47d0 Implement intro timing and countdown 2024-05-24 14:27:00 +01:00
Keith Edmunds
0c03db14d4 Migrate Alembic to Alchemical format 2024-05-24 14:25:54 +01:00
Keith Edmunds
fb5376cdf0 WIP time to vocals: record button icons 2024-05-24 14:25:54 +01:00
Keith Edmunds
01916c4adc WIP: time to vocals: preview +- working 2024-05-24 14:25:51 +01:00
Keith Edmunds
1d33622c13 WIP: time to vocals 2024-05-24 14:20:59 +01:00
Keith Edmunds
b86f0ac1b7 Unifty format of VLC config variables 2024-05-24 14:19:16 +01:00
Keith Edmunds
f7f5579c25 Merge branch 'dev' 2024-05-24 13:43:51 +01:00
Keith Edmunds
3871da048d Reimplement issue #223 fix 2024-05-24 13:36:06 +01:00
Keith Edmunds
73199121d9 Reimplement issue #223 fix 2024-05-24 13:35:56 +01:00
Keith Edmunds
dcbb040045 Merge branch 'dev' 2024-05-23 19:19:35 +01:00
Keith Edmunds
bd125f2a1a Fix typo getting play time in tick_1000ms 2024-05-23 19:19:11 +01:00
Keith Edmunds
fa52b7ffaf Merge branch 'dev' 2024-05-22 16:53:06 +01:00
Keith Edmunds
36e28ca4f4 Fix bug storing open tabs 2024-05-22 16:52:35 +01:00
Keith Edmunds
f2d01e003d Merge changes made to master 2024-05-22 15:47:00 +01:00
Keith Edmunds
71e76e02d1 Merge changes from master 2024-05-22 15:45:21 +01:00
Keith Edmunds
fc4129994b Fix move rows bug
Fixes #244
2024-05-22 15:26:57 +01:00
Keith Edmunds
1421934415 Merge branch 'dev' 2024-05-20 17:55:49 +01:00
Keith Edmunds
a7932adfe4 Add more protection against hitting return twice 2024-05-10 12:48:39 +01:00
Keith Edmunds
f825304de4 Update track times after rescan
Fixes #242
2024-05-10 12:06:04 +01:00
Keith Edmunds
37e450ab22 Bugfix replace files
Fixes #243
2024-05-10 11:48:40 +01:00
Keith Edmunds
be0fc27896 Move player functionality into music.py 2024-05-06 15:55:51 +01:00
Keith Edmunds
4a5fe74a9f Save open state of playlists 2024-05-06 12:25:04 +01:00
Keith Edmunds
d050fa0d84 Fix file importing
Imported track wasn't moved to destination
2024-05-06 12:12:56 +01:00
Keith Edmunds
e25d4ad311 Fixup tests 2024-05-05 18:38:50 +01:00
Keith Edmunds
c1d2fcd8cd Save open tabs properly
Fixes #239
2024-05-04 21:15:08 +01:00
Keith Edmunds
253550b490 Implement SQLAlchemy Pool.pre_ping
Fixes #241
2024-05-04 20:35:14 +01:00
Keith Edmunds
9fb7cce82c Update dependencies 2024-05-04 02:08:18 +01:00
Keith Edmunds
f2db9967fb Reduce stdout output 2024-05-04 02:08:00 +01:00
Keith Edmunds
a24ff76b6b Build in replace_file functionality
Major rewrite of file importing

Fixes #141
2024-05-03 22:40:21 +01:00
Keith Edmunds
6aa09bf28a Save new playlist (commit to db) 2024-05-02 22:44:11 +01:00
Keith Edmunds
049a5508cc Commit when adding track to header
Fixes #238
2024-05-02 19:46:43 +01:00
Keith Edmunds
aa208d72c1 Save to db after rescan
Fixes #237
2024-05-02 19:43:03 +01:00
Keith Edmunds
57e81b0f17 Allow artist search in title box with "a/" 2024-04-28 18:45:37 +01:00
Keith Edmunds
dfc51e1399 Hover previous track to see list
Fixes #205
2024-04-28 17:07:02 +01:00
Keith Edmunds
f898e4645b Hover last played column to show list
Fixes #205
2024-04-28 16:41:16 +01:00
Keith Edmunds
2475f817f9 Merge branch 'dev' 2024-04-28 13:17:29 +01:00
Keith Edmunds
80687df82e Don't react to second of two quick 'return' key presses
Fixes #228
2024-04-28 13:15:15 +01:00
Keith Edmunds
09dcba90a9 Attempt to detect sound system access problem
Fixes #232
2024-04-28 13:02:54 +01:00
Keith Edmunds
1ce64804fb Fix moving rows
Also fix associated tests.
Fixes #234
2024-04-28 12:54:32 +01:00
Keith Edmunds
2a55cd9c92 Replaced obsws-python with obs-websocket-py
Fixes #235
2024-04-28 11:30:54 +01:00
Keith Edmunds
e9a3047f00 Improve logging and FadeCurve generation. Tidy. 2024-04-28 10:50:20 +01:00
Keith Edmunds
feb09db3d7 Merge session.commit() calls 2024-04-27 21:58:26 +01:00
Keith Edmunds
e179e57459 Add required session.commit() calls 2024-04-27 21:56:11 +01:00
Keith Edmunds
cad26ff8f9 Fix #233 2024-04-27 21:54:18 +01:00
Keith Edmunds
9a6313bfae Update environment for Alchemical 2024-04-27 21:54:18 +01:00
Keith Edmunds
46964b5f66 Update tests 2024-04-27 21:54:18 +01:00
Keith Edmunds
1011b2f549 Fixup replace_files for Alchemical 2024-04-27 21:54:18 +01:00
Keith Edmunds
2e8fae99ed Pull in recent V3 updates 2024-04-27 21:54:17 +01:00
Keith Edmunds
e4a9520908 Tidy up tests 2024-04-27 21:52:31 +01:00
Keith Edmunds
52ab4fa43e Remove superflous __repr__ 2024-04-27 21:52:31 +01:00
Keith Edmunds
0519006bb2 Update dependencies 2024-04-27 21:52:31 +01:00
Keith Edmunds
a9763b7a11 Initial GUI test running. Test coverage: 42%. 2024-04-27 21:52:31 +01:00
Keith Edmunds
7cd03d7a2b Fix up db import 2024-04-27 21:52:31 +01:00
Keith Edmunds
a4858761c6 All tests working 2024-04-27 21:52:31 +01:00
Keith Edmunds
76021aa1c6 Put commit()s where needed, move some info to debug logging 2024-04-27 21:52:31 +01:00
Keith Edmunds
16e3c8235e V4 WIP: mostly Black formatting 2024-04-27 21:52:31 +01:00
Keith Edmunds
df620cde86 Migrated to Alchemical 2024-04-27 21:52:30 +01:00
Keith Edmunds
9d44642fea Migrate to Alchemical 2024-04-27 21:52:28 +01:00
Keith Edmunds
6890e0d0c2 Improve test coverage 2024-04-27 21:51:47 +01:00
Keith Edmunds
b8c19c6046 Merge v4 branch 2024-04-27 20:40:17 +01:00
Keith Edmunds
503aac530a Update environment for Alchemical 2024-04-27 20:38:21 +01:00
Keith Edmunds
35438f59fb Update tests 2024-04-27 20:36:04 +01:00
Keith Edmunds
189efb379f Fixup replace_files for Alchemical 2024-04-27 20:25:22 +01:00
Keith Edmunds
134961abfd Pull in recent V3 updates 2024-04-27 19:33:35 +01:00
Keith Edmunds
ebf62fe161 Fix #233 2024-04-27 18:47:06 +01:00
Keith Edmunds
4c638ab608 More issue #223 debug 2024-04-24 17:56:16 +01:00
Keith Edmunds
f1ef2f4d5a Merge branch 'dev' 2024-04-18 19:23:55 +01:00
Keith Edmunds
b562f90b25 Don't track .coverage file 2024-04-13 10:40:04 +01:00
Keith Edmunds
2454e8e4b9 Tidy up logging around issue #223 2024-04-13 10:39:51 +01:00
Keith Edmunds
5f1682c0c6 Tidy up tests 2024-04-06 11:16:00 +01:00
Keith Edmunds
cce7194aa1 Remove superflous __repr__ 2024-04-06 11:15:17 +01:00
Keith Edmunds
c1b0b333b8 Update dependencies 2024-04-06 11:14:51 +01:00
Keith Edmunds
373f4eeb23 Initial GUI test running. Test coverage: 42%. 2024-04-05 21:12:41 +01:00
Keith Edmunds
836d812ef3 Migrate to Alchemical and unittest+pytest framework 2024-04-05 17:47:26 +01:00
Keith Edmunds
6624ac8f31 Fix up db import 2024-04-05 17:29:06 +01:00
Keith Edmunds
c5595bb61b All tests working 2024-04-05 16:42:02 +01:00
Keith Edmunds
92d85304f2 Put commit()s where needed, move some info to debug logging 2024-04-05 14:42:04 +01:00
Keith Edmunds
1a5bd638c0 Merge branch 'dev' 2024-04-05 11:23:59 +01:00
Keith Edmunds
e813a80a5b Debugging for #223 2024-04-05 11:23:00 +01:00
Keith Edmunds
c380d37cf9 V4 WIP: mostly Black formatting 2024-04-05 10:41:14 +01:00
Keith Edmunds
3821a7061b Migrated to Alchemical 2024-04-05 10:38:03 +01:00
Keith Edmunds
6fd541060e Migrate to Alchemical 2024-04-05 10:38:03 +01:00
Keith Edmunds
dbe71c3be4 Improve test coverage 2024-04-05 10:38:03 +01:00
Keith Edmunds
aaf2257117 Fix opening Audacity with non-ASCII file path
Fixes #227 #224
2024-04-05 10:37:22 +01:00
Keith Edmunds
92320c8922 Re-enable status line messages re play controls enabled/disabled 2024-04-05 10:21:26 +01:00
Keith Edmunds
a653bff29e Merge branch 'dev' 2024-04-04 14:17:37 +01:00
Keith Edmunds
6699d829e5 Resize rows on copy/paste
Fixes #226
2024-04-04 14:14:44 +01:00
Keith Edmunds
4714364517 Resize rows on copy/paste
Fixes #226
2024-03-27 08:47:32 +00:00
Keith Edmunds
056c66ebec Re-enable automatic Wikipedia searches 2024-03-27 08:47:32 +00:00
Keith Edmunds
9cec490855 Don't automatically show Wikipedia page (debugging #223) 2024-03-27 08:47:32 +00:00
Keith Edmunds
1a38676ff0 Re-enable automatic Wikipedia searches 2024-03-26 08:28:17 +00:00
Keith Edmunds
851e52c3e1 Use dialog box to check for unintended play next track 2024-03-26 08:23:05 +00:00
Keith Edmunds
cf66cef60a Use dialog box to check for unintended play next track 2024-03-25 17:48:56 +00:00
Keith Edmunds
38bb5dc7cd Merge branch 'dev' 2024-03-25 16:42:25 +00:00
Keith Edmunds
50b051a864 Improve resize rows speed 2024-03-22 14:21:37 +00:00
Keith Edmunds
a7301eb909 Merge branch 'dev' 2024-03-21 16:58:17 +00:00
Keith Edmunds
90697652b0 Speed up row insertion 2024-03-21 16:57:37 +00:00
Keith Edmunds
fd2183b7f0 Merge branch 'dev' 2024-03-08 23:33:46 +00:00
Keith Edmunds
1363010da8 More logging changes to try to debug #223 2024-03-08 23:32:50 +00:00
Keith Edmunds
609544ddd4 Implement random sort 2024-03-08 23:25:07 +00:00
Keith Edmunds
b116f062e9 Update packages, fix one bug 2024-03-01 17:58:25 +00:00
Keith Edmunds
9a9f894215 Don't automatically show Wikipedia page (debugging #223) 2024-03-01 13:08:52 +00:00
Keith Edmunds
ab867c1a67 Logging changes to try to debug #223 2024-03-01 11:07:42 +00:00
Keith Edmunds
1753534e20 Allow canceling Audactity edit
Fixes #221
2024-02-23 17:30:01 +00:00
Keith Edmunds
2932f32771 Highlight releasing player
Work on #223
2024-02-23 12:27:50 +00:00
Keith Edmunds
0e2c8c6056 Fix delete rows bug
Fixes #225
2024-02-23 12:26:42 +00:00
Keith Edmunds
2976ceaa22 Temporarily make releasing music player an error notification
To try to establish whether releasing the music player is related to
2024-02-18 12:47:02 +00:00
Keith Edmunds
f0c6d884ef Fix bug importing tracks with no row selected 2024-02-15 23:00:27 +00:00
Keith Edmunds
5d95748640 Possibly fix row deleting bug
Fixes #220
2024-02-10 15:52:03 +00:00
Keith Edmunds
c511bf053e Rework Audacity initialisation 2024-02-10 15:51:23 +00:00
Keith Edmunds
468ecda450 Don't copy header rows when moving unplayed tracks
Fixes #222
2024-02-10 09:11:28 +00:00
Keith Edmunds
42676789c1 Remove commented-out code 2024-01-19 10:27:53 +00:00
Keith Edmunds
af6e0f69be Speed up changing to tab with lots of tracks
Fixes: #219
2024-01-19 10:16:28 +00:00
Keith Edmunds
2ecb67629e Don't exit if Audacity not running
Handle Audacity integration better

Fixes: #215
2024-01-19 10:12:41 +00:00
Keith Edmunds
4fce750223 Refactor / simplify start/stop times
Fixes #218
2024-01-19 09:58:52 +00:00
Keith Edmunds
fcbdfc65ac Resize rows after hiding/showing played
Fixes #216
2024-01-19 09:57:25 +00:00
Keith Edmunds
c5dd913b98 Resize rows on show/hide played 2024-01-18 22:59:02 +00:00
Keith Edmunds
b0278b92b0 Try to eliminate occasional short pause at start of track
Made playing the track the last thing in play_next()
2024-01-14 15:11:38 +00:00
Keith Edmunds
128fe2925f Disable selected row timing during move_unplayed 2024-01-12 10:36:05 +00:00
Keith Edmunds
84cf22a196 Escape double quotes in finlename for Audacity 2024-01-11 23:08:56 +00:00
Keith Edmunds
d3999ca63d Fix moving rows between playlists 2024-01-05 09:54:55 +00:00
Keith Edmunds
8de9bf0d6e Deselect track after pasting 2023-12-22 15:36:42 +00:00
Keith Edmunds
37711f883f Rework Audacity import/export 2023-12-22 13:40:24 +00:00
Keith Edmunds
3922be2642 Report track import errors correctly 2023-12-22 13:21:12 +00:00
Keith Edmunds
91cef9e506 Fix bug moving unplayed tracks between playlists 2023-12-22 08:14:51 +00:00
Keith Edmunds
c6a0e8c749 Remve log level letter from stderr output 2023-12-21 17:15:44 +00:00
Keith Edmunds
e43c9f3b17 Add successive tracks below those just added 2023-12-17 14:33:24 +00:00
Keith Edmunds
2bf1e442be Fix row spanning error leading to high CPU idle load 2023-12-17 00:12:39 +00:00
Keith Edmunds
4b6c8b0634 Rewrite logging
Add lots of log.info() statements
2023-12-17 00:12:03 +00:00
Keith Edmunds
2432039b72 Best-efforts resize row heights on open 2023-12-16 12:37:41 +00:00
Keith Edmunds
74bdbe2975 Improve open in / import from Audacity 2023-12-16 12:34:23 +00:00
Keith Edmunds
f228a371f2 Ensure all rows correctly resized for height 2023-12-16 02:37:49 +00:00
Keith Edmunds
b74007119d Name source and proxy models consistently 2023-12-16 02:36:16 +00:00
Keith Edmunds
45243759b8 Stackprinter dump if no fade graph 2023-12-15 18:46:30 +00:00
Keith Edmunds
d73bdb264d Don't prompt user when editing if no changes made 2023-12-15 18:46:03 +00:00
Keith Edmunds
90f8e20843 Fix scroll to current/next track with played tracks hidden 2023-12-15 18:27:42 +00:00
Keith Edmunds
184318078f Better fix for setting track/header row spans correctly 2023-12-15 17:55:22 +00:00
Keith Edmunds
c6befd219c Improve playlist load speed 2023-12-15 17:48:42 +00:00
Keith Edmunds
2f0ad5cd52 Fix track rows sometimes displayed as header rows 2023-12-15 14:10:54 +00:00
Keith Edmunds
60c085ad12 Fix errors copy rows from search results 2023-12-14 18:20:16 +00:00
Keith Edmunds
bf438c3d99 Fix sometimes rows too tall after loading playlist 2023-12-14 18:12:00 +00:00
Keith Edmunds
33fdc40f66 Clean up AudacityManager 2023-12-09 14:05:29 +00:00
Keith Edmunds
0082f76b56 Rescan after Audacity 2023-12-08 20:54:37 +00:00
Keith Edmunds
83a817234d Remotely open and save files in Audacity 2023-12-08 19:57:25 +00:00
Keith Edmunds
540846223b WIP Audacity 2023-12-08 18:21:42 +00:00
Keith Edmunds
6985170378 Audacity class 2023-12-08 18:21:42 +00:00
Keith Edmunds
b86b7f7f33 Resize row on insertion
Fixes #207
2023-12-08 18:15:47 +00:00
Keith Edmunds
c1dd111453 Fix add note only from track dialog
Fixes #208
2023-12-08 18:10:38 +00:00
Keith Edmunds
7ed54f2bab Fix issues saving/restoring active tab
Fixes #212
2023-12-08 14:00:59 +00:00
Keith Edmunds
06ef175b46 Fix moving rows when played rows are hidden
Fixes #210
2023-12-08 13:35:22 +00:00
Keith Edmunds
e313e84010 Fix move unplayed rows
Fixes #211
2023-12-07 23:07:45 +00:00
Keith Edmunds
6391490f9d Select next track after header
Fixes #209
2023-12-07 23:04:25 +00:00
Keith Edmunds
243bc765f9 Clean up editing
No need to disable (and re-enable) play controls.

Fixes #191
2023-12-01 22:44:28 +00:00
Keith Edmunds
1b92b79cf0 Stop inadvertent editing of cell after cancelling search 2023-12-01 18:45:30 +00:00
Keith Edmunds
03f19dfb9c Improve loading time for long playlists
Fixes #199
2023-12-01 17:08:13 +00:00
Keith Edmunds
8f51e790b5 Fix header row colours
Fixes #206
2023-12-01 10:36:11 +00:00
Keith Edmunds
c56e097f75 Merge v3 2023-12-01 09:56:52 +00:00
Keith Edmunds
30b836895e Change intro gap warning to 300ms 2023-12-01 09:53:59 +00:00
Keith Edmunds
4816520343 Fix bug with unended timed section 2023-12-01 09:51:42 +00:00
Keith Edmunds
ef651dbc0a Fix replace_files after other updates 2023-12-01 09:41:42 +00:00
Keith Edmunds
1502b10701 Fix (innocuous) mypy warning 2023-11-29 22:01:38 +00:00
Keith Edmunds
9cbdccb98b V3 polish 2023-11-29 15:04:50 +00:00
Keith Edmunds
3af9bef3f6 V3: fix preview button behaviour
Was asking user to select a track when next track selected.
2023-11-29 08:02:14 +00:00
Keith Edmunds
1db3990cd6 V3: add note colouring 2023-11-29 07:57:36 +00:00
Keith Edmunds
6061b20398 V3 polish 2023-11-28 21:56:20 +00:00
Keith Edmunds
2e090b192c V3: remove debug print statement 2023-11-28 21:19:23 +00:00
Keith Edmunds
63340a408d V3: fix display corruption when moving a header row 2023-11-28 21:13:16 +00:00
Keith Edmunds
f9b8f1d8d3 V3 tweaks and polishes 2023-11-28 19:59:45 +00:00
Keith Edmunds
f8093bc642 V3: track highlighting fix
When a track is moved to above the marked next track, and the moved
track is made the next track, the original next track remained marked
as next.
2023-11-28 18:29:19 +00:00
Keith Edmunds
cf4d06db16 V3 tidying 2023-11-28 14:36:12 +00:00
Keith Edmunds
95aadb867a V3 hide played tracks
Don't hide previous track until delay after playing next track.
2023-11-28 14:29:49 +00:00
Keith Edmunds
3179c6f5de V3 tweaks and polishes 2023-11-28 14:29:09 +00:00
Keith Edmunds
63a38b5bf9 V3 polish: fix @starttime in headers 2023-11-28 07:28:33 +00:00
Keith Edmunds
15c10431e6 V3 polish: header with "-" echoes section start text 2023-11-28 07:19:09 +00:00
Keith Edmunds
0f1d5117cc V3 tweaks 2023-11-27 22:44:20 +00:00
Keith Edmunds
4eabf4a02a WIP V3: ready for testing 2023-11-27 21:46:19 +00:00
Keith Edmunds
00d7258afd WIP V3: OBS scene changes working 2023-11-27 21:27:27 +00:00
Keith Edmunds
b1442b2c7d WIP V3: check track already present in playlist when adding 2023-11-27 20:55:24 +00:00
Keith Edmunds
3cab9f737c WIP V3: click on current/next header scrolls to track 2023-11-27 16:16:33 +00:00
Keith Edmunds
04f0e95653 WIP V3: fix minor issues 2023-11-27 15:21:20 +00:00
Keith Edmunds
dfb45dd0ff WIP V3: Don't hide next/current row 2023-11-27 11:52:29 +00:00
Keith Edmunds
02391f04b1 WIP V3: hide played tracks working 2023-11-27 11:27:25 +00:00
Keith Edmunds
31f7122a7f WIP V3: fixup tests from earlier changes 2023-11-26 15:27:14 +00:00
Keith Edmunds
480c832852 WIP V3: implement searching with QSortFilterProxyModel (ooo!) 2023-11-26 15:22:01 +00:00
Keith Edmunds
6f5c371510 Git ignore tmp directory 2023-11-25 18:02:39 +00:00
Keith Edmunds
23a9eff43b WIP V3 wire in QSortFilterProxyModel 2023-11-23 18:28:10 +00:00
Keith Edmunds
25e3be6fae WIP V3: add track to header working 2023-11-23 17:12:03 +00:00
Keith Edmunds
c626d91f26 WIP V3: copy and paste rows to same or other playlist works 2023-11-23 10:59:03 +00:00
Keith Edmunds
551a574eac WIP V3: move unplayed rows 2023-11-23 04:44:36 +00:00
Keith Edmunds
80c363c316 WIP V3: better handle row order changing 2023-11-23 04:44:17 +00:00
Keith Edmunds
48b180e280 WIP V3: move selected tracks works 2023-11-22 19:57:14 +00:00
Keith Edmunds
223fb3bdec WIP V3: tests for moving rows between playlists pass 2023-11-22 16:57:16 +00:00
Keith Edmunds
5769e34412 WIP V3: move ImportTrack back to musicmuster.py 2023-11-20 12:40:45 +00:00
Keith Edmunds
e3d20c9bdc WIP V3: cleanup 2023-11-20 11:24:12 +00:00
Keith Edmunds
5add1f01c6 WIP V3: use signals to open wikipedia/songfacts pages
Also open wikipedia page on selecting next track
2023-11-19 21:50:39 +00:00
Keith Edmunds
88e638a56e WIP V3: search wikipedia/songfacts from menu 2023-11-19 21:31:09 +00:00
Keith Edmunds
4ca5eb24c3 WIP V3: remove track from row implemented 2023-11-19 20:56:46 +00:00
Keith Edmunds
05ef2d766c WIP V3: Black 2023-11-19 20:49:50 +00:00
Keith Edmunds
db547cbdb7 WIP V3: import tracks working 2023-11-19 16:02:44 +00:00
Keith Edmunds
005d17ee0a Check for no title/artist tag in replace_files 2023-11-19 11:44:43 +00:00
Keith Edmunds
262ab202fc WIP V3: catch proposed duplicate playlist name
Fixes #197
2023-11-19 11:13:49 +00:00
Keith Edmunds
4f4408400f WIP V3: info popup implemented 2023-11-19 03:11:03 +00:00
Keith Edmunds
f4a374f68c WIP V3: select duplicate rows working 2023-11-19 03:09:58 +00:00
Keith Edmunds
77774dc403 WIP V3: marn new playlist as open 2023-11-18 15:46:07 +00:00
Keith Edmunds
8f2ab98be0 Fix create playlist from template and tab handlding
Tab restore code rewritten.
2023-11-18 14:29:52 +00:00
Keith Edmunds
199f0e27fa WIP V3: fixup row insertion/deletion
All row insertions and deletions are now wrapped in beginRemoveRows /
endRemoveRows (and similar for insertions).
2023-11-17 22:17:47 +00:00
Keith Edmunds
e37f62fe87 WIP V3: fixup closing tabs 2023-11-17 22:14:51 +00:00
Keith Edmunds
be7071aae0 Change intro gap warning to 300ms 2023-11-16 22:23:22 +00:00
Keith Edmunds
eae8870d4d WIP V3: resume working 2023-11-16 19:09:41 +00:00
Keith Edmunds
93c5475a29 WIP V3: preview button works 2023-11-16 18:06:21 +00:00
Keith Edmunds
2861511f1f WIP V3: remove functions, formatting 2023-11-16 00:08:12 +00:00
Keith Edmunds
a8aa157484 Remove lots of unuse functions from playlists.py 2023-11-15 23:54:06 +00:00
Keith Edmunds
71f3e4cda8 WIP V3: delete rows works 2023-11-15 23:40:48 +00:00
Keith Edmunds
9467ae4ee5 WIP V3: show selected time plus drag 'n' drop refinements 2023-11-15 22:37:42 +00:00
Keith Edmunds
de710b1dc7 WIP V3: start/end times, moving row bug
Start/end times now stored separately from self.playlist_rows. Moving
next row to above current row now works.
2023-11-15 20:09:00 +00:00
Keith Edmunds
3cbc69b11e Fix off-by-one errors in tests 2023-11-15 19:07:23 +00:00
Keith Edmunds
56087870f4 WIP V3: recalculate start/end times after moving rows 2023-11-15 15:14:23 +00:00
Keith Edmunds
b83bd0d5c3 WIP V3: display last played date 2023-11-15 15:09:41 +00:00
Keith Edmunds
3e49ad08b9 WIP V3: sort by each element implemented 2023-11-15 08:41:06 +00:00
Keith Edmunds
d5871fe77f WIP V3: context menu started
Sort by title implemented
2023-11-14 23:45:47 +00:00
Keith Edmunds
1b4411d7e5 Set up fade graph before playing track 2023-11-13 21:24:21 +00:00
Keith Edmunds
d2254b6ddd WIP V3: Use config settings for warning timers 2023-11-13 21:22:05 +00:00
Keith Edmunds
0d2dad9f3c WIP V3: remove references to HEADER_NOTES_COLUMN in playlists.py 2023-11-12 22:36:17 +00:00
Keith Edmunds
0f77cef37a WIP V3: editing header rows works 2023-11-12 22:35:44 +00:00
Keith Edmunds
bfc7a8508c WIP V3: fix moving tracks repaint bug
When a header row moved down to make room for a track row,
the column spanning is now reset on the now-track row.
2023-11-12 22:15:35 +00:00
Keith Edmunds
9e9bc8b4c7 WIP V3: end time of playing subsection implemented 2023-11-10 03:57:33 +00:00
Keith Edmunds
f311721386 Update packages 2023-11-09 18:47:34 +00:00
Keith Edmunds
2907514eb7 WIP V3: smarten up section timings 2023-11-08 23:34:17 +00:00
Keith Edmunds
ab084ccf97 Fixup tests for section timings 2023-11-08 23:22:32 +00:00
Keith Edmunds
b399abb471 WIP V3: section timings in place 2023-11-08 23:18:33 +00:00
Keith Edmunds
6d648a56b7 WIP V3: fix editing headers rows 2023-11-08 18:34:10 +00:00
Keith Edmunds
b3262b2ede WIP V3: track start/end times working 2023-11-08 18:15:57 +00:00
Keith Edmunds
698fa4625a WIP V3: track start/stop times basics working
Only updates from header rows or current track. Changing
current track doesn't update correctly.
2023-11-07 23:14:26 +00:00
Keith Edmunds
b042ea10ec Move test_playlists.py to X_test_playlists for now 2023-11-07 20:50:39 +00:00
Keith Edmunds
9b682564ee WIP V3: remove redundant test.py 2023-11-07 20:42:34 +00:00
Keith Edmunds
813588e8e9 WIP V3: track stop implemented 2023-11-07 20:11:12 +00:00
Keith Edmunds
ad3ec45a76 WIP V3: unplayed rows in bold 2023-11-06 20:01:35 +00:00
Keith Edmunds
6f31ed7afc WIP V3: set up track_sequence handling 2023-11-06 20:00:04 +00:00
Keith Edmunds
c20dc0288f V3 WIP: implement playing_track structure 2023-11-05 08:15:59 +00:00
Keith Edmunds
a8ac67b9e3 V3 WIP Black 2023-11-05 08:03:02 +00:00
Keith Edmunds
a35905dee8 WIP V3: play track working 2023-11-03 15:16:27 +00:00
Keith Edmunds
bd2fa1cab0 Initialise FadeCurve in a thread
Stops a UI delay of half a second or so when marking a track 'next'
2023-11-03 09:08:06 +00:00
Keith Edmunds
4d3dc1fd00 WIP V3: don't select headers or unplayable track as next 2023-11-01 23:12:10 +00:00
Keith Edmunds
e137045812 WIP V3: select next track works with caveats
Peformance isn't great
Selecting a non-existent track isn't caught
2023-11-01 22:53:25 +00:00
Keith Edmunds
d9ad001c75 Relayout files
Created classes.py and moved common classes to classes.py. Ordered
imports.
2023-11-01 19:08:22 +00:00
Keith Edmunds
15ecae54cf Move MusicMusterSignals into helpers 2023-11-01 07:49:40 +00:00
Keith Edmunds
fedcfc3eea WIP V3: Add track to header row implemented 2023-10-31 20:09:45 +00:00
Keith Edmunds
9554336860 Move SQLAlchemy statements to models.py 2023-10-31 13:04:21 +00:00
Keith Edmunds
813b325029 Black reformatting, tidying 2023-10-31 08:15:24 +00:00
Keith Edmunds
734d5cb545 Make MusicMusterSignals a singleton class
Moved into datastructures.py
2023-10-31 08:14:34 +00:00
Keith Edmunds
3557d22c54 WIP V3: insert track works 2023-10-30 21:55:02 +00:00
Keith Edmunds
e4b986fd2e Implement active_tab and active_model 2023-10-30 16:39:02 +00:00
Keith Edmunds
3832d9300c move_rows implemented; all tests pass 2023-10-28 11:30:37 +01:00
Keith Edmunds
afb8ddfaf5 Added archive/db_experiments.py for testing 2023-10-27 12:01:43 +01:00
Keith Edmunds
617c39c0de Reworked inserting rows into model
_insert_row() handles database
insert_header() handles playlist_rows and display updates
2023-10-27 12:01:09 +01:00
Keith Edmunds
f57bcc37f6 WIP V3 model development 2023-10-27 06:58:22 +01:00
Keith Edmunds
37cdaf3e3f Call scalars() from session rather than row results 2023-10-27 06:41:40 +01:00
Keith Edmunds
858c86d907 test_insert_header_row passes 2023-10-25 22:17:52 +01:00
Keith Edmunds
b12b1501e7 WIP V3: Black formatting 2023-10-24 21:47:32 +01:00
Keith Edmunds
87172c8757 WIP V3: drag 'n' drop rows working with tests 2023-10-24 21:46:21 +01:00
Keith Edmunds
86a1678f41 WIP V3: move row initial tests working
More tests to write
2023-10-24 20:48:28 +01:00
Keith Edmunds
da658f0ae3 V3 WIP testing working for test_models 2023-10-23 17:39:56 +01:00
Keith Edmunds
da23ae9732 Move pytest configuration to pyproject.toml 2023-10-23 12:34:05 +01:00
Keith Edmunds
36b3b8c323 Remove old profile directory 2023-10-23 12:22:18 +01:00
Keith Edmunds
d25beeda89 Added reference drag 'n' drop to archive 2023-10-22 22:55:10 +01:00
Keith Edmunds
9d3e4b8d0c V3 WIP Drag and drop partly implemented
UI works but outputs model changes needed to stdout
2023-10-22 22:53:59 +01:00
Keith Edmunds
4903330e44 V3 WIP Add ROWS_FROM_ZERO option 2023-10-22 22:51:37 +01:00
Keith Edmunds
d81b4c84b8 WIP V3: add drag and drop example to archive 2023-10-21 14:44:57 +01:00
Keith Edmunds
d6572c13b5 V3 WIP Black formatting 2023-10-21 14:07:42 +01:00
Keith Edmunds
95c7ccbf34 WIP V3: editing saves 2023-10-21 13:49:13 +01:00
Keith Edmunds
5d19d1ed9f Move playlists_v3 to playlists 2023-10-21 11:07:25 +01:00
Keith Edmunds
93d780f75a V3 WIP: ESC works in editing 2023-10-21 11:03:03 +01:00
Keith Edmunds
b75dc4256a WIP V3 don't send session to playlist tab 2023-10-21 09:02:36 +01:00
Keith Edmunds
d0645a1768 Tidy up InterceptEscapeWhenEditingTableCellInView.py 2023-10-21 07:25:55 +01:00
Keith Edmunds
0690a66806 Edit partially working
setData called but not implemented
ESC not detected in edit
2023-10-20 23:17:19 +01:00
Keith Edmunds
07669043eb WIP V3 2023-10-20 20:49:52 +01:00
Keith Edmunds
d579eb81b4 WIP V3 2023-10-20 20:47:08 +01:00
Keith Edmunds
cbdcd5f4fc Fix column spanning to not be recursive 2023-10-20 16:25:48 +01:00
Keith Edmunds
bb14b34c2e WIP V3: column widths set/save works 2023-10-20 11:30:54 +01:00
Keith Edmunds
dbbced7401 Fix repr() for Settings 2023-10-20 11:06:50 +01:00
Keith Edmunds
5fb5e12bb8 WIP: V3: All headers displaying 2023-10-20 08:54:48 +01:00
Keith Edmunds
978b83ba67 WIP: V3 header rows span columns 2023-10-19 18:29:09 +01:00
Keith Edmunds
9a01bf2c2c Don't error on header rows 2023-10-19 15:09:49 +01:00
Keith Edmunds
1c8fb05ffa WIP V3: gap and bitrate column background working 2023-10-19 15:05:30 +01:00
Keith Edmunds
bec336d2a3 WIP V3: playlist populates from database 2023-10-19 13:49:07 +01:00
Keith Edmunds
51a827093a Add return type in music.py 2023-10-19 13:49:07 +01:00
Keith Edmunds
8acd279cfe Clean up music.py interface 2023-10-17 22:52:51 +01:00
Keith Edmunds
d2444159ac Improved fading
fade() takes an optional parameter, fade_seconds
fading is now logarithmic
2023-10-17 22:38:57 +01:00
Keith Edmunds
2ca2471f5e Fix bug where unable to preview first row of playlist. 2023-10-16 23:25:09 +01:00
Keith Edmunds
d57ffbdb09 Implement select duplicate rows
Fixes #157
2023-10-16 23:16:56 +01:00
Keith Edmunds
f35b8b93b1 Fix up cron database check 2023-10-16 20:39:53 +01:00
Keith Edmunds
64c3e3066b Filter virtualenv lines from stackprinter dump 2023-10-16 20:31:32 +01:00
Keith Edmunds
3e2293195a Improve track creation in database
Pass all arguments to Tracks.__init__ on track creation
Smarten up metadata collecting
Reformat code
Reinstate stackprinter, but with more sensible settings (mostly
defaults, oddly enough)
2023-10-16 19:44:51 +01:00
Keith Edmunds
8cd8f80883 Shift-sort reverses sort 2023-10-15 22:46:32 +01:00
Keith Edmunds
d7c64141f2 Remove unused app/ui/playlist_ui.py 2023-10-15 22:25:48 +01:00
Keith Edmunds
3a612558e4 Set playlist column widths before populating playlist
Big speed improvment. Loading a 540 line playlist went from 0.445s to
0.264s.
2023-10-15 22:17:46 +01:00
Keith Edmunds
9ac2911a55 Typing and mypy fixes 2023-10-15 21:04:54 +01:00
Keith Edmunds
3513c32a62 Speed increases, more typing, cleanup
Pull all playlist row info in one database query when loading a
playlist.

Fixup some type hints in models.

Comment out stackprinter calls - they mostly get in the way
interactively.
2023-10-15 19:04:58 +01:00
Keith Edmunds
ae87ac82ba Migrate model to SQLAlchemy 2.0 DeclarativeBase 2023-10-15 09:51:02 +01:00
Keith Edmunds
a8c5a56c1a Implent subtotal times and unplayed time 2023-10-13 19:01:22 +01:00
Keith Edmunds
8cebf7829b Save playlist after undoing sort 2023-10-12 18:44:01 +01:00
Keith Edmunds
c8a7ae7f73 Black formatting 2023-10-12 08:55:26 +01:00
Keith Edmunds
87ab973439 Implement playlist range sort and unsort 2023-10-12 02:43:17 +01:00
Keith Edmunds
06e457a3da Save sorted selection 2023-10-10 01:28:31 +01:00
Keith Edmunds
8e2edb6af3 Add sort selection 2023-10-10 01:27:36 +01:00
Keith Edmunds
ee391e42e7 Minor tidying 2023-10-10 01:27:13 +01:00
Keith Edmunds
c078fa69e7 Only create one infotab at initialisation. 2023-10-06 19:10:19 +01:00
Keith Edmunds
da8272b29b Fix flickering when first marking a track as next
Pre-create the infotabs as adding the first one caused the flicker.
2023-10-06 18:04:11 +01:00
Keith Edmunds
b3905e062d Improve artist search
Replicate recent changes in title search to artist search
2023-10-06 10:58:15 +01:00
Keith Edmunds
6d48bcc9d0 Remove double ampersand in last track header 2023-10-06 10:52:28 +01:00
Keith Edmunds
f3a5ed2e72 Track selection dialog bugfix
If multiple tracks had the name name, only one would be listed.
2023-10-05 13:49:52 +01:00
Keith Edmunds
bb700d26f1 Faster track selection diaglog
Use better query to load last_played times along with tracks
2023-10-04 08:11:41 +01:00
Keith Edmunds
b2f826dfcc Much improved performance adding tracks 2023-10-01 15:17:27 +01:00
Keith Edmunds
c1fae2f91a Much improved performance adding tracks 2023-10-01 15:09:41 +01:00
Keith Edmunds
403c470c8a In track add dialog, ESC clears currently selected track 2023-09-30 21:32:08 +01:00
Keith Edmunds
8651dae3f3 Save wheel events 2023-09-30 20:46:16 +01:00
Keith Edmunds
c087858674 Add track dialog: add header if note given but no track selected 2023-09-30 20:45:12 +01:00
Keith Edmunds
494e124ac8 Separate path display from title/artist buttons, track add dialog 2023-09-30 20:38:46 +01:00
Keith Edmunds
b7a33d2676 Update Black 2023-09-30 20:37:56 +01:00
Keith Edmunds
dcab21bdde Reset preview button if preview track ends
Fixes #178
2023-07-14 17:16:14 +01:00
Keith Edmunds
cd04ec6339 Flake8 fixes 2023-07-09 23:27:13 +01:00
Keith Edmunds
a0a2903706 Make updating of clock backgrounds more efficient 2023-07-09 23:23:18 +01:00
Keith Edmunds
da267562ea Fix clocks for resumed track 2023-07-09 23:19:27 +01:00
Keith Edmunds
2ca1d30609 Rewrite timers/tick code
Fixes #176
2023-07-09 23:18:37 +01:00
Keith Edmunds
cb2017e953 Add button icons; wire up Stop button 2023-07-09 16:20:10 +01:00
Keith Edmunds
c7284c4397 Merge branch 'buttons' into dev 2023-07-09 16:15:29 +01:00
Keith Edmunds
986257bef6 Flake8 and Black run on all files 2023-07-09 16:12:21 +01:00
Keith Edmunds
fbc780b579 Put elapsed/total time below Preview button 2023-07-09 15:40:56 +01:00
Keith Edmunds
722043d049 Move Stop button away from other buttons
Fixes #177
2023-07-09 15:39:22 +01:00
Keith Edmunds
f44d6aa25e Documentation skeleton in place 2023-07-02 19:18:28 +01:00
Keith Edmunds
d3834928fd Remove padding around volume graph 2023-06-22 00:24:32 +01:00
Keith Edmunds
09f0e11aa7 Improve clock management
- tick() implemented independently of Config.TIMER_MS
 - have tick() call periodic functions
 - don't rely on vlc get_time() (too coarse)
2023-06-19 09:40:32 +01:00
Keith Edmunds
b706008101 Make volume fade graph update much smoother.
VLC get_time and get_position are very granular, only updating about
3-4 times a second. Instead, calculate play_time by substracting track
start time from current time and expressing that as milliseconds.
2023-06-19 00:55:04 +01:00
Keith Edmunds
4eb3a98c95 Added volume fade graph. 2023-06-18 09:20:55 +01:00
Keith Edmunds
af0d715423 Suppress pygame message at startup 2023-06-14 07:20:36 +01:00
Keith Edmunds
6ae6d8e94e WIP volume graphs using matlibplot 2023-06-13 07:55:24 +01:00
Keith Edmunds
df265ead69 Unset preview button if there's no track to preview 2023-06-12 17:54:58 +01:00
Keith Edmunds
52a4de0c01 Implement preview button
Fixes #172
2023-06-11 17:49:29 +01:00
Keith Edmunds
bcb079727a Install and set up pudb for non-production environment 2023-06-07 15:14:52 +01:00
Keith Edmunds
c0ae9eba9f Don't scroll display after drop
With no code, display scroll back to where the source rows came from.
With code we had, we ensured dropped rows were visible, but display
would still scroll.
Now freeze display as it is when rows are dropped.
2023-05-01 18:04:03 +01:00
Keith Edmunds
e3ad7787af Make header row span columns after drag and drop 2023-05-01 17:27:30 +01:00
Keith Edmunds
65f2f4f351 Ensure volume is set to VOLUME_VLC_DEFAULT on play 2023-04-21 14:37:48 +01:00
Keith Edmunds
f07ff56987 Intercept ESC on cell edit 2023-04-18 21:33:48 +01:00
Keith Edmunds
4a927084c9 Fix (workaround) volume going to zero after track starts 2023-04-14 11:12:13 +01:00
Keith Edmunds
8a6812e405 Greatly simplifed drag and drop code 2023-04-13 17:29:58 +01:00
Keith Edmunds
32cc0468e8 Disable drag and drop (todo: fix in qt6) 2023-04-13 14:45:29 +01:00
Keith Edmunds
a8ffa6f231 Upgrade PyQt5 → PyQt6 2023-04-12 21:55:13 +01:00
Keith Edmunds
7ff9146bd1 Update dependencies 2023-04-10 13:59:00 +01:00
Keith Edmunds
69d379ab10 Disconnect _cell_changed signal on edit abort 2023-04-10 13:58:32 +01:00
Keith Edmunds
ebc087f1f6 Improve typing 2023-04-10 13:58:07 +01:00
Keith Edmunds
3d32ce2f34 WIP to improve info tabs 2023-04-10 10:50:09 +01:00
Keith Edmunds
b122ac06a9 Workround to have tabs display 2023-04-10 10:49:54 +01:00
Keith Edmunds
543d0be7f2 Upgrade dependencies 2023-04-09 17:59:09 +01:00
Keith Edmunds
028c6cd43c Fix(?) music starting with volume=0 2023-04-09 17:53:06 +01:00
Keith Edmunds
fe338aaf4a Tidy up scene change code 2023-04-09 17:45:48 +01:00
Keith Edmunds
a923f32070 First pass of OBS scene change 2023-04-09 16:02:44 +01:00
Keith Edmunds
7dac80dcf6 Use QThreadPool to manage fades 2023-04-08 17:48:41 +01:00
Keith Edmunds
c0e1732bbc Fix replace_files prompt not showing 2023-04-06 18:51:08 +01:00
Keith Edmunds
c5c5c28583 Change PlaylistRows.row_number to plr_rownnum 2023-04-02 17:23:49 +01:00
Keith Edmunds
f3c86484fe Change remaining PlaylistRows.row_number to row_no 2023-04-02 15:14:11 +01:00
Keith Edmunds
034993b737 Remove .idea files 2023-04-01 19:59:58 +01:00
Keith Edmunds
f9f1e5f237 Change PlaylistRows.row_number to row_no 2023-04-01 19:59:25 +01:00
Keith Edmunds
5cb6e83cd5 Specifiy Python3 in hashbang line 2023-04-01 19:45:48 +01:00
Keith Edmunds
16a9880583 Improve track search performance
Searching for a track was wrapping the search string in % signs
(wildcards). The leading % meant the database didn't use the index.
Dropped leading % (user can add it manually if needed).
2023-04-01 19:45:07 +01:00
Keith Edmunds
69bfd3cff9 Default to moving existing track when adding a new track 2023-03-25 17:20:10 +00:00
Keith Edmunds
3a14207c71 Ensure we pass ints to signal 2023-03-25 16:30:58 +00:00
Keith Edmunds
25287c8f7f Tidy playlist header colours
Simplify and also ensure that playlist tab is uncoloured after
unsetting next track.
2023-03-25 15:52:17 +00:00
Keith Edmunds
4a03596bd3 Ensure current track visible toggling hide/show played 2023-03-25 10:30:18 +00:00
Keith Edmunds
9c66333729 musicmuster refactor: signal next tracks, tab colouring 2023-03-19 15:21:02 +00:00
Keith Edmunds
728feb1c8e Allow multiple selected rows to be marked unplayed 2023-03-19 13:47:49 +00:00
Keith Edmunds
c9c47c3133 Retain current/next colours when pasting tracks 2023-03-17 23:07:14 +00:00
Keith Edmunds
0b2e7c7e31 Update last played time when track ends 2023-03-17 22:50:54 +00:00
Keith Edmunds
a30f054eb0 Set tab colours correctly 2023-03-17 22:43:36 +00:00
Keith Edmunds
eafacc3b21 Retain current/next colouring after editing notes 2023-03-17 18:28:32 +00:00
Keith Edmunds
a29bf3fce5 Fix first track staying green after end 2023-03-17 16:27:01 +00:00
Keith Edmunds
b30f2d5cc3 Fix play with mplayer 2023-03-16 15:20:31 +00:00
Keith Edmunds
6bf9330b62 Fix 'called set_header on track row'
Ensure playlist is saved before updating track start/end times.
2023-03-15 18:28:37 +00:00
Keith Edmunds
f3631b2c2b Synchronise row start/end updates
Row start/end time updates were being run in a different SQLAlchemy
session to the database updates and thus there was a lack of
synchronisation.

Now they run in the same session.
2023-03-14 22:59:39 +00:00
Keith Edmunds
3197c844a5 Print stack trace to stdout on internal error 2023-03-13 09:12:19 +00:00
Keith Edmunds
e22351386f Fix bug editing header rows 2023-03-13 09:11:47 +00:00
Keith Edmunds
ee422aacb3 Update track times after drag and drop 2023-03-12 18:48:36 +00:00
Keith Edmunds
380806d27a Change row to row_number 2023-03-12 18:43:23 +00:00
Keith Edmunds
c6840d2356 Improve copying track path 2023-03-12 18:41:44 +00:00
Keith Edmunds
453e42172b Use Audacity and mplayer without session 2023-03-12 18:41:13 +00:00
Keith Edmunds
019bc87eb0 Fix sense of file_is_unreadable() 2023-03-12 18:38:00 +00:00
Keith Edmunds
ee64a4a035 Remove unused function _get_row_start_time 2023-03-12 17:08:13 +00:00
Keith Edmunds
9c67b9bd8e Change row to row_number 2023-03-12 17:03:47 +00:00
Keith Edmunds
3cc90f8c11 Remove unneeded function _get_current_track_start_time 2023-03-12 16:53:13 +00:00
Keith Edmunds
71daccab12 Remove unneeded function _get_current_track_end_time 2023-03-12 16:51:02 +00:00
Keith Edmunds
ca86f59736 Rename function file_is_readable to file_is_unreadable 2023-03-12 16:47:45 +00:00
Keith Edmunds
d609656ae3 Change row to row_number 2023-03-12 16:44:12 +00:00
Keith Edmunds
f96e02d9ae Remove unused function _deferred_save() 2023-03-12 16:43:51 +00:00
Keith Edmunds
6c53d59f1a Fix adding/removing track from row 2023-03-12 16:23:56 +00:00
Keith Edmunds
b9fd7a5d21 Clean up editing 2023-03-12 16:23:36 +00:00
Keith Edmunds
669125794f Change row to row_number 2023-03-12 16:22:59 +00:00
Keith Edmunds
4094b63f44 Switch to existing infotab if it contains required URL 2023-03-12 13:25:20 +00:00
Keith Edmunds
b126a70139 Fix and improve hide played tracks
Last played track is now not hidden until
Config.HIDE_AFTER_PLAYING_OFFSET milliseconds after next track starts
playing.
2023-03-12 13:00:46 +00:00
Keith Edmunds
f30fff5356 Fix development bug that truncated playlists
Saving of playlist and updating note colours more consistent.
2023-03-12 10:33:10 +00:00
Keith Edmunds
80e698680b Clean up header and note updates
• rationalise number of functions
• make colour handling cleaner
• optimise when playlist is saved
2023-03-12 09:53:11 +00:00
Keith Edmunds
39ec7f470b Fixup section duration times 2023-03-11 16:05:10 +00:00
Keith Edmunds
16ad7ae5aa Produce consistent log output 2023-03-11 16:02:26 +00:00
Keith Edmunds
d54f1bedda Remove colon-in-path conditional fix 2023-03-10 23:11:23 +00:00
Keith Edmunds
ad071bb74b Consistently use clear_next() to clear next track 2023-03-10 23:10:54 +00:00
Keith Edmunds
2422adea21 Fix play sometimes stopping almost immediately 2023-03-10 22:34:23 +00:00
Keith Edmunds
ee7436221e Playlist save / session work 2023-03-09 08:35:16 +00:00
Keith Edmunds
889d32cc90 Post editing fixes
Fix row or cell colour
Fix row height after expanding when editing starts
2023-03-08 20:09:15 +00:00
Keith Edmunds
ae1835a421 Use signals to updates note text after editing
Hypothesis: this stops some kind of database race condition or
similar.
2023-03-08 20:08:17 +00:00
Keith Edmunds
8dd13a2ba2 Log file that creates sessions 2023-03-08 20:07:07 +00:00
Keith Edmunds
dda74782b6 Keep section headers bold 2023-03-07 18:02:17 +00:00
Keith Edmunds
4af1d4906c Never hide current or next row 2023-03-07 18:02:00 +00:00
Keith Edmunds
ea5e4a2215 Fix merge error 2023-03-05 20:23:43 +00:00
Keith Edmunds
e80a74cc40 Fixup track start/end times 2023-03-05 20:21:27 +00:00
Keith Edmunds
d92612c69a Tidy up when track start/stop times are recalculated 2023-03-05 20:19:40 +00:00
Keith Edmunds
b1841b02ea WIP playlists refactor: set header colour when removing track 2023-03-05 20:05:04 +00:00
Keith Edmunds
c5f89dbcf4 WIP playlists refactor: unify note and tab colour settings 2023-03-05 19:44:13 +00:00
Keith Edmunds
188623e574 Always treat running from mm dir as production 2023-03-05 14:59:00 +00:00
Keith Edmunds
0978e93ee7 WIP: playlists refactor: fixup context menu 2023-03-05 14:36:01 +00:00
Keith Edmunds
15f4bec197 WIP: playlists refactoring 2023-03-05 14:31:30 +00:00
Keith Edmunds
530ee60015 WIP: playlists.py refactoring 2023-03-04 23:02:21 +00:00
Keith Edmunds
4a6ce3b4ee WIP: playists refactor: fix rescan 2023-03-01 20:27:17 +00:00
Keith Edmunds
9d3743ceb5 Update section timer and end of section note 2023-02-28 21:27:48 +00:00
Keith Edmunds
bc06722633 Launch Wikipedia on select vis singleShot timer 2023-02-28 21:27:20 +00:00
Keith Edmunds
aa3388f732 WIP: playlist refactor: section timings 2023-02-28 20:46:22 +00:00
Keith Edmunds
634637f42c WIP: playlist refacton: start/end times
Clean up function. If next track is above current track, flow start
times around current track rather than resetting them at current
track.
2023-02-26 22:04:39 +00:00
Keith Edmunds
613fa4343b Fix cancelling creation of new playlist 2023-02-26 22:03:13 +00:00
Keith Edmunds
e23f8afed2 WIP: playlist refactor fix default header colour 2023-02-26 21:31:20 +00:00
Keith Edmunds
9a7d24b895 Sample tree.py showing expansion/contraction 2023-02-25 19:46:25 +00:00
Keith Edmunds
45a564729b WIP playlists refactor including fixing saving playlist 2023-02-25 19:45:56 +00:00
Keith Edmunds
cc2f3733b2 Start using signals to call for saving playlist 2023-02-25 19:44:02 +00:00
Keith Edmunds
77716005c7 Modify session logging 2023-02-25 19:40:15 +00:00
Keith Edmunds
fed4e9fbde Open Wikipedia page on single row selection 2023-02-24 20:32:27 +00:00
Keith Edmunds
5902428c23 Clear selection after edit 2023-02-24 20:25:19 +00:00
Keith Edmunds
58ec47517d WIP: playlists.py refactor 2023-02-24 19:31:38 +00:00
Keith Edmunds
c14f03f0c1 WIP: playlists.py refactor
Reset colour of current track when it has finished and is on a
different tab to the next track.
2023-02-19 21:31:06 +00:00
Keith Edmunds
2cd49b5898 WIP: playlists.py refactor
Tracks are bold on import
2023-02-19 21:22:04 +00:00
Keith Edmunds
6de95573ff WIP: playlists.py refactor
Hide/show played tracks
2023-02-19 20:36:08 +00:00
Keith Edmunds
19377a8e1c WIP: playlists.py refactor
Reset background colour of current track when track ended.
2023-02-19 20:26:55 +00:00
Keith Edmunds
0794f061ee WIP: playlists.py refactor 2023-02-19 20:09:00 +00:00
Keith Edmunds
1c294e1ce4 Only send exception mails from production environment 2023-02-18 18:11:56 +00:00
Keith Edmunds
a41aea2d36 Fix potential bug in get_selected_playlistrows()
It was possible for the returned list to have embedded None objects
2023-02-18 10:43:38 +00:00
Keith Edmunds
c93f24970f Fix moving tracks to another playlist 2023-02-16 11:23:16 +00:00
Keith Edmunds
5fc1d21f5a Clean up "importing track" message 2023-02-16 11:22:52 +00:00
Keith Edmunds
8476dd4ace Add ability to delete and rename playlists
Fixes #54
2023-02-13 19:34:28 +00:00
Keith Edmunds
2a6dfc8b63 Fix can't add track to header row 2023-02-10 08:43:04 +00:00
Keith Edmunds
424709ca74 Fix startup issues after refactor 2023-02-10 08:42:41 +00:00
Keith Edmunds
4b104798b8 Add unmark as next, played to context menu
Fixes #166
Fixex #138
2023-02-08 20:52:42 +00:00
Keith Edmunds
a15f181008 Fix start time calc that stopped app starting 2023-02-08 16:10:31 +00:00
Keith Edmunds
0c38fc2ef4 Fix all bar one typing errors 2023-02-07 21:58:08 +00:00
Keith Edmunds
df2652e6cc Import tracks in QThread
Allows progress messages to be sent
Fixes #164
2023-02-07 21:25:16 +00:00
Keith Edmunds
1cc1f1a185 Display ampersands correctly in header
Fixes #165
2023-02-06 21:51:53 +00:00
Keith Edmunds
4a6d6fa208 Log errors importing tracks 2023-02-05 22:48:32 +00:00
Keith Edmunds
4f3fb6c1ae No mypy errors; four FIXMEs 2023-02-05 21:04:10 +00:00
Keith Edmunds
e4ef0b34c8 Improve type hints, rework code
Fixes #147
2023-02-05 17:38:56 +00:00
Keith Edmunds
9e6c700644 More typing fixes 2023-02-04 15:01:39 +00:00
Keith Edmunds
f182f49f15 More typing 2023-02-01 08:43:53 +00:00
Keith Edmunds
5d50ebf3aa Typing and other cleanups 2023-01-31 21:14:02 +00:00
Keith Edmunds
73bb4b3a7f WIP: typing 2023-01-30 19:29:33 +00:00
Keith Edmunds
dfb9326d5e Fix display corruption adding a track
Fixes #137
2023-01-29 18:31:50 +00:00
Keith Edmunds
e736cb82d2 Close MySQL session after running standalone commands 2023-01-27 10:53:28 +00:00
Keith Edmunds
d471082e3f Clean up dependencies, update them, add vulture settings 2023-01-20 22:01:52 +00:00
Keith Edmunds
e77c05b908 Remove unused functions 2023-01-20 22:01:05 +00:00
Keith Edmunds
ffa3015ac3 Fix move existing track when adding duplicate with note
Fixes #161
2023-01-20 22:00:47 +00:00
Keith Edmunds
f8dcc69a55 Python typing fixups 2023-01-20 21:59:40 +00:00
Keith Edmunds
c04114b07a Fix some type hints 2023-01-19 23:32:20 +00:00
Keith Edmunds
92852f7e27 Fix bug moving unplayed tracks
Fixes #162
2023-01-19 23:29:52 +00:00
Keith Edmunds
0507f495ad Fix adding only a note from track dialog
Fixes #160
2023-01-16 17:20:18 +00:00
Keith Edmunds
d87ff80bef Fix next track not selected when playing top row 2023-01-07 12:26:38 +00:00
Keith Edmunds
27cc86d48d Ensure when track stops playing it is no longer highlighted as current
track in playlist.
2023-01-07 12:21:53 +00:00
Keith Edmunds
7584ad2090 Make row number a playlist-only concept
Solves problem of rows being moved in playlist and musicmuster not
knowing which row the current/next track is (but it doesn't need to
know; it only needs to know the PlaylistRows id).
2023-01-07 11:50:05 +00:00
Keith Edmunds
087139f4de Quickfix: couldn't close tabs 2023-01-02 08:58:16 +00:00
Keith Edmunds
ed4a106bec Fix not recording playlist rows as played 2023-01-01 18:56:02 +00:00
Keith Edmunds
90424e917e Fix not recording playlist rows as played 2023-01-01 18:51:56 +00:00
Keith Edmunds
4870647387 Fix current track highligting when starting track on another playlist 2023-01-01 18:27:41 +00:00
Keith Edmunds
046b689882 Fixup moving tracks between playlists.
Fixes #155
2023-01-01 15:52:06 +00:00
Keith Edmunds
74028fadf7 Set colours of tabs correctly. 2023-01-01 14:25:06 +00:00
Keith Edmunds
4edcab1542 Skip over unreadable tracks when selecting next track. 2023-01-01 11:08:37 +00:00
Keith Edmunds
5e75659c48 Don't use row metadat for next/current track
Get them from musicmuster.
2023-01-01 10:49:54 +00:00
Keith Edmunds
daf8069de2 Tidy up moving to PlaylistTrack object 2023-01-01 09:19:34 +00:00
Keith Edmunds
4beafe7cfc Fix typo Session→session 2023-01-01 08:33:06 +00:00
Keith Edmunds
2a484d51d3 Remove function_logger
It doesn't work properly (call methods with an additional "None"
argument).
2023-01-01 08:11:41 +00:00
Keith Edmunds
b476db188f Implement PlaylistTrack object 2022-12-30 21:43:47 +00:00
Keith Edmunds
ce08790343 Merge branch 'resume_use_plrs_issue128' into use_plrs 2022-12-30 10:37:02 +00:00
Keith Edmunds
1d35574224 Add flakehell to pyproject 2022-12-30 10:29:38 +00:00
Keith Edmunds
f1c27e0e8c WIP 2022-12-29 08:56:58 +00:00
Keith Edmunds
aa405cd6d9 WIP for resume play 2022-12-28 15:08:54 +00:00
Keith Edmunds
8f8c6a1034 Remove redundant code 2022-12-28 09:33:40 +00:00
Keith Edmunds
ece6723211 Database changes needed for 2.8 and 2.9 2022-12-25 10:29:05 +00:00
Keith Edmunds
a56cdea207 Clean up .envrc 2022-12-25 10:15:56 +00:00
Keith Edmunds
683e76f9a0 Update database correctly when tabs are closed 2022-12-24 20:24:27 +00:00
Keith Edmunds
abd6ad0a64 Fix to not sending stack dumps in development environment 2022-12-24 20:23:30 +00:00
Keith Edmunds
ea4d7693ef Don't send stackdumps by mail in DEVELOPMENT environment 2022-12-24 18:46:04 +00:00
Keith Edmunds
94b2f473e9 Cleanups from running vulture 2022-12-24 09:36:51 +00:00
Keith Edmunds
f2a27366d3 Fix deleting rows from playlist 2022-12-23 21:27:06 +00:00
Keith Edmunds
46f2b662f3 Copy/paste, insert track/header works 2022-12-23 20:52:18 +00:00
Keith Edmunds
647e7d478a Move rows works. 2022-12-23 20:37:21 +00:00
Keith Edmunds
444c3e4fb4 Remove rows from playlist works and db updates 2022-12-23 20:15:07 +00:00
Keith Edmunds
35b101a538 Tidy up saving database 2022-12-23 17:23:43 +00:00
Keith Edmunds
d3958db8a3 Fix crash if create new playlist is cancelled 2022-12-23 09:27:14 +00:00
Keith Edmunds
be4f19757c Improve performance of save_playlist 2022-12-22 17:41:46 +00:00
Keith Edmunds
784d036bb7 Finally(?) sort out stackprinter logging. 2022-12-21 15:06:10 +00:00
Keith Edmunds
6a2bcfff19 Restore tab order and focussed tab
Fixes #96
2022-12-20 18:35:18 +00:00
Keith Edmunds
eb7ed1d6dd Install line-profiler 2022-12-19 21:31:08 +00:00
Keith Edmunds
78a9103490 Better stackprinter handling 2022-12-19 21:07:03 +00:00
Keith Edmunds
0d4b306fc4 Don't scroll on drag and drop
Fixes #152
2022-12-19 18:14:59 +00:00
Keith Edmunds
57f038c704 Implement row mark and paste
Fixed #132
2022-12-19 15:28:03 +00:00
Keith Edmunds
999a98e2ad Check before moving unplayed tracks
Fixes #151
2022-12-18 23:11:05 +00:00
Keith Edmunds
2ada8a27fe Tidy up log.py 2022-12-18 22:23:17 +00:00
Keith Edmunds
bd9c8a84b9 Implement stackprinter 2022-12-18 22:20:55 +00:00
Keith Edmunds
693e8f195d Notify when issue #147 occurs 2022-12-18 21:03:45 +00:00
Keith Edmunds
d9851adf65 Fix inability to play tracks with colon in path
Fixes #103
2022-12-17 19:47:17 +00:00
Keith Edmunds
30bd23c088 Workaround for issue #147 2022-11-24 09:17:40 +00:00
Keith Edmunds
f297923a2f Hide carts from config 2022-11-11 21:47:04 +00:00
Keith Edmunds
41379efd1b Limit number of matching tracks on import 2022-11-11 21:12:12 +00:00
Keith Edmunds
6339326947 Don't scroll to top without a row 2022-11-11 21:06:15 +00:00
Keith Edmunds
a0c1dad2f5 Merge branch 'dev' 2022-11-10 10:12:13 +00:00
Keith Edmunds
25add4239d Limit matching tracks on import to five 2022-11-10 10:11:42 +00:00
Keith Edmunds
04f1fba581 Ignore directories for replace_files 2022-11-10 10:11:20 +00:00
Keith Edmunds
9af20c29d3 Fix scroll to current/next with hidden rows 2022-11-06 16:18:51 +00:00
Keith Edmunds
2b4e003caf Speed up marking track as next 2022-10-28 13:22:00 +01:00
Keith Edmunds
0f5edcc86c Use signal to update cart progress bar 2022-10-26 20:09:04 +01:00
Keith Edmunds
52776fcf8d Workaround to crash when playing cart with next track selected 2022-10-26 14:20:34 +01:00
Keith Edmunds
2f13099bda Don't allow cart click while that cart is playing. 2022-10-25 07:46:14 +01:00
Keith Edmunds
9ccff3db20 Specify colour of cart progress bars 2022-10-23 22:37:06 +01:00
Keith Edmunds
ef9b1e7ce5 Remove redundant debug logging 2022-10-23 16:29:38 +01:00
Keith Edmunds
5e770b3975 Cart progress bar tweaks 2022-10-23 16:29:03 +01:00
Keith Edmunds
6c92401ad6 Put progress bars on playing cart buttons. 2022-10-23 16:17:43 +01:00
Keith Edmunds
5b0d604edf Remove extraneous message 2022-10-22 08:55:14 +01:00
Keith Edmunds
15258f6cc8 Put bar under carts 2022-10-22 08:51:52 +01:00
Keith Edmunds
001df4cfce Merge branch 'newcarts' into dev 2022-10-21 22:55:06 +01:00
Keith Edmunds
f42261277e Carts: tidy up code 2022-10-21 22:54:50 +01:00
Keith Edmunds
1899aac9ae Implement carts 2022-10-21 22:41:38 +01:00
Keith Edmunds
72b0555271 Make stderr logging level ERROR 2022-10-21 16:08:23 +01:00
Keith Edmunds
a649fa8c59 WIP: Carts 2022-10-15 20:15:30 +01:00
Keith Edmunds
ef17b359e2 Put KAE in debug logging strings 2022-10-15 17:57:44 +01:00
Keith Edmunds
0b91cf7da4 WIP: carts 2022-10-15 17:42:37 +01:00
Keith Edmunds
4f3769ae38 Populate footer with next track info if not playing
Fixes #133
2022-10-15 13:39:54 +01:00
Keith Edmunds
69afb2986e Highlight leading gap when adding track to header
Fixes #142
2022-10-15 10:21:23 +01:00
Keith Edmunds
39f5374b32 Disable set next track during editing
Fixes #130
2022-10-14 22:15:40 +01:00
Keith Edmunds
ed2b919db4 Reorder functions 2022-10-14 21:54:39 +01:00
Keith Edmunds
bf67866f8a debug markers to investigate #137 2022-10-14 15:50:13 +01:00
Keith Edmunds
4357e0e038 Fix size/spacing of header bars
Fixes #144
2022-10-14 14:22:49 +01:00
Keith Edmunds
5783da051e Add debug statements for scroll to next/current 2022-10-14 09:05:12 +01:00
Keith Edmunds
3528b58174 Add debug to help menu 2022-10-13 19:12:49 +01:00
Keith Edmunds
f6e2fe7652 Add debug to help menu 2022-10-13 19:12:30 +01:00
Keith Edmunds
2d62fb993f Facility to add notes when inserting tracks 2022-10-02 14:05:25 +01:00
Keith Edmunds
11090b57ad Preserve note when adding track to header 2022-10-01 16:47:03 +01:00
Keith Edmunds
00d3add0d3 Implement templates 2022-10-01 14:14:26 +01:00
Keith Edmunds
9f32abc2ea Fix removing track from row (ie, make it a header) 2022-10-01 09:04:37 +01:00
Keith Edmunds
3609a224f1 Fix adding track to header row 2022-10-01 08:57:43 +01:00
Keith Edmunds
5d3d373abc Update headers when editing current/next track
Fixes #126
2022-09-30 22:26:49 +01:00
Keith Edmunds
c3712eba27 Switch to correct tab when clicking on next/current header 2022-09-30 21:45:15 +01:00
Keith Edmunds
1da0668807 Preserve bitrate when importing track 2022-09-30 18:54:23 +01:00
Keith Edmunds
1ce009ee73 Playlist deals with invalid track_id 2022-09-30 18:53:04 +01:00
Keith Edmunds
5d1078dea0 Debug output to try to track down why titles are changing 2022-09-30 18:26:13 +01:00
Keith Edmunds
e1ceb5e8e3 Update bitrate displayed if db differs from display 2022-09-30 18:25:51 +01:00
Keith Edmunds
912ed0b1eb Use symbols for columns 2022-09-30 18:24:50 +01:00
Keith Edmunds
d670f397fc Stop notes column going to zero width on track import 2022-09-30 15:55:52 +01:00
Keith Edmunds
7829186d55 Keep row selected after adding section header 2022-09-30 15:33:33 +01:00
Keith Edmunds
0c37eccb76 Adjust row height to edited striped text 2022-09-30 15:21:13 +01:00
Keith Edmunds
7601c7dc4c Clean up duplicate prompts when importing track 2022-09-23 21:13:48 +01:00
Keith Edmunds
84d746bd2f Use symbolic names for columns 2022-09-23 21:09:14 +01:00
Keith Edmunds
b42ffcec69 Fix notes not wrapping on startup
Ensure notes column stretches to fill width and that it wraps.
2022-09-19 19:26:59 +01:00
Keith Edmunds
632e555bed Make clock bar darker 2022-09-19 15:54:36 +01:00
Keith Edmunds
c63bbcd574 Set environment variables for changed database names 2022-09-18 19:41:55 +01:00
Keith Edmunds
dff7e2323d Set next track start time correctly when current track on another tab 2022-09-12 18:24:15 +01:00
Keith Edmunds
0194790605 Clean up importing and track rescan 2022-09-12 18:23:30 +01:00
Keith Edmunds
11eaa803f5 Remove odd file 2022-09-12 18:20:24 +01:00
Keith Edmunds
c907736436 Remove redundant code 2022-09-10 21:59:14 +01:00
Keith Edmunds
c0c90595fd Close Session context before importing tracks 2022-09-09 07:29:46 +01:00
Keith Edmunds
7163a4c6e4 Re-enable session logging 2022-09-09 07:29:20 +01:00
Keith Edmunds
cc80022428 Add About box with version and database name 2022-09-07 20:38:36 +01:00
Keith Edmunds
2f5d00fa3a Scroll to current/next on header click 2022-09-07 20:07:02 +01:00
Keith Edmunds
af11f90808 Only autoscroll when track played 2022-09-07 19:47:51 +01:00
Keith Edmunds
27eba987ca No default note background for track notes 2022-09-07 19:00:48 +01:00
Keith Edmunds
7e02bd60e5 Make 'show played' work again 2022-09-05 18:51:12 +01:00
Keith Edmunds
8044f95556 Remove current track higlighting at end of track 2022-09-05 18:42:30 +01:00
Keith Edmunds
56b99630c1 Increase row height on edit to make editing easier 2022-09-04 21:41:46 +01:00
Keith Edmunds
cdb9e1fb59 Enforce minimum row height; adjust height more intelligently 2022-09-04 21:25:18 +01:00
Keith Edmunds
6ede0ab7ea Pull playlist changes from v2_editor
- minimum row height
- intelligent row resizing
2022-09-04 20:55:40 +01:00
Keith Edmunds
958edb0140 Expand last column; use ^Return to close editor 2022-09-04 19:20:54 +01:00
Keith Edmunds
f2f99b5f79 Don't clear selection after adding as track 2022-08-24 17:51:01 +01:00
Keith Edmunds
f3ccab513b Put section headers in row 2
Bug in Qt means automatically setting row height doesn't take into
account row spans, so putting headers in narrow column makes for tall
rows.
2022-08-24 17:33:22 +01:00
Keith Edmunds
7819e863eb Merge branch 'EditorClosing' into v3_play 2022-08-24 14:35:10 +01:00
Keith Edmunds
9f6eb2554a close edit box with return 2022-08-24 14:35:01 +01:00
Keith Edmunds
b5c792b8d8 Lots of work on replace_files.py 2022-08-24 12:44:56 +01:00
Keith Edmunds
2b48e889a5 Always print summary from replace_files 2022-08-23 10:38:25 +01:00
Keith Edmunds
688267834d Set bitrate in replace_files.py 2022-08-23 09:32:26 +01:00
Keith Edmunds
c9a411d15d Tuning replace_files.py 2022-08-22 19:27:47 +01:00
Keith Edmunds
a0c074adad Checked all queries are SQLAlchemy V2 format 2022-08-22 17:46:04 +01:00
Keith Edmunds
140722217b Add bitrates to database and display 2022-08-22 17:30:30 +01:00
Keith Edmunds
0e9461e0df Merge branch 'replacing_files' into v3_play 2022-08-22 16:09:04 +01:00
Keith Edmunds
f851fdcafe First draft of rename_singles.py 2022-08-22 16:08:24 +01:00
Keith Edmunds
26358761e5 Default to no processing in replace_files.py 2022-08-22 16:07:44 +01:00
Keith Edmunds
6ce41d3314 Check replace_files is run against production db 2022-08-22 16:01:56 +01:00
Keith Edmunds
62c5fa178c Work around MariaDB bug in replace_files.py 2022-08-22 14:39:18 +01:00
Keith Edmunds
5f8d8572ad Don't allow duplicate track paths 2022-08-21 19:47:47 +01:00
Keith Edmunds
16b9ac19f0 Reset colours for each track on update_display 2022-08-21 17:00:42 +01:00
Keith Edmunds
1bae79265d Only adjust height of track rows with notes, not header rows 2022-08-17 22:18:25 +01:00
Keith Edmunds
c9cdbe2eb2 Remove commented code 2022-08-17 21:30:04 +01:00
Keith Edmunds
dfcdc0b9e8 Only resize track rows that have notes 2022-08-17 21:28:32 +01:00
Keith Edmunds
957450c0f6 Use QPlainTextEdit to edit cells 2022-08-17 21:28:15 +01:00
Keith Edmunds
20e9880a03 Set alternate row colous using App.setPalette 2022-08-17 21:12:21 +01:00
Keith Edmunds
503ba36a88 Replacing files fine tuning 2022-08-17 17:09:19 +01:00
Keith Edmunds
d267b32c0d WIP trying things 2022-08-17 13:30:45 +01:00
Keith Edmunds
7b2b7fada5 WIP: replace notes TableWidgetItem with TextEdit 2022-08-17 12:52:09 +01:00
Keith Edmunds
bcc6634e34 Work on replacing existing music files 2022-08-17 11:28:10 +01:00
Keith Edmunds
4fad05db6b QTextEdit WIP 2022-08-16 12:30:03 +01:00
Keith Edmunds
c4be0b55d4 Make rows tall enough for notes, notes not bold 2022-08-16 10:46:42 +01:00
Keith Edmunds
88d0c11cbc Add track to header working 2022-08-15 21:36:04 +01:00
Keith Edmunds
a67b295f33 Reorder functions 2022-08-15 17:16:06 +01:00
Keith Edmunds
01a9ce342a Open wikipedia and songfacts from right click menu.
Also reorganised right click menu.
2022-08-15 17:06:01 +01:00
Keith Edmunds
6ddb40d146 Remove superflous code 2022-08-15 16:01:16 +01:00
Keith Edmunds
61311f67fe Implement musicuster --check-database 2022-08-15 15:59:34 +01:00
Keith Edmunds
8ec0911ce4 Insert commented placeholders for column sorting 2022-08-15 15:33:12 +01:00
Keith Edmunds
87e2f33f59 Scroll to put next, not current, track at top 2022-08-15 15:31:26 +01:00
Keith Edmunds
92bdf216ca Remove unused code 2022-08-15 14:19:56 +01:00
Keith Edmunds
73e728177e Import track working 2022-08-15 14:16:46 +01:00
Keith Edmunds
3b4cf5320d Remove unused code 2022-08-15 12:45:45 +01:00
Keith Edmunds
d5950ab29a Move selected / move unplayed working 2022-08-15 12:29:36 +01:00
Keith Edmunds
eff80d684e Log exceptions to screen 2022-08-15 12:20:40 +01:00
Keith Edmunds
dcc84e0df1 Move selected working 2022-08-15 09:31:30 +01:00
Keith Edmunds
49bef912d2 Refactor playlist searching 2022-08-15 09:10:26 +01:00
Keith Edmunds
8fedb394a4 Fix artist search and match on row zero 2022-08-14 22:45:00 +01:00
Keith Edmunds
23af906d95 Remove all linting errors 2022-08-14 22:33:14 +01:00
Keith Edmunds
ebdb0d0a82 Much improved search now working 2022-08-14 22:19:15 +01:00
Keith Edmunds
b7c0fa94dd Fixed up some editing oddities 2022-08-14 13:22:54 +01:00
Keith Edmunds
29857e1185 Section timing now works 2022-08-14 11:40:17 +01:00
Keith Edmunds
56fb1aeb3d Add section header working 2022-08-14 11:01:20 +01:00
Keith Edmunds
dfc1344c69 Insert track working 2022-08-14 10:25:10 +01:00
Keith Edmunds
bdf7b0979d Cell editing rewrite
Simplied, commented, no longer using custom signals, all functions
have type information.
2022-08-13 22:12:22 +01:00
Keith Edmunds
cee84563fb WIP re editing 2022-08-13 21:13:03 +01:00
Keith Edmunds
4d9bf9a36b Hide/show played tracks button working 2022-08-13 16:32:37 +01:00
Keith Edmunds
ce0c3de40d 3dB drop button working 2022-08-13 16:11:55 +01:00
Keith Edmunds
0f8c648d1c Reorder functions alphabetically 2022-08-13 16:05:12 +01:00
Keith Edmunds
a1060d1173 Skip to next working 2022-08-13 15:24:34 +01:00
Keith Edmunds
930efbbe6e Select next/prev row working 2022-08-13 15:21:09 +01:00
Keith Edmunds
cb5eedd8c8 Open playlists working; playlist queries refactored 2022-08-13 14:50:23 +01:00
Keith Edmunds
c7034cf35a Create playlist working 2022-08-13 14:19:08 +01:00
Keith Edmunds
436f6b4fa9 Export playlist working 2022-08-13 13:32:25 +01:00
Keith Edmunds
9485b244f5 Export played tracks csv works 2022-08-13 12:57:37 +01:00
Keith Edmunds
63acc025f9 Close tab works 2022-08-13 12:27:38 +01:00
Keith Edmunds
066b20a571 Close playlist from menubar 2022-08-13 12:03:35 +01:00
Keith Edmunds
f1796451ae Refine save_playlist 2022-08-13 11:06:52 +01:00
Keith Edmunds
5ba70c9c6f Copy escaped track path 2022-08-13 11:06:20 +01:00
Keith Edmunds
568dc1ef68 Don't check Audacity; save splitter position 2022-08-13 11:05:39 +01:00
Keith Edmunds
7d71e8ce64 WIP: clocks working 2022-08-12 21:25:59 +01:00
Keith Edmunds
afc27c988d Move info tabs to below playlist 2022-08-12 11:57:34 +01:00
Keith Edmunds
70c2c18fb3 WIP (working on marking next track) 2022-08-11 14:43:19 +01:00
Keith Edmunds
c8194fad80 WIP: Implement move rows to playlist 2022-08-09 20:33:06 +01:00
Keith Edmunds
12541e1ff7 WIP: delete playlist rows working 2022-08-09 17:08:18 +01:00
Keith Edmunds
99409e8626 Right-click menu mostly working
Still to implement:
 - Move to playlist
 - Remove row
2022-08-07 20:20:56 +01:00
Keith Edmunds
89781c0a94 Revise menu, selected tracks duration summing OK 2022-08-07 16:15:11 +01:00
Keith Edmunds
91841cfc18 Clear drag mode with clear selection 2022-08-07 11:54:18 +01:00
Keith Edmunds
96255e83ea Enable drag-select, then drag selection 2022-08-06 22:41:18 +01:00
Keith Edmunds
32e81fb074 Save of new style playlist implemented but not tested 2022-08-06 21:17:11 +01:00
Keith Edmunds
7a14651bd7 Add function type hints. Section headers and note colours working 2022-08-05 21:52:17 +01:00
Keith Edmunds
4f03306aff SQLA2: WIP, playlists load 2022-08-03 21:11:02 +01:00
Keith Edmunds
caed7fd079 SQLA2: sync'd to v2.3.1 2022-07-31 22:22:55 +01:00
Keith Edmunds
b7111d8a3b SQLA2: WIP 2022-07-31 21:11:34 +01:00
Keith Edmunds
64799ccc61 Scheme fixed for v2.4 (nee v3) 2022-07-06 21:40:35 +01:00
Keith Edmunds
2d886f3413 SQLA2.0 tidy up Alembic migration file 2022-07-05 07:59:40 +01:00
Keith Edmunds
374a312797 SQLA2.0 schema updates, column width saves 2022-07-04 21:32:23 +01:00
Keith Edmunds
ab47bb0ab4 SQLA2.0 playlist column headers display 2022-07-03 20:59:10 +01:00
Keith Edmunds
bef4507ef6 SQLA2.0 rewrote logging 2022-07-03 15:17:25 +01:00
Keith Edmunds
ff2f0d576c SQLA2.0 main window displays 2022-07-02 21:47:42 +01:00
Keith Edmunds
8192e79d42 Make search case insensitive 2022-06-19 13:57:39 +01:00
Keith Edmunds
29860268ba Revise UI; add -3db button
Fixes #55
2022-06-19 13:33:04 +01:00
Keith Edmunds
de3a746806 WIP: button to drop 3db 2022-06-18 19:04:01 +01:00
Keith Edmunds
ce21322117 Clean up last played time in update_display 2022-06-18 18:34:06 +01:00
Keith Edmunds
cc395ea0df Move notes with tracks
Fixes #106
2022-06-18 18:24:09 +01:00
Keith Edmunds
709347db6b WIP: move notes with tracks 2022-06-18 11:09:47 +01:00
Keith Edmunds
8558de82b4 Fix bug stopping right-click menu 2022-06-10 15:28:12 +01:00
Keith Edmunds
5c02f82d21 Merge branch 'mplayer' 2022-06-10 14:59:47 +01:00
Keith Edmunds
b05e6d156d Add 'play with mplayer' to right click menu
Fixes #118
2022-06-10 14:57:01 +01:00
Keith Edmunds
44e4e451ad Make session acquisition silent by default
Also suppress notification to stdout of database in use.
2022-06-10 08:44:56 +01:00
Keith Edmunds
3f609f6f2f Don't output DEBUG messages to stdout by default 2022-06-08 13:05:34 +01:00
Keith Edmunds
1888c7f00d Fix cron job
Now only reports errors but does not attempt to fix them.

Fixes #114
2022-06-05 15:18:45 +01:00
Keith Edmunds
c6d55344c7 Add 'move track to playlist' to right-click menu
Fixes #117
2022-06-05 14:30:29 +01:00
Keith Edmunds
42092d3d39 Add 'last played' time to track select from database box
Fixes #116
2022-06-04 23:05:39 +01:00
Keith Edmunds
fbe9c2ba94 Fix deleting multiple rows
Also allow mass delete to be cancelled.

Fixes #115
2022-06-04 22:56:38 +01:00
Keith Edmunds
a8395d8c97 Fix background importing and duplicate checking 2022-06-04 22:32:22 +01:00
Keith Edmunds
fc9a10ad52 Tidy up playlist.remove_track 2022-05-02 17:32:29 +01:00
Keith Edmunds
8b644ee236 Clarify comment 2022-05-02 16:09:29 +01:00
Keith Edmunds
c7f7f25af0 Run file import in separate thread 2022-04-19 15:25:15 +01:00
Keith Edmunds
e2af6dd7ac Remove erroneous type 2022-04-19 10:07:39 +01:00
Keith Edmunds
a4ad78cec3 Fix up Python type checking 2022-04-19 09:47:30 +01:00
Keith Edmunds
fd0d3e6e1f Move cron jobs to musicmuster.py 2022-04-18 14:53:57 +01:00
Keith Edmunds
70287d15a6 Implement search of playlist 2022-04-17 13:10:21 +01:00
Keith Edmunds
871598efe6 Code cleanup 2022-04-17 11:30:49 +01:00
Keith Edmunds
f143bd7fe9 Rebase from dev 2022-04-17 10:44:15 +01:00
Keith Edmunds
9e65eef621 Fix next start times
Fixes #113
2022-04-17 10:42:20 +01:00
Keith Edmunds
0fe26e8a75 Fix application icon in resources 2022-04-09 22:40:12 +01:00
Keith Edmunds
75bd981dba Move application icon to resources 2022-04-09 22:25:04 +01:00
Keith Edmunds
da9da3780a Add application icon 2022-04-09 22:18:07 +01:00
Keith Edmunds
cf7930190e Add ability to download CSV of played tracks.
Fixes #60
2022-04-09 22:08:08 +01:00
Keith Edmunds
e1800328fd Set MM_ENV from .envrc 2022-04-09 19:00:41 +01:00
Keith Edmunds
dd86c60636 Fix background color of row 1 on play 2022-04-08 22:53:48 +01:00
Keith Edmunds
a774f148ee Fix track length on import 2022-04-08 22:47:50 +01:00
Keith Edmunds
9da5328735 Use exports in run_prod 2022-04-07 11:51:18 +01:00
Keith Edmunds
79e1fdde27 Update note row number in db when it changes 2022-04-06 19:37:10 +01:00
Keith Edmunds
fe4b1f8b5e Crude track import 2022-04-05 22:12:05 +01:00
Keith Edmunds
1abee60827 Correct prod pw/allow adding multiple db tracks 2022-04-05 21:23:30 +01:00
Keith Edmunds
6ca37bc45a Protect music player during fade 2022-04-05 21:23:30 +01:00
Keith Edmunds
558a283e73 Detect music playing better 2022-04-05 21:03:28 +01:00
Keith Edmunds
fe660524a0 All tests passing 2022-04-05 17:00:29 +01:00
Keith Edmunds
805053b795 Improve performance selecting multiple tracks 2022-04-04 21:30:49 +01:00
Keith Edmunds
c5f33c437f Fix moving tracks between playlists 2022-04-04 21:30:31 +01:00
Keith Edmunds
0a3700e208 Correct production database credentials 2022-04-04 21:28:54 +01:00
Keith Edmunds
976eb91e30 Fix move selected tracks 2022-03-20 22:40:38 +00:00
Keith Edmunds
ebfdf98612 Polish typing, explicit returns to terminate context managers 2022-03-20 18:56:59 +00:00
Keith Edmunds
0fb1536055 Add section timing 2022-03-20 11:42:05 +00:00
Keith Edmunds
ca385dcf54 Remove test function 2022-03-19 23:24:42 +00:00
Keith Edmunds
0d865f05ac Clean up dbconfig session handling 2022-03-19 23:24:18 +00:00
Keith Edmunds
75b814e26c Session acquisitiong logging 2022-03-19 20:30:14 +00:00
Keith Edmunds
47f53428f6 Session fixes, MSS colour 2022-03-19 20:20:22 +00:00
Keith Edmunds
e2c5bba4ae Minor tweak to tests 2022-03-15 21:29:36 +00:00
Keith Edmunds
7f046ae86b test_playlists complete and working 2022-03-14 21:40:15 +00:00
Keith Edmunds
a27dd7189a Fix tests 2022-03-14 20:13:14 +00:00
Keith Edmunds
34fa0c92b2 Update packages 2022-03-14 20:11:11 +00:00
Keith Edmunds
87f9e1e81b Merge 2022-03-14 20:10:59 +00:00
Keith Edmunds
a31718d2b9 Separate db config, testing session for pytest 2022-03-14 20:10:07 +00:00
Keith Edmunds
cf4e42358e First moves to separate db config 2022-03-14 20:09:38 +00:00
Keith Edmunds
4ce6c2e9b9 Add pytest-qt back in 2022-03-12 08:28:22 +00:00
Keith Edmunds
fbca77debe Package management so tests start passing 2022-03-12 08:21:00 +00:00
Keith Edmunds
3ebb3e1acf Enhance tests 2022-03-11 23:04:09 +00:00
Keith Edmunds
f0b9ab4256 Fix up remove track from playlist 2022-03-09 21:40:47 +00:00
Keith Edmunds
2b02c1b5b4 profiling 2022-03-06 12:05:12 +00:00
Keith Edmunds
a882d409cb Session sanity 2022-03-04 22:59:01 +00:00
Keith Edmunds
2186b3eb09 Record playlist opening and closing
Also fixes #95
2022-03-04 18:55:02 +00:00
Keith Edmunds
06efaf2ba2 Fix tests 2022-03-04 18:34:31 +00:00
Keith Edmunds
9c0371d41c Scroll current row to top; improve session handling 2022-03-04 18:17:57 +00:00
Keith Edmunds
e7004688d0 Add configurable web zoom factor 2022-03-04 16:53:10 +00:00
Keith Edmunds
8c69f108cb Change LH clock box
Fixes #102, #99
2022-03-04 16:01:20 +00:00
Keith Edmunds
f22f209bee Fix some type hints 2022-03-03 18:30:13 +00:00
Keith Edmunds
1c56505ab0 Fix playlist export 2022-03-03 18:30:00 +00:00
Keith Edmunds
ca1b11b545 Fix select all (un)played tracks 2022-03-03 17:30:37 +00:00
Keith Edmunds
9397adee03 Don't allow active tab to be closed 2022-03-02 22:04:53 +00:00
Keith Edmunds
4a83e9af86 Revamp menus 2022-03-02 21:13:41 +00:00
Keith Edmunds
f22f2780a3 Fix move tracks 2022-03-02 20:37:27 +00:00
Keith Edmunds
f1aba41921 Update all packages 2022-03-02 09:34:52 +00:00
Keith Edmunds
a2fb6baba8 Rebase dev onto v2_id 2022-03-02 09:30:26 +00:00
Keith Edmunds
08eea631d6 Rebase dev onto v2_id 2022-03-02 09:27:37 +00:00
Keith Edmunds
d62a044522 Fix typo 2022-03-02 09:27:12 +00:00
Keith Edmunds
e8211414f9 V2 using ids rather than objects. Looking good. 2022-03-02 09:27:12 +00:00
Keith Edmunds
26edd5a2d0 more session stuff 2022-03-02 09:27:12 +00:00
Keith Edmunds
bc6a4c11cf Rebase dev onto v2_id 2022-03-02 09:27:10 +00:00
Keith Edmunds
a91309477b Rebase dev onto v2_id 2022-03-02 09:25:59 +00:00
Keith Edmunds
3a7b09f025 Code cleanups 2022-03-02 09:24:40 +00:00
Keith Edmunds
7f2dd68bce Rebase dev onto v2_id 2022-03-02 09:24:35 +00:00
Keith Edmunds
281a1d40bf Rebase dev onto v2_id 2022-03-02 09:23:56 +00:00
Keith Edmunds
cf58932fca Rebase dev onto v2_id 2022-03-02 09:16:07 +00:00
Keith Edmunds
b92a0927f8 Get row and track from playlist.tracks with tests 2022-03-02 09:14:52 +00:00
Keith Edmunds
ab9955b88a v2 tidy/refactor 2022-03-02 09:14:52 +00:00
Keith Edmunds
b00f70ff4b v2 tidy/refactor 2022-03-02 09:14:52 +00:00
Keith Edmunds
9fb05079dc All helper tests pass 2022-03-02 09:14:52 +00:00
Keith Edmunds
1c86728170 Added .rescan to Tracks
Also added tests for rescan function
2022-03-02 09:14:52 +00:00
Keith Edmunds
557b89ba09 Refactoring and tests for models complete (for now) 2022-03-02 09:14:52 +00:00
Keith Edmunds
7cd2d610b1 playlist.tracks now association object plus refactoring 2022-03-02 09:14:52 +00:00
Keith Edmunds
ac27486317 Rebase dev onto v2_id 2022-03-02 09:14:44 +00:00
Keith Edmunds
907861ea48 Rebase dev onto v2_id 2022-03-02 09:13:43 +00:00
Keith Edmunds
04c3c2efbc Refactoring 2022-03-02 09:13:11 +00:00
Keith Edmunds
fa2e1234e9 Remove redundant functions and tests 2022-03-02 09:13:11 +00:00
Keith Edmunds
fec45925c6 Remove redundant functions and tests 2022-03-02 09:13:11 +00:00
Keith Edmunds
fcebe2f220 Rebase dev onto v2_id 2022-03-02 09:12:55 +00:00
Keith Edmunds
00f85a9a96 Add PyCharm config files to git 2022-03-02 09:12:00 +00:00
Keith Edmunds
f3bf829ef3 Rebase dev onto v2_id 2022-03-02 09:11:52 +00:00
Keith Edmunds
1a0cac22f6 Added more tests in test_models 2022-03-02 09:11:10 +00:00
Keith Edmunds
9aa6941fca Added first few tests in test_models 2022-03-02 09:11:10 +00:00
Keith Edmunds
a164f4c962 Rebase dev onto v2_id branch 2022-03-02 09:10:46 +00:00
Keith Edmunds
db86d04b9a Make alembic.ini safe
All database URLs are commented out. The appropriate one should be
uncommented when needed.
2022-03-02 09:08:27 +00:00
Keith Edmunds
3cab7a8376 Auto-create MySQL connect string in env vars 2022-03-02 09:08:27 +00:00
Keith Edmunds
2015dcce1f Use colour rather than hexcolour in notecolours table 2022-03-02 09:08:27 +00:00
Keith Edmunds
03735c2456 Add ipdb to dev tools 2022-02-26 09:26:44 +00:00
Keith Edmunds
b283a3db07 Warn if colon in track path 2022-02-26 09:26:13 +00:00
Keith Edmunds
cb50fc253b Make current track in playlist lighter green 2022-02-20 11:10:23 +00:00
Keith Edmunds
9d78e5fe57 Update packages 2022-02-12 10:10:27 +00:00
Keith Edmunds
bb648488d6 Add order to colours table 2022-02-05 23:46:43 +00:00
Keith Edmunds
0ae5a99346 Merge branch 'notecolours' into dev 2022-02-05 21:33:25 +00:00
Keith Edmunds
53899b3a24 Manage note colours from database 2022-02-05 21:32:41 +00:00
Keith Edmunds
1ea2f7b531 Update db correctly when opening/closing playlists.
Ensures that open playlist dialog box lists playlists
in last-used order.
2022-02-05 20:40:17 +00:00
Keith Edmunds
441c47bdc2 Improve closing of playist tabs
Fixes #90
2022-02-05 20:00:10 +00:00
Keith Edmunds
1de7cefe72 Start configurable note colours 2022-02-05 18:42:35 +00:00
Keith Edmunds
eb1dc4c07d Add PyCharm files to git 2022-02-05 16:42:45 +00:00
Keith Edmunds
80126440c8 Have notes span all columns
Fixes #88
2022-02-05 16:30:52 +00:00
Keith Edmunds
e256ceee0f Fixups from PyCharm 2022-02-05 16:14:10 +00:00
Keith Edmunds
bf2ef70595 Use date, not datetime, to dermine how long ago track was last played.
Fixes #92.
2022-02-05 16:11:44 +00:00
Keith Edmunds
88b2789128 Move to Poetry 2022-01-26 20:54:30 +00:00
Keith Edmunds
62364fdaf1 Don't automatically select previously played tracks
Fixes #89
2021-10-17 12:08:13 +01:00
Keith Edmunds
125a44c645 Add 'this month then' note colour 2021-10-16 10:33:32 +01:00
Keith Edmunds
a72a86cfcc Don't prompt for duplicate track on a rescan
Fixes #87
2021-10-15 15:02:25 +01:00
Keith Edmunds
1a16b1022d Implement tab close buttons
Fixes #81
2021-09-29 21:29:20 +01:00
Keith Edmunds
69fb10fcd9 Make database update check cron-friendly.
Fixes #85
2021-09-29 20:55:39 +01:00
Keith Edmunds
1a4f842f1f Set last played time when playing track
Fixes #83
2021-09-26 08:47:00 +01:00
Keith Edmunds
69dd0235a0 Improve note colouring
- Make case insensitive
 - If not starts with key, it's a match

Fixes #71
2021-09-25 22:33:17 +01:00
Keith Edmunds
ab858a62fd Fix moving tracks with Wikipedia tabs open
Fixes #77
2021-09-25 22:22:34 +01:00
Keith Edmunds
01b531aabf Scroll to show moved tracks on drag and drop
Fixes #75
2021-09-24 15:10:17 +01:00
Keith Edmunds
6ccfae0ab1 Add note colouring by keyword
Fixes #71
2021-09-24 14:58:35 +01:00
Keith Edmunds
9cf9ef9a59 Add ^T shortcut to add note
Fixes #69
2021-09-24 14:43:33 +01:00
Keith Edmunds
21fe8fff83 Update track.lastplayed field
Fixes #78
2021-09-24 08:05:01 +01:00
Keith Edmunds
780b053219 Check for duplicate title on import
Fixes #80
2021-09-23 18:07:28 +01:00
Keith Edmunds
2fbf829eed Show track info when importing track
Fixes #79
2021-09-23 17:50:39 +01:00
Keith Edmunds
32fb44439d Change force play next keyboard shortcut
Now control-alt-return to prevent muscle memory typing control-return

Fixes #76
2021-09-23 08:08:36 +01:00
Keith Edmunds
8b641cd728 Fix last track going blank
Fixes: #68
2021-09-11 16:53:00 +01:00
Keith Edmunds
d5d4361ec5 Further fixes to moving tracks between playlists
Fixes: #38
2021-09-10 11:48:30 +01:00
Keith Edmunds
c69aefef92 Save playlist after moving tracks to another list
Fixes: #38
2021-09-10 09:25:06 +01:00
Keith Edmunds
baf0c180bd Add .desktop file 2021-09-03 14:16:44 +01:00
Keith Edmunds
b46830f010 Tab text colours implemented
Fixes #61
2021-08-24 16:41:50 +01:00
Keith Edmunds
0a4730e5a7 Start implementing coloured text on tabs 2021-08-24 15:13:03 +01:00
Keith Edmunds
e4fe4b576e Clear start/end time for unplayed tracks above current
Fixes #53
2021-08-23 19:25:47 +01:00
Keith Edmunds
54cfb1191a Set start correctly when note edited 2021-08-23 15:19:52 +01:00
Keith Edmunds
d8072ae73f Remove TODOs from code.
Fixes #57
2021-08-23 09:23:18 +01:00
Keith Edmunds
d2e2144148 Remove inapplicable right-click menu items 2021-08-22 20:40:41 +01:00
Keith Edmunds
9dfc5e50cc Improve tagging on rescan 2021-08-22 20:40:13 +01:00
Keith Edmunds
4267901630 Tweak right-click menu order 2021-08-22 19:13:33 +01:00
Keith Edmunds
c5f094443a Enable editing with Audacity
Fixes #28
2021-08-22 17:42:31 +01:00
Keith Edmunds
70d986f4ac Delete multiple rows
Fixes #22
2021-08-22 16:42:33 +01:00
Keith Edmunds
d9ccaf7caa Allow in-playist editing of title, artist and notes
Fixes #27 #23
2021-08-22 13:52:22 +01:00
Keith Edmunds
d767c879c6 Improve track info dialog box 2021-08-22 13:02:03 +01:00
Keith Edmunds
0caf48919c Implement database search by artist
Fixes #31
2021-08-22 09:53:54 +01:00
Keith Edmunds
15ec91e446 Implement track rescanning
Fixes #29
2021-08-21 23:34:33 +01:00
Keith Edmunds
04788ef923 Implement copy track path
Fixes #30
2021-08-21 22:58:01 +01:00
Keith Edmunds
79f9a49659 Remove debug statement 2021-08-21 22:44:14 +01:00
Keith Edmunds
834ad68e00 Tab info for previous / current / next track 2021-08-21 20:47:55 +01:00
Keith Edmunds
8fa85dd47f Import multiple tracks from command line 2021-08-21 18:14:47 +01:00
Keith Edmunds
ccbe8fdb1b Import tracks from command line
songdb.py -i FILENAME
2021-08-21 16:46:37 +01:00
Keith Edmunds
762a41bec6 Add total time of selected tracks to status bar 2021-08-21 14:22:55 +01:00
Keith Edmunds
7ed7730574 Clean up timers when track ends 2021-08-15 17:03:19 +01:00
Keith Edmunds
0e3e30391b Don't grow window when track title too long
Use an elided text box, set wrapping and max height for label.

Fixes #26
2021-08-15 16:03:48 +01:00
Keith Edmunds
246b0d4915 Improve full database update sanity check 2021-08-15 13:04:30 +01:00
Keith Edmunds
fcf4ba3eb9 Implement full database scan 2021-08-15 12:52:50 +01:00
Keith Edmunds
a7d9252619 Move Fade button to right of Stop
Fixes #50
2021-08-15 11:22:35 +01:00
Keith Edmunds
d4f542cc29 Warn when trying to delete playing or next track 2021-08-15 11:17:09 +01:00
Keith Edmunds
2c9f041838 Show last track in playlist as playing when it is
Fixes #52
2021-08-15 11:06:08 +01:00
Keith Edmunds
90a8209551 Clean up of musicmuster.py 2021-08-15 10:40:28 +01:00
Keith Edmunds
c0752407b9 Handle next track not found consistently
Highlight in red, don't set as next track.
Fixes #51
2021-08-15 10:13:42 +01:00
Keith Edmunds
87fb74b14f Tidy up model.py 2021-08-15 09:21:32 +01:00
Keith Edmunds
6336eb9215 add test file for fades 2021-08-15 00:21:40 +01:00
Keith Edmunds
ee74deaa49 Clean up when tracks ends and next track is not immediately played. 2021-08-15 00:20:30 +01:00
Keith Edmunds
00cae6dc52 Fix up silence detection from last commit 2021-08-15 00:03:52 +01:00
Keith Edmunds
11e3536801 Emit INFO message during database scan 2021-08-14 23:53:43 +01:00
Keith Edmunds
427afee8da Change algorithm to detect fade point 2021-08-14 23:52:31 +01:00
Keith Edmunds
b4da349a8c Remove unused function last_show() 2021-08-14 23:07:30 +01:00
Keith Edmunds
0836f74d17 Improve 'last played' strings 2021-08-14 23:06:16 +01:00
Keith Edmunds
89d49f3e34 Merge 2021-08-14 18:44:05 +01:00
Keith Edmunds
e813a01e14 Improve track info box 2021-08-14 18:29:29 +01:00
Keith Edmunds
72e3ef69ff Handle files not found in database update
Fixes #37
Fixes #36
2021-08-14 18:26:59 +01:00
Keith Edmunds
94e7508a24 Default volume to 75 2021-08-14 12:03:46 +01:00
Keith Edmunds
0e4de857d4 Update last played time during show
Fixes #43
2021-08-14 09:05:14 +01:00
Keith Edmunds
4687ef5288 Fix check of whether track is readable
Fixes #45
Fixes #44
Fixes #42
2021-08-14 08:20:02 +01:00
Keith Edmunds
f0b59b8d23 Improve track info box. Fixes #46 2021-08-14 08:03:03 +01:00
Keith Edmunds
976beade85 Add debug to troubleshoot issue #38 2021-08-10 18:28:20 +01:00
Keith Edmunds
bc54be237b Check tracks for readability
Check on load and on setting next track. Also provide info popup that
shows path.
2021-08-10 08:18:05 +01:00
Keith Edmunds
61e1fb1192 Make last played date 'today' when appropriate 2021-08-08 20:05:26 +01:00
Keith Edmunds
35f2b9629b Only open Wikipedia for songs 2021-08-06 13:39:22 +01:00
Keith Edmunds
a6a0b905d8 Put "last played" in place of "path" in playlist 2021-08-06 10:23:30 +01:00
Keith Edmunds
79f1a6afa3 Set track end time when setting next track. Fixes #33 2021-07-24 17:38:53 +01:00
Keith Edmunds
194306bc1d Order functions alphabetically 2021-07-24 17:29:59 +01:00
Keith Edmunds
4f10ed7bad Normalise mp3's on import 2021-07-15 17:54:34 +01:00
Keith Edmunds
2edf12670f Add POC of audacity control 2021-07-04 19:28:18 +01:00
Keith Edmunds
a027cbe776 Greatly improve database update 2021-07-04 19:28:18 +01:00
Keith Edmunds
28396d136f Add ui/.py files to git 2021-07-04 19:28:18 +01:00
Keith Edmunds
2fc705dc6e Fix typo in run_prod 2021-07-04 19:23:11 +01:00
Keith Edmunds
6936b24129 Facilitate dev and prod databases - fixes #15 2021-07-04 19:21:28 +01:00
Keith Edmunds
199dada246 Save playlist column widths correctly 2021-07-03 10:15:39 +01:00
Keith Edmunds
8838c23c59 Add end times column. Fixes #24 2021-07-03 10:15:08 +01:00
Keith Edmunds
5b6db24692 Clear fade b/g colour explicity - should fix #25 2021-07-03 09:51:54 +01:00
Keith Edmunds
019e9f6cf3 Warn if leading silence over 500ms. Helps #11 2021-06-12 13:19:33 +01:00
Keith Edmunds
f37c6f3e70 Improve metadata handling; fixes #20 2021-06-12 10:09:32 +01:00
Keith Edmunds
f4efeac36a Relayout buttons. Fixes #21 2021-06-12 09:31:37 +01:00
Keith Edmunds
a89e3cf1c9 Fix ToD clock width - fixes #19 2021-06-12 09:27:38 +01:00
Keith Edmunds
b45fab2855 Better UI info - helps issue #11
- add status bar message to show whether play controls are enabled
 - add warning background colour to 'fade' box
2021-06-11 09:29:51 +01:00
Keith Edmunds
8baf01bc60 Added DEBUG statements to investigate issue #11 2021-06-11 09:05:02 +01:00
Keith Edmunds
6e754c1b3a Make music fading more solid - issue #3 2021-06-10 17:55:55 +01:00
Keith Edmunds
a80dc3f165 Select and move (un)played tracks. Fixes #4 2021-06-10 15:24:31 +01:00
Keith Edmunds
73879c6a99 Add locking to music.py
Ensure nothing interrupts the stop - release - nullify sequence. Also
don't limit how many concurrent fades there can be.
2021-06-07 20:46:05 +01:00
Keith Edmunds
987db155a1 Tighten up player handling (mitigate for issue #11) 2021-06-06 20:01:28 +01:00
Keith Edmunds
6310dfd5c7 Add DEBUG statements to investigate issue #11 2021-06-06 16:52:12 +01:00
Keith Edmunds
caf78df17f Differentiate between playlist tabs and db objects. Fixes #17 2021-06-06 16:40:36 +01:00
Keith Edmunds
20bd178cf1 Differentiate between playlist tabs and db objects. Fixes #17 2021-06-06 16:40:10 +01:00
Keith Edmunds
37ccf7c325 Fix moving tracks between playlists 2021-06-06 15:57:32 +01:00
Keith Edmunds
823d0b6628 Fix error closing playlist 2021-06-06 14:51:46 +01:00
Keith Edmunds
ec760ca0d4 Allow adding more than one file at a time 2021-06-06 14:48:58 +01:00
Keith Edmunds
0ca9bfec0a Segregate adding notes, tracks to onscreen playlist and database 2021-06-06 14:47:14 +01:00
Keith Edmunds
e14bed34bd Improve repr for mode:Playlists 2021-06-06 14:44:15 +01:00
Keith Edmunds
6677577df5 Wire up Tracks, Stop menu. Fixed #6. 2021-06-06 14:43:27 +01:00
Keith Edmunds
c5f5155332 Remove link to database object from playlist. Fixes #16 2021-06-06 11:36:27 +01:00
Keith Edmunds
e498457395 Add option to force DEBUG message to stderr
If the default log level for stderr is greater than DEBUG, DEBUG
message won't be shown. The DEBUG(msg) function now takes an optional
Boolean second parameter. If that is True, the DEBUG message is always
sent to stderr.
2021-06-06 10:50:40 +01:00
Keith Edmunds
dbf0c27a09 Set up session before calling DbDialog. Fixes #13 2021-06-06 10:23:27 +01:00
172 changed files with 47572 additions and 20514 deletions

26
.envrc
View File

@ -1 +1,25 @@
layout python3
layout uv
export LINE_PROFILE=1
export MAIL_PASSWORD="ewacyay5seu2qske"
export MAIL_PORT=587
export MAIL_SERVER="smtp.fastmail.com"
export MAIL_USERNAME="kae@midnighthax.com"
export MAIL_USE_TLS=True
export PYGAME_HIDE_SUPPORT_PROMPT=1
branch=$(git branch --show-current)
# Always treat running from /home/kae/mm as production
if [ $(pwd) == /home/kae/mm ]; then
export MM_ENV="PRODUCTION"
export DATABASE_URL="mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_prod"
# on_git_branch is a direnv directive
# See https://github.com/direnv/direnv/blob/master/man/direnv-stdlib.1.md
elif on_git_branch master; then
export MM_ENV="PRODUCTION"
export DATABASE_URL="mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_prod"
else
export MM_ENV="DEVELOPMENT"
export DATABASE_URL="mysql+mysqldb://dev_musicmuster:dev_musicmuster@localhost/dev_musicmuster"
export PYTHONBREAKPOINT="pudb.set_trace"
fi

13
.flake8 Normal file
View File

@ -0,0 +1,13 @@
[flake8]
max-line-length = 88
select = C,E,F,W,B,B950
extend-ignore = E203, E501
exclude =
.git
app/ui,
__pycache__,
archive,
migrations,
prof,
docs,
app/icons_rc.py

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.py diff=python

6
.gitignore vendored
View File

@ -1,8 +1,8 @@
.mypy_cache/
*_ui.py
*.pyc
*.swp
tags
.venv/
venv/
Session.vim
*.flac
@ -11,3 +11,7 @@ StudioPlaylist.png
*.otl
*.howto
.direnv
tmp/
.coverage
profile_output*
kae.py

View File

@ -1 +1 @@
musicmuster
3.13

View File

@ -1,18 +1,29 @@
# A generic, single database configuration.
# a multi-database configuration.
[alembic]
# this must be configured to point to the Alchemical database instance
# there are two components separated by a colon:
# the left part is the import path to the module containing the database instance
# the right part is the name of the database instance, typically 'db'
alchemical_db = models:db
# path to migration scripts
script_location = migrations
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
# for all available tokens
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
prepend_sys_path = .
prepend_sys_path = app
# timezone to use when rendering the date
# within the migration file as well as the filename.
# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the python-dateutil library that can be
# installed by adding `alembic[tz]` to the pip requirements
# string value is passed to dateutil.tz.gettz()
# leave blank for localtime
# timezone =
@ -30,28 +41,36 @@ prepend_sys_path = .
# versions/ directory
# sourceless = false
# version location specification; this defaults
# version location specification; This defaults
# to migrations/versions. When using multiple version
# directories, initial revisions must be specified with --version-path
# version_locations = %(here)s/bar %(here)s/bat migrations/versions
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "version_path_separator" below.
# version_locations = %(here)s/bar:%(here)s/bat:migrations/versions
# version path separator; As mentioned above, this is the character used to split
# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep.
# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas.
# Valid values for version_path_separator are:
#
# version_path_separator = :
# version_path_separator = ;
# version_path_separator = space
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.
# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8
sqlalchemy.url = mysql+mysqldb://songdb:songdb@localhost/musicmuster
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples
# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks=black
# black.type=console_scripts
# black.entrypoint=black
# black.options=-l 79
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME
# Logging configuration
[loggers]

View File

@ -2,7 +2,7 @@
import os
from pydub import AudioSegment, effects
from pydub import AudioSegment
# DIR = "/home/kae/git/musicmuster/archive"
DIR = "/home/kae/git/musicmuster"

155
app/audacity_controller.py Normal file
View File

@ -0,0 +1,155 @@
# Standard library imports
import os
import psutil
import socket
import select
from typing import Optional
# PyQt imports
# Third party imports
# App imports
from classes import ApplicationError
from config import Config
from log import log
class AudacityController:
def __init__(
self,
method: str = "pipe",
socket_host: str = "localhost",
socket_port: int = 12345,
timeout: int = Config.AUDACITY_TIMEOUT_SECONDS,
) -> None:
"""
Initialize the AudacityController.
:param method: Communication method ('pipe' or 'socket').
:param socket_host: Host for socket connection (if using sockets).
:param socket_port: Port for socket connection (if using sockets).
:param timeout: Timeout in seconds for pipe operations.
"""
self.method = method
self.path: Optional[str] = None
self.timeout = timeout
if method == "pipe":
user_uid = os.getuid() # Get the user's UID
self.pipe_to = f"/tmp/audacity_script_pipe.to.{user_uid}"
self.pipe_from = f"/tmp/audacity_script_pipe.from.{user_uid}"
elif method == "socket":
self.socket_host = socket_host
self.socket_port = socket_port
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
self.sock.connect((self.socket_host, self.socket_port))
self.sock.settimeout(self.timeout)
except socket.error as e:
raise ApplicationError(f"Failed to connect to Audacity socket: {e}")
else:
raise ApplicationError("Invalid method. Use 'pipe' or 'socket'.")
self._sanity_check()
def close(self):
"""
Close the connection (for sockets).
"""
if self.method == "socket":
self.sock.close()
def export(self) -> None:
"""
Export file from Audacity
"""
self._sanity_check()
select_status = self._send_command("SelectAll")
log.debug(f"{select_status=}")
# Escape any double quotes in filename
export_cmd = f'Export2: Filename="{self.path.replace('"', '\\"')}" NumChannels=2'
export_status = self._send_command(export_cmd)
log.debug(f"{export_status=}")
self.path = ""
if not export_status.startswith("Exported"):
raise ApplicationError(f"Error writing from Audacity: {export_status=}")
def open(self, path: str) -> None:
"""
Open path in Audacity. Escape filename.
"""
self._sanity_check()
escaped_path = path.replace('"', '\\"')
cmd = f'Import2: Filename="{escaped_path}"'
status = self._send_command(cmd)
self.path = path
log.debug(f"_open_in_audacity {path=}, {status=}")
def _sanity_check(self) -> None:
"""
Check Audactity running and basic connectivity.
"""
# Check Audacity is running
if "audacity" not in [i.name() for i in psutil.process_iter()]:
log.warning("Audactity not running")
raise ApplicationError("Audacity is not running")
# Check pipes exist
if self.method == "pipe":
if not (os.path.exists(self.pipe_to) and os.path.exists(self.pipe_from)):
raise ApplicationError(
"AudacityController: Audacity pipes not found. Ensure scripting is enabled "
f"and pipes exist at {self.pipe_to} and {self.pipe_from}."
)
def _test_connectivity(self) -> None:
"""
Send test command to Audacity
"""
response = self._send_command(Config.AUDACITY_TEST_COMMAND)
if response != Config.AUDACITY_TEST_RESPONSE:
raise ApplicationError(
"Error testing Audacity connectivity\n"
f"Sent: {Config.AUDACITY_TEST_COMMAND}"
f"Received: {response}"
)
def _send_command(self, command: str) -> str:
"""
Send a command to Audacity.
:param command: Command to send (e.g., 'SelectAll').
:return: Response from Audacity.
"""
log.debug(f"_send_command({command=})")
if self.method == "pipe":
try:
with open(self.pipe_to, "w") as to_pipe:
to_pipe.write(command + "\n")
with open(self.pipe_from, "r") as from_pipe:
ready, _, _ = select.select([from_pipe], [], [], self.timeout)
if ready:
response = from_pipe.readline()
else:
raise TimeoutError(
f"Timeout waiting for response from {self.pipe_from}"
)
except Exception as e:
raise RuntimeError(f"Error communicating with Audacity via pipes: {e}")
elif self.method == "socket":
try:
self.sock.sendall((command + "\n").encode("utf-8"))
response = self.sock.recv(1024).decode("utf-8")
except socket.timeout:
raise TimeoutError("Timeout waiting for response from Audacity socket.")
except Exception as e:
raise RuntimeError(f"Error communicating with Audacity via socket: {e}")
return response.strip()

154
app/classes.py Normal file
View File

@ -0,0 +1,154 @@
# Standard library imports
from __future__ import annotations
from dataclasses import dataclass
from enum import auto, Enum
import functools
import threading
from typing import NamedTuple
# Third party imports
# PyQt imports
from PyQt6.QtCore import (
pyqtSignal,
QObject,
)
from PyQt6.QtWidgets import (
QProxyStyle,
QStyle,
QStyleOption,
)
# App imports
# Define singleton first as it's needed below
def singleton(cls):
"""
Make a class a Singleton class (see
https://realpython.com/primer-on-python-decorators/#creating-singletons)
Added locking.
"""
lock = threading.Lock()
@functools.wraps(cls)
def wrapper_singleton(*args, **kwargs):
if wrapper_singleton.instance is None:
with lock:
if wrapper_singleton.instance is None: # Check still None
wrapper_singleton.instance = cls(*args, **kwargs)
return wrapper_singleton.instance
wrapper_singleton.instance = None
return wrapper_singleton
class ApplicationError(Exception):
"""
Custom exception
"""
pass
class AudioMetadata(NamedTuple):
start_gap: int = 0
silence_at: int = 0
fade_at: int = 0
class Col(Enum):
START_GAP = 0
TITLE = auto()
ARTIST = auto()
INTRO = auto()
DURATION = auto()
START_TIME = auto()
END_TIME = auto()
LAST_PLAYED = auto()
BITRATE = auto()
NOTE = auto()
class FileErrors(NamedTuple):
path: str
error: str
@dataclass
class Filter:
version: int = 1
path_type: str = "contains"
path: str = ""
last_played_number: int = 0
last_played_comparator: str = "before"
last_played_unit: str = "years"
duration_type: str = "longer than"
duration_number: int = 0
duration_unit: str = "minutes"
@singleton
@dataclass
class MusicMusterSignals(QObject):
"""
Class for all MusicMuster signals. See:
- https://zetcode.com/gui/pyqt5/eventssignals/
- https://stackoverflow.com/questions/62654525/emit-a-signal-from-another-class-to-main-class
"""
begin_reset_model_signal = pyqtSignal(int)
enable_escape_signal = pyqtSignal(bool)
end_reset_model_signal = pyqtSignal(int)
next_track_changed_signal = pyqtSignal()
resize_rows_signal = pyqtSignal(int)
search_songfacts_signal = pyqtSignal(str)
search_wikipedia_signal = pyqtSignal(str)
show_warning_signal = pyqtSignal(str, str)
span_cells_signal = pyqtSignal(int, int, int, int, int)
status_message_signal = pyqtSignal(str, int)
track_ended_signal = pyqtSignal()
def __post_init__(self):
super().__init__()
class PlaylistStyle(QProxyStyle):
def drawPrimitive(self, element, option, painter, widget=None):
"""
Draw a line across the entire row rather than just the column
we're hovering over.
"""
if (
element == QStyle.PrimitiveElement.PE_IndicatorItemViewItemDrop
and not option.rect.isNull()
):
option_new = QStyleOption(option)
option_new.rect.setLeft(0)
if widget:
option_new.rect.setRight(widget.width())
option = option_new
super().drawPrimitive(element, option, painter, widget)
class QueryCol(Enum):
TITLE = 0
ARTIST = auto()
DURATION = auto()
LAST_PLAYED = auto()
BITRATE = auto()
class Tags(NamedTuple):
artist: str = ""
title: str = ""
bitrate: int = 0
duration: int = 0
class TrackInfo(NamedTuple):
track_id: int
row_number: int

View File

@ -1,40 +1,145 @@
# Standard library imports
import datetime as dt
import logging
import os
# PyQt imports
# Third party imports
# App imports
class Config(object):
AUDACITY_TEST_COMMAND = "Message"
AUDACITY_TEST_RESPONSE = "Some message"
AUDACITY_TIMEOUT_SECONDS = 20
AUDIO_SEGMENT_CHUNK_SIZE = 10
COLOUR_CURRENT_HEADER = "#d4edda"
COLOUR_CURRENT_PLAYLIST = "#28a745"
COLOUR_ODD_PLAYLIST = "#f2f2f2"
BITRATE_LOW_THRESHOLD = 192
BITRATE_OK_THRESHOLD = 300
COLOUR_BITRATE_LOW = "#ffcdd2"
COLOUR_BITRATE_MEDIUM = "#ffeb6f"
COLOUR_BITRATE_OK = "#dcedc8"
COLOUR_CURRENT_PLAYLIST = "#7eca8f"
COLOUR_CURRENT_TAB = "#248f24"
COLOUR_ENDING_TIMER = "#dc3545"
COLOUR_EVEN_PLAYLIST = "#d9d9d9"
COLOUR_NEXT_HEADER = "#fff3cd"
COLOUR_LABEL_TEXT = "#000000"
COLOUR_LONG_START = "#dc3545"
COLOUR_NEXT_PLAYLIST = "#ffc107"
COLOUR_NEXT_TAB = "#b38600"
COLOUR_NORMAL_TAB = "#000000"
COLOUR_NOTES_PLAYLIST = "#b8daff"
COLOUR_PREVIOUS_HEADER = "#f8d7da"
COLOUR_ODD_PLAYLIST = "#f2f2f2"
COLOUR_QUERYLIST_SELECTED = "#d3ffd3"
COLOUR_UNREADABLE = "#dc3545"
COLOUR_WARNING_TIMER = "#ffc107"
DBFS_FADE = -12
DBFS_SILENCE = -50
DEFAULT_COLUMN_WIDTH = 200
DISPLAY_SQL = False
ERRORS_TO = ['kae@midnighthax.com']
FADE_STEPS = 20
FADE_TIME = 3000
LOG_LEVEL_STDERR = logging.DEBUG
DO_NOT_IMPORT = "Do not import"
ENGINE_OPTIONS = dict(pool_pre_ping=True)
# ENGINE_OPTIONS = dict(pool_pre_ping=True, echo=True)
EPOCH = dt.datetime(1970, 1, 1)
ERRORS_FROM = ["noreply@midnighthax.com"]
ERRORS_TO = ["kae@midnighthax.com"]
EXTERNAL_BROWSER_PATH = "/usr/bin/vivaldi"
FADE_CURVE_BACKGROUND = "lightyellow"
FADE_CURVE_FOREGROUND = "blue"
FADE_CURVE_MS_BEFORE_FADE = 5000
FADEOUT_DB = -10
FADEOUT_SECONDS = 5
FADEOUT_STEPS_PER_SECOND = 5
FILTER_DURATION_LONGER = "longer than"
FILTER_DURATION_MINUTES = "minutes"
FILTER_DURATION_SECONDS = "seconds"
FILTER_DURATION_SHORTER = "shorter than"
FILTER_PATH_CONTAINS = "contains"
FILTER_PATH_EXCLUDING = "excluding"
FILTER_PLAYED_COMPARATOR_ANYTIME = "Any time"
FILTER_PLAYED_COMPARATOR_BEFORE = "before"
FILTER_PLAYED_COMPARATOR_NEVER = "never"
FILTER_PLAYED_DAYS = "days"
FILTER_PLAYED_MONTHS = "months"
FILTER_PLAYED_WEEKS = "weeks"
FILTER_PLAYED_YEARS = "years"
FUZZYMATCH_MINIMUM_LIST = 60.0
FUZZYMATCH_MINIMUM_SELECT_ARTIST = 80.0
FUZZYMATCH_MINIMUM_SELECT_TITLE = 80.0
FUZZYMATCH_SHOW_SCORES = True
HEADER_ARTIST = "Artist"
HEADER_BITRATE = "bps"
HEADER_DURATION = "Length"
HEADER_END_TIME = "End"
HEADER_INTRO = "Intro"
HEADER_LAST_PLAYED = "Last played"
HEADER_NOTE = "Notes"
HEADER_START_GAP = "Gap"
HEADER_START_TIME = "Start"
HEADER_TITLE = "Title"
HIDE_AFTER_PLAYING_OFFSET = 5000
HIDE_PLAYED_MODE_SECTIONS = "SECTIONS"
HIDE_PLAYED_MODE_TRACKS = "TRACKS"
IMPORT_AS_NEW = "Import as new track"
INFO_TAB_TITLE_LENGTH = 15
INTRO_SECONDS_FORMAT = ".1f"
INTRO_SECONDS_WARNING_MS = 3000
LAST_PLAYED_TODAY_STRING = "Today"
LAST_PLAYED_TOOLTIP_DATE_FORMAT = "%a, %d %b %Y"
LOG_LEVEL_STDERR = logging.INFO
LOG_LEVEL_SYSLOG = logging.DEBUG
LOG_NAME = "musicmuster"
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
MAIL_PORT = int(os.environ.get('MAIL_PORT') or 25)
MAIL_SERVER = os.environ.get('MAIL_SERVER') or "woodlands.midnighthax.com"
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS') is not None
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD")
MAIL_PORT = int(os.environ.get("MAIL_PORT") or 25)
MAIL_SERVER = os.environ.get("MAIL_SERVER") or "woodlands.midnighthax.com"
MAIL_USERNAME = os.environ.get("MAIL_USERNAME")
MAIL_USE_TLS = os.environ.get("MAIL_USE_TLS") is not None
MAIN_WINDOW_TITLE = "MusicMuster"
MAX_IMPORT_MATCHES = 5
MAX_IMPORT_THREADS = 3
MAX_INFO_TABS = 5
MAX_MISSING_FILES_TO_REPORT = 10
MILLISECOND_SIGFIGS = 0
MYSQL_CONNECT = "mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster"
NORMALISE_ON_IMPORT = True
ROOT = "/home/kae/music"
TESTMODE = True
TIMER_MS = 500
VOLUME_VLC_DEFAULT = 81
MINIMUM_ROW_HEIGHT = 30
NO_QUERY_NAME = "Select query"
NO_TEMPLATE_NAME = "None"
NOTE_TIME_FORMAT = "%H:%M"
OBS_HOST = "localhost"
OBS_PASSWORD = "auster"
OBS_PORT = 4455
PLAY_NEXT_GUARD_MS = 10000
PLAY_SETTLE = 500000
PLAYLIST_ICON_CURRENT = ":/icons/green-circle.png"
PLAYLIST_ICON_NEXT = ":/icons/yellow-circle.png"
PLAYLIST_ICON_TEMPLATE = ":/icons/redstar.png"
PREVIEW_ADVANCE_MS = 5000
PREVIEW_BACK_MS = 5000
PREVIEW_END_BUFFER_MS = 1000
REPLACE_FILES_DEFAULT_SOURCE = "/home/kae/music/Singles/tmp"
RESIZE_ROW_CHUNK_SIZE = 40
RETURN_KEY_DEBOUNCE_MS = 1000
ROOT = os.environ.get("ROOT") or "/home/kae/music"
ROW_PADDING = 4
ROWS_FROM_ZERO = True
SCROLL_TOP_MARGIN = 3
SECTION_ENDINGS = ("-", "+-", "-+")
SECTION_HEADER = "[Section header]"
SECTION_STARTS = ("+", "+-", "-+")
SONGFACTS_ON_NEXT = False
START_GAP_WARNING_THRESHOLD = 300
SUBTOTAL_ON_ROW_ZERO = "[No subtotal on first row]"
TOD_TIME_FORMAT = "%H:%M:%S"
TRACK_TIME_FORMAT = "%H:%M:%S"
VLC_MAIN_PLAYER_NAME = "MusicMuster Main Player"
VLC_PREVIEW_PLAYER_NAME = "MusicMuster Preview Player"
VLC_VOLUME_DEFAULT = 100
VLC_VOLUME_DROP3db = 70
WARNING_MS_BEFORE_FADE = 5500
WARNING_MS_BEFORE_SILENCE = 5500
WEB_ZOOM_FACTOR = 1.2
WIKIPEDIA_ON_NEXT = False
config = Config
# These rely on earlier definitions
HIDE_PLAYED_MODE = HIDE_PLAYED_MODE_TRACKS
IMPORT_DESTINATION = os.path.join(ROOT, "Singles")
REPLACE_FILES_DEFAULT_DESTINATION = os.path.dirname(REPLACE_FILES_DEFAULT_SOURCE)

31
app/dbmanager.py Normal file
View File

@ -0,0 +1,31 @@
# Standard library imports
# PyQt imports
# Third party imports
from alchemical import Alchemical # type:ignore
# App imports
class DatabaseManager:
"""
Singleton class to ensure we only ever have one db object
"""
__instance = None
def __init__(self, database_url: str, **kwargs: dict) -> None:
if DatabaseManager.__instance is None:
self.db = Alchemical(database_url, **kwargs)
# Database managed by Alembic so no create_all() required
# self.db.create_all()
DatabaseManager.__instance = self
else:
raise Exception("Attempted to create a second DatabaseManager instance")
@staticmethod
def get_instance(database_url: str, **kwargs: dict) -> Alchemical:
if DatabaseManager.__instance is None:
DatabaseManager(database_url, **kwargs)
return DatabaseManager.__instance

226
app/dbtables.py Normal file
View File

@ -0,0 +1,226 @@
# Standard library imports
from typing import Optional
from dataclasses import asdict
import datetime as dt
import json
# PyQt imports
# Third party imports
from alchemical import Model # type: ignore
from sqlalchemy import (
Boolean,
DateTime,
ForeignKey,
String,
)
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.engine.interfaces import Dialect
from sqlalchemy.orm import (
Mapped,
mapped_column,
relationship,
)
from sqlalchemy.types import TypeDecorator, TEXT
# App imports
from classes import Filter
class JSONEncodedDict(TypeDecorator):
"""
Custom JSON Type for MariaDB (since native JSON type is just LONGTEXT)
"""
impl = TEXT
def process_bind_param(self, value: dict | None, dialect: Dialect) -> str | None:
"""Convert Python dictionary to JSON string before saving."""
if value is None:
return None
return json.dumps(value, default=lambda o: o.__dict__)
def process_result_value(self, value: str | None, dialect: Dialect) -> dict | None:
"""Convert JSON string back to Python dictionary after retrieval."""
if value is None:
return None
return json.loads(value)
# Database classes
class NoteColoursTable(Model):
__tablename__ = "notecolours"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
substring: Mapped[str] = mapped_column(String(256), index=True, unique=True)
colour: Mapped[str] = mapped_column(String(21), index=False)
enabled: Mapped[bool] = mapped_column(default=True, index=True)
foreground: Mapped[Optional[str]] = mapped_column(String(21), index=False)
is_regex: Mapped[bool] = mapped_column(default=False, index=False)
is_casesensitive: Mapped[bool] = mapped_column(default=False, index=False)
order: Mapped[Optional[int]] = mapped_column(index=True)
strip_substring: Mapped[bool] = mapped_column(default=True, index=False)
def __repr__(self) -> str:
return (
f"<NoteColours(id={self.id}, substring={self.substring}, "
f"colour={self.colour}>"
)
class PlaydatesTable(Model):
__tablename__ = "playdates"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
lastplayed: Mapped[dt.datetime] = mapped_column(index=True)
track_id: Mapped[int] = mapped_column(ForeignKey("tracks.id", ondelete="CASCADE"))
track: Mapped["TracksTable"] = relationship(
"TracksTable",
back_populates="playdates",
)
def __repr__(self) -> str:
return (
f"<Playdates(id={self.id}, track_id={self.track_id} "
f"lastplayed={self.lastplayed}>"
)
class PlaylistsTable(Model):
"""
Manage playlists
"""
__tablename__ = "playlists"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(32), unique=True)
last_used: Mapped[Optional[dt.datetime]] = mapped_column(DateTime, default=None)
tab: Mapped[Optional[int]] = mapped_column(default=None)
open: Mapped[bool] = mapped_column(default=False)
is_template: Mapped[bool] = mapped_column(default=False)
rows: Mapped[list["PlaylistRowsTable"]] = relationship(
"PlaylistRowsTable",
back_populates="playlist",
cascade="all, delete-orphan",
order_by="PlaylistRowsTable.row_number",
)
favourite: Mapped[bool] = mapped_column(
Boolean, nullable=False, index=False, default=False
)
def __repr__(self) -> str:
return (
f"<Playlists(id={self.id}, name={self.name}, "
f"is_templatee={self.is_template}, open={self.open}>"
)
class PlaylistRowsTable(Model):
__tablename__ = "playlist_rows"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
row_number: Mapped[int] = mapped_column(index=True)
note: Mapped[str] = mapped_column(
String(2048), index=False, default="", nullable=False
)
playlist_id: Mapped[int] = mapped_column(
ForeignKey("playlists.id", ondelete="CASCADE"), index=True
)
playlist: Mapped[PlaylistsTable] = relationship(back_populates="rows")
track_id: Mapped[Optional[int]] = mapped_column(
ForeignKey("tracks.id", ondelete="CASCADE")
)
track: Mapped["TracksTable"] = relationship(
"TracksTable",
back_populates="playlistrows",
)
played: Mapped[bool] = mapped_column(
Boolean, nullable=False, index=False, default=False
)
def __repr__(self) -> str:
return (
f"<PlaylistRows(id={self.id}, playlist_id={self.playlist_id}, "
f"track_id={self.track_id}, "
f"note={self.note}, row_number={self.row_number}>"
)
class QueriesTable(Model):
__tablename__ = "queries"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(128), nullable=False)
_filter_data: Mapped[dict | None] = mapped_column("filter_data", JSONEncodedDict, nullable=False)
favourite: Mapped[bool] = mapped_column(Boolean, nullable=False, index=False, default=False)
def _get_filter(self) -> Filter:
"""Convert stored JSON dictionary to a Filter object."""
if isinstance(self._filter_data, dict):
return Filter(**self._filter_data)
return Filter() # Default object if None or invalid data
def _set_filter(self, value: Filter | None) -> None:
"""Convert a Filter object to JSON before storing."""
self._filter_data = asdict(value) if isinstance(value, Filter) else None
# Single definition of `filter`
filter = property(_get_filter, _set_filter)
def __repr__(self) -> str:
return f"<QueriesTable(id={self.id}, name={self.name}, filter={self.filter})>"
class SettingsTable(Model):
"""Manage settings"""
__tablename__ = "settings"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(64), unique=True)
f_datetime: Mapped[Optional[dt.datetime]] = mapped_column(default=None)
f_int: Mapped[Optional[int]] = mapped_column(default=None)
f_string: Mapped[Optional[str]] = mapped_column(String(128), default=None)
def __repr__(self) -> str:
return (
f"<Settings(id={self.id}, name={self.name}, "
f"f_datetime={self.f_datetime}, f_int={self.f_int}, f_string={self.f_string}>"
)
class TracksTable(Model):
__tablename__ = "tracks"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
artist: Mapped[str] = mapped_column(String(256), index=True)
bitrate: Mapped[int] = mapped_column(default=None)
duration: Mapped[int] = mapped_column(index=True)
fade_at: Mapped[int] = mapped_column(index=False)
intro: Mapped[Optional[int]] = mapped_column(default=None)
path: Mapped[str] = mapped_column(String(2048), index=False, unique=True)
silence_at: Mapped[int] = mapped_column(index=False)
start_gap: Mapped[int] = mapped_column(index=False)
title: Mapped[str] = mapped_column(String(256), index=True)
playlistrows: Mapped[list[PlaylistRowsTable]] = relationship(
"PlaylistRowsTable",
back_populates="track",
cascade="all, delete-orphan",
)
playlists = association_proxy("playlistrows", "playlist")
playdates: Mapped[list[PlaydatesTable]] = relationship(
"PlaydatesTable",
back_populates="track",
cascade="all, delete-orphan",
lazy="joined",
)
def __repr__(self) -> str:
return (
f"<Track(id={self.id}, title={self.title}, "
f"artist={self.artist}, path={self.path}>"
)

231
app/dialogs.py Normal file
View File

@ -0,0 +1,231 @@
# Standard library imports
from typing import Optional
# PyQt imports
from PyQt6.QtCore import QEvent, Qt
from PyQt6.QtGui import QKeyEvent
from PyQt6.QtWidgets import (
QDialog,
QListWidgetItem,
QMainWindow,
)
# Third party imports
from sqlalchemy.orm.session import Session
# App imports
from classes import MusicMusterSignals
from helpers import (
ask_yes_no,
get_relative_date,
ms_to_mmss,
)
from log import log
from models import Settings, Tracks
from playlistmodel import PlaylistModel
from ui import dlg_TrackSelect_ui
class TrackSelectDialog(QDialog):
"""Select track from database"""
def __init__(
self,
parent: QMainWindow,
session: Session,
new_row_number: int,
base_model: PlaylistModel,
add_to_header: Optional[bool] = False,
*args: Qt.WindowType,
**kwargs: Qt.WindowType,
) -> None:
"""
Subclassed QDialog to manage track selection
"""
super().__init__(parent, *args, **kwargs)
self.session = session
self.new_row_number = new_row_number
self.base_model = base_model
self.add_to_header = add_to_header
self.ui = dlg_TrackSelect_ui.Ui_Dialog()
self.ui.setupUi(self)
self.ui.btnAdd.clicked.connect(self.add_selected)
self.ui.btnAddClose.clicked.connect(self.add_selected_and_close)
self.ui.btnClose.clicked.connect(self.close)
self.ui.matchList.itemDoubleClicked.connect(self.add_selected)
self.ui.matchList.itemSelectionChanged.connect(self.selection_changed)
self.ui.radioTitle.toggled.connect(self.title_artist_toggle)
self.ui.searchString.textEdited.connect(self.chars_typed)
self.track: Optional[Tracks] = None
self.signals = MusicMusterSignals()
record = Settings.get_setting(self.session, "dbdialog_width")
width = record.f_int or 800
record = Settings.get_setting(self.session, "dbdialog_height")
height = record.f_int or 600
self.resize(width, height)
if add_to_header:
self.ui.lblNote.setVisible(False)
self.ui.txtNote.setVisible(False)
def add_selected(self) -> None:
"""Handle Add button"""
track = None
if self.ui.matchList.selectedItems():
item = self.ui.matchList.currentItem()
if item:
track = item.data(Qt.ItemDataRole.UserRole)
note = self.ui.txtNote.text()
if not (track or note):
return
track_id = None
if track:
track_id = track.id
if note and not track_id:
self.base_model.insert_row(self.new_row_number, track_id, note)
self.ui.txtNote.clear()
self.new_row_number += 1
return
self.ui.txtNote.clear()
self.select_searchtext()
if track_id is None:
log.error("track_id is None and should not be")
return
# Check whether track is already in playlist
move_existing = False
existing_prd = self.base_model.is_track_in_playlist(track_id)
if existing_prd is not None:
if ask_yes_no(
"Duplicate row",
"Track already in playlist. " "Move to new location?",
default_yes=True,
):
move_existing = True
if self.add_to_header:
if move_existing and existing_prd: # "and existing_prd" for mypy's benefit
self.base_model.move_track_to_header(
self.new_row_number, existing_prd, note
)
else:
self.base_model.add_track_to_header(self.new_row_number, track_id)
# Close dialog - we can only add one track to a header
self.accept()
else:
# Adding a new track row
if move_existing and existing_prd: # "and existing_prd" for mypy's benefit
self.base_model.move_track_add_note(
self.new_row_number, existing_prd, note
)
else:
self.base_model.insert_row(self.new_row_number, track_id, note)
self.new_row_number += 1
def add_selected_and_close(self) -> None:
"""Handle Add and Close button"""
self.add_selected()
self.accept()
def chars_typed(self, s: str) -> None:
"""Handle text typed in search box"""
self.ui.matchList.clear()
if len(s) > 0:
if s.startswith("a/") and len(s) > 2:
matches = Tracks.search_artists(self.session, "%" + s[2:])
elif self.ui.radioTitle.isChecked():
matches = Tracks.search_titles(self.session, "%" + s)
else:
matches = Tracks.search_artists(self.session, "%" + s)
if matches:
for track in matches:
last_played = None
last_playdate = max(
track.playdates, key=lambda p: p.lastplayed, default=None
)
if last_playdate:
last_played = last_playdate.lastplayed
t = QListWidgetItem()
track_text = (
f"{track.title} - {track.artist} "
f"[{ms_to_mmss(track.duration)}] "
f"({get_relative_date(last_played)})"
)
t.setText(track_text)
t.setData(Qt.ItemDataRole.UserRole, track)
self.ui.matchList.addItem(t)
def closeEvent(self, event: Optional[QEvent]) -> None:
"""
Override close and save dialog coordinates
"""
if not event:
return
record = Settings.get_setting(self.session, "dbdialog_height")
record.f_int = self.height()
record = Settings.get_setting(self.session, "dbdialog_width")
record.f_int = self.width()
self.session.commit()
event.accept()
def keyPressEvent(self, event: QKeyEvent | None) -> None:
"""
Clear selection on ESC if there is one
"""
if event and event.key() == Qt.Key.Key_Escape:
if self.ui.matchList.selectedItems():
self.ui.matchList.clearSelection()
return
super(TrackSelectDialog, self).keyPressEvent(event)
def select_searchtext(self) -> None:
"""Select the searchbox"""
self.ui.searchString.selectAll()
self.ui.searchString.setFocus()
def selection_changed(self) -> None:
"""Display selected track path in dialog box"""
if not self.ui.matchList.selectedItems():
return
item = self.ui.matchList.currentItem()
track = item.data(Qt.ItemDataRole.UserRole)
last_playdate = max(track.playdates, key=lambda p: p.lastplayed, default=None)
if last_playdate:
last_played = last_playdate.lastplayed
else:
last_played = None
path_text = f"{track.path} ({get_relative_date(last_played)})"
self.ui.dbPath.setText(path_text)
def title_artist_toggle(self) -> None:
"""
Handle switching between searching for artists and searching for
titles
"""
# Logic is handled already in chars_typed(), so just call that.
self.chars_typed(self.ui.searchString.text())

777
app/file_importer.py Normal file
View File

@ -0,0 +1,777 @@
from __future__ import annotations
from dataclasses import dataclass, field
from fuzzywuzzy import fuzz # type: ignore
import os.path
import threading
from typing import Optional, Sequence
import os
import shutil
# PyQt imports
from PyQt6.QtCore import (
pyqtSignal,
QThread,
)
from PyQt6.QtWidgets import (
QButtonGroup,
QDialog,
QFileDialog,
QHBoxLayout,
QLabel,
QPushButton,
QRadioButton,
QVBoxLayout,
)
# Third party imports
# App imports
from classes import (
ApplicationError,
MusicMusterSignals,
singleton,
Tags,
)
from config import Config
from helpers import (
audio_file_extension,
file_is_unreadable,
get_tags,
show_OK,
)
from log import log
from models import db, Tracks
from music_manager import track_sequence
from playlistmodel import PlaylistModel
import helpers
@dataclass
class ThreadData:
"""
Data structure to hold details of the import thread context
"""
base_model: PlaylistModel
row_number: int
@dataclass
class TrackFileData:
"""
Data structure to hold details of file to be imported
"""
source_path: str
tags: Tags = Tags()
destination_path: str = ""
import_this_file: bool = False
error: str = ""
file_path_to_remove: Optional[str] = None
track_id: int = 0
track_match_data: list[TrackMatchData] = field(default_factory=list)
@dataclass
class TrackMatchData:
"""
Data structure to hold details of existing files that are similar to
the file being imported.
"""
artist: str
artist_match: float
title: str
title_match: float
track_id: int
@singleton
class FileImporter:
"""
Class to manage the import of new tracks. Sanity checks are carried
out before processing each track.
They may replace existing tracks, be imported as new tracks, or the
import may be skipped altogether. The user decides which of these in
the UI managed by the PickMatch class.
The actual import is handled by the DoTrackImport class.
"""
# Place to keep a reference to importer workers. This is an instance
# variable to allow tests access. As this is a singleton, a class
# variable or an instance variable are effectively the same thing.
workers: dict[str, DoTrackImport] = {}
def __init__(self, base_model: PlaylistModel, row_number: int) -> None:
"""
Initialise the FileImporter singleton instance.
"""
log.debug(f"FileImporter.__init__({base_model=}, {row_number=})")
# Create ModelData
self.model_data = ThreadData(base_model=base_model, row_number=row_number)
# Data structure to track files to import
self.import_files_data: list[TrackFileData] = []
# Get signals
self.signals = MusicMusterSignals()
def _get_existing_tracks(self) -> Sequence[Tracks]:
"""
Return a list of all existing Tracks
"""
with db.Session() as session:
return Tracks.get_all(session)
def start(self) -> None:
"""
Build a TrackFileData object for each new file to import, add it
to self.import_files_data, and trigger importing.
"""
new_files: list[str] = []
if not os.listdir(Config.REPLACE_FILES_DEFAULT_SOURCE):
show_OK(
"File import",
f"No files in {Config.REPLACE_FILES_DEFAULT_SOURCE} to import",
None,
)
return
# Refresh list of existing tracks as they may have been updated
# by previous imports
self.existing_tracks = self._get_existing_tracks()
for infile in [
os.path.join(Config.REPLACE_FILES_DEFAULT_SOURCE, f)
for f in os.listdir(Config.REPLACE_FILES_DEFAULT_SOURCE)
if f.endswith((".mp3", ".flac"))
]:
if infile in [a.source_path for a in self.import_files_data]:
log.debug(f"file_importer.start skipping {infile=}, already queued")
else:
new_files.append(infile)
self.import_files_data.append(self.populate_trackfiledata(infile))
# Tell user which files won't be imported and why
self.inform_user(
[
a
for a in self.import_files_data
if a.source_path in new_files and a.import_this_file is False
]
)
# Remove do-not-import entries from queue
self.import_files_data[:] = [
a for a in self.import_files_data if a.import_this_file is not False
]
# Start the import if necessary
log.debug(
f"Import files prepared: {[a.source_path for a in self.import_files_data]}"
)
self._import_next_file()
def populate_trackfiledata(self, path: str) -> TrackFileData:
"""
Populate TrackFileData object for path:
- Validate file to be imported
- Find matches and similar files
- Get user choices for each import file
- Validate self.import_files_data integrity
- Tell the user which files won't be imported and why
- Import the files, one by one.
"""
tfd = TrackFileData(source_path=path)
if self.check_file_readable(tfd):
if self.check_file_tags(tfd):
self.find_similar(tfd)
if len(tfd.track_match_data) > 1:
self.sort_track_match_data(tfd)
selection = self.get_user_choices(tfd)
if self.process_selection(tfd, selection):
if self.extension_check(tfd):
if self.validate_file_data(tfd):
tfd.import_this_file = True
return tfd
def check_file_readable(self, tfd: TrackFileData) -> bool:
"""
Check file is readable.
Return True if it is.
Populate error and return False if not.
"""
if file_is_unreadable(tfd.source_path):
tfd.import_this_file = False
tfd.error = f"{tfd.source_path} is unreadable"
return False
return True
def check_file_tags(self, tfd: TrackFileData) -> bool:
"""
Add tags to tfd
Return True if successful.
Populate error and return False if not.
"""
try:
tfd.tags = get_tags(tfd.source_path)
except ApplicationError as e:
tfd.import_this_file = False
tfd.error = f"of tag errors ({str(e)})"
return False
return True
def extension_check(self, tfd: TrackFileData) -> bool:
"""
If we are replacing an existing file, check that the correct file
extension of the replacement file matches the existing file
extension and return True if it does (or if there is no exsting
file), else False.
"""
if not tfd.file_path_to_remove:
return True
if tfd.file_path_to_remove.endswith(audio_file_extension(tfd.source_path)):
return True
tfd.error = (
f"Existing file ({tfd.file_path_to_remove}) has a different "
f"extension to replacement file ({tfd.source_path})"
)
return False
def find_similar(self, tfd: TrackFileData) -> None:
"""
- Search title in existing tracks
- if score >= Config.FUZZYMATCH_MINIMUM_LIST:
- get artist score
- add TrackMatchData to self.import_files_data[path].track_match_data
"""
title = tfd.tags.title
artist = tfd.tags.artist
for existing_track in self.existing_tracks:
title_score = self._get_match_score(title, existing_track.title)
if title_score >= Config.FUZZYMATCH_MINIMUM_LIST:
artist_score = self._get_match_score(artist, existing_track.artist)
tfd.track_match_data.append(
TrackMatchData(
artist=existing_track.artist,
artist_match=artist_score,
title=existing_track.title,
title_match=title_score,
track_id=existing_track.id,
)
)
def sort_track_match_data(self, tfd: TrackFileData) -> None:
"""
Sort matched tracks in artist-similarity order
"""
tfd.track_match_data.sort(key=lambda x: x.artist_match, reverse=True)
def _get_match_score(self, str1: str, str2: str) -> float:
"""
Return the score of how well str1 matches str2.
"""
ratio = fuzz.ratio(str1, str2)
partial_ratio = fuzz.partial_ratio(str1, str2)
token_sort_ratio = fuzz.token_sort_ratio(str1, str2)
token_set_ratio = fuzz.token_set_ratio(str1, str2)
# Combine scores
combined_score = (
ratio * 0.25
+ partial_ratio * 0.25
+ token_sort_ratio * 0.25
+ token_set_ratio * 0.25
)
return combined_score
def get_user_choices(self, tfd: TrackFileData) -> int:
"""
Find out whether user wants to import this as a new track,
overwrite an existing track or not import it at all.
Return -1 (user cancelled) 0 (import as new) >0 (replace track id)
"""
# Build a list of (track title and artist, track_id, track path)
choices: list[tuple[str, int, str]] = []
# First choices are always a) don't import 2) import as a new track
choices.append((Config.DO_NOT_IMPORT, -1, ""))
choices.append((Config.IMPORT_AS_NEW, 0, ""))
# New track details
new_track_description = f"{tfd.tags.title} ({tfd.tags.artist})"
# Select 'import as new' as default unless the top match is good
# enough
default = 1
track_match_data = tfd.track_match_data
if track_match_data:
if (
track_match_data[0].artist_match
>= Config.FUZZYMATCH_MINIMUM_SELECT_ARTIST
and track_match_data[0].title_match
>= Config.FUZZYMATCH_MINIMUM_SELECT_TITLE
):
default = 2
for xt in track_match_data:
xt_description = f"{xt.title} ({xt.artist})"
if Config.FUZZYMATCH_SHOW_SCORES:
xt_description += f" ({xt.title_match:.0f}%)"
existing_track_path = self._get_existing_track(xt.track_id).path
choices.append(
(
xt_description,
xt.track_id,
existing_track_path,
)
)
dialog = PickMatch(
new_track_description=new_track_description,
choices=choices,
default=default,
)
if dialog.exec():
return dialog.selected_track_id
else:
return -1
def process_selection(self, tfd: TrackFileData, selection: int) -> bool:
"""
Process selection from PickMatch
"""
if selection < 0:
# User cancelled
tfd.import_this_file = False
tfd.error = "you asked not to import this file"
return False
elif selection > 0:
# Import and replace track
self.replace_file(tfd, track_id=selection)
else:
# Import as new
self.import_as_new(tfd)
return True
def replace_file(self, tfd: TrackFileData, track_id: int) -> None:
"""
Set up to replace an existing file.
"""
log.debug(f"replace_file({tfd=}, {track_id=})")
if track_id < 1:
raise ApplicationError(f"No track ID: replace_file({tfd=}, {track_id=})")
tfd.track_id = track_id
existing_track_path = self._get_existing_track(track_id).path
tfd.file_path_to_remove = existing_track_path
# If the existing file in the Config.IMPORT_DESTINATION
# directory, replace it with the imported file name; otherwise,
# use the existing file name. This so that we don't change file
# names from CDs, etc.
if os.path.dirname(existing_track_path) == Config.IMPORT_DESTINATION:
tfd.destination_path = os.path.join(
Config.IMPORT_DESTINATION, os.path.basename(tfd.source_path)
)
else:
tfd.destination_path = existing_track_path
def _get_existing_track(self, track_id: int) -> Tracks:
"""
Lookup in existing track in the local cache and return it
"""
existing_track_records = [a for a in self.existing_tracks if a.id == track_id]
if len(existing_track_records) != 1:
raise ApplicationError(
f"Internal error in _get_existing_track: {existing_track_records=}"
)
return existing_track_records[0]
def import_as_new(self, tfd: TrackFileData) -> None:
"""
Set up to import as a new file.
"""
tfd.destination_path = os.path.join(
Config.IMPORT_DESTINATION, os.path.basename(tfd.source_path)
)
def validate_file_data(self, tfd: TrackFileData) -> bool:
"""
Check the data structures for integrity
Return True if all OK
Populate error and return False if not.
"""
# Check tags
if not (tfd.tags.artist and tfd.tags.title):
raise ApplicationError(
f"validate_file_data: {tfd.tags=}, {tfd.source_path=}"
)
# Check file_path_to_remove
if tfd.file_path_to_remove and not os.path.exists(tfd.file_path_to_remove):
# File to remove is missing, but this isn't a major error. We
# may be importing to replace a deleted file.
tfd.file_path_to_remove = ""
# Check destination_path
if not tfd.destination_path:
raise ApplicationError(
f"validate_file_data: no destination path set ({tfd.source_path=})"
)
# If destination path is the same as file_path_to_remove, that's
# OK, otherwise if this is a new import then check that
# destination path doesn't already exists
if tfd.track_id == 0 and tfd.destination_path != tfd.file_path_to_remove:
while os.path.exists(tfd.destination_path):
msg = (
"New import requested but default destination path"
f" ({tfd.destination_path})"
" already exists. Click OK and choose where to save this track"
)
show_OK(title="Desintation path exists", msg=msg, parent=None)
# Get output filename
pathspec = QFileDialog.getSaveFileName(
None,
"Save imported track",
directory=Config.IMPORT_DESTINATION,
)
if pathspec:
if pathspec == "":
# User cancelled
tfd.error = "You did not select a location to save this track"
return False
tfd.destination_path = pathspec[0]
else:
tfd.error = "destination file already exists"
return False
# The desintation path should not already exist in the
# database (becquse if it does, it points to a non-existent
# file). Check that because the path field in the database is
# unique and so adding a duplicate will give a db integrity
# error.
with db.Session() as session:
if Tracks.get_by_path(session, tfd.destination_path):
tfd.error = (
"Importing a new track but destination path already exists "
f"in database ({tfd.destination_path})"
)
return False
# Check track_id
if tfd.track_id < 0:
raise ApplicationError(
f"validate_file_data: track_id < 0, {tfd.source_path=}"
)
return True
def inform_user(self, tfds: list[TrackFileData]) -> None:
"""
Tell user about files that won't be imported
"""
msgs: list[str] = []
for tfd in tfds:
msgs.append(
f"{os.path.basename(tfd.source_path)} will not be imported because {tfd.error}"
)
if msgs:
show_OK("File not imported", "\r\r".join(msgs))
log.debug("\r\r".join(msgs))
def _import_next_file(self) -> None:
"""
Import the next file sequentially.
This is called when an import completes so will be called asynchronously.
Protect with a lock.
"""
lock = threading.Lock()
with lock:
while len(self.workers) < Config.MAX_IMPORT_THREADS:
try:
tfd = self.import_files_data.pop()
filename = os.path.basename(tfd.source_path)
log.debug(f"Processing {filename}")
log.debug(
f"remaining files: {[a.source_path for a in self.import_files_data]}"
)
self.signals.status_message_signal.emit(
f"Importing {filename}", 10000
)
self._start_import(tfd)
except IndexError:
log.debug("import_next_file: no files remaining in queue")
break
def _start_import(self, tfd: TrackFileData) -> None:
"""
Start thread to import track
"""
filename = os.path.basename(tfd.source_path)
log.debug(f"_start_import({filename=})")
self.workers[tfd.source_path] = DoTrackImport(
import_file_path=tfd.source_path,
tags=tfd.tags,
destination_path=tfd.destination_path,
track_id=tfd.track_id,
file_path_to_remove=tfd.file_path_to_remove,
)
log.debug(f"{self.workers[tfd.source_path]=} created")
self.workers[tfd.source_path].import_finished.connect(
self.post_import_processing
)
self.workers[tfd.source_path].finished.connect(lambda: self.cleanup_thread(tfd))
self.workers[tfd.source_path].finished.connect(
self.workers[tfd.source_path].deleteLater
)
self.workers[tfd.source_path].start()
def cleanup_thread(self, tfd: TrackFileData) -> None:
"""
Remove references to finished threads/workers to prevent leaks.
"""
log.debug(f"cleanup_thread({tfd.source_path=})")
if tfd.source_path in self.workers:
del self.workers[tfd.source_path]
else:
log.error(f"Couldn't find {tfd.source_path=} in {self.workers.keys()=}")
log.debug(f"After cleanup_thread: {self.workers.keys()=}")
def post_import_processing(self, source_path: str, track_id: int) -> None:
"""
If track already in playlist, refresh it else insert it
"""
log.debug(f"post_import_processing({source_path=}, {track_id=})")
if self.model_data:
if self.model_data.base_model:
self.model_data.base_model.update_or_insert(
track_id, self.model_data.row_number
)
# Process next file(s)
self._import_next_file()
class DoTrackImport(QThread):
"""
Class to manage the actual import of tracks in a thread.
"""
import_finished = pyqtSignal(str, int)
def __init__(
self,
import_file_path: str,
tags: Tags,
destination_path: str,
track_id: int,
file_path_to_remove: Optional[str] = None,
) -> None:
"""
Save parameters
"""
super().__init__()
self.import_file_path = import_file_path
self.tags = tags
self.destination_track_path = destination_path
self.track_id = track_id
self.file_path_to_remove = file_path_to_remove
self.signals = MusicMusterSignals()
def __repr__(self) -> str:
return f"<DoTrackImport(id={hex(id(self))}, import_file_path={self.import_file_path}"
def run(self) -> None:
"""
Either create track objects from passed files or update exising track
objects.
And add to visible playlist or update playlist if track already present.
"""
self.signals.status_message_signal.emit(
f"Importing {os.path.basename(self.import_file_path)}", 5000
)
# Get audio metadata in this thread rather than calling
# function to save interactive time
self.audio_metadata = helpers.get_audio_metadata(self.import_file_path)
# Remove old file if so requested
if self.file_path_to_remove and os.path.exists(self.file_path_to_remove):
os.unlink(self.file_path_to_remove)
# Move new file to destination
shutil.move(self.import_file_path, self.destination_track_path)
with db.Session() as session:
if self.track_id == 0:
# Import new track
try:
track = Tracks(
session,
path=self.destination_track_path,
**self.tags._asdict(),
**self.audio_metadata._asdict(),
)
except Exception as e:
self.signals.show_warning_signal.emit(
"Error importing track", str(e)
)
return
else:
track = session.get(Tracks, self.track_id)
if track:
for key, value in self.tags._asdict().items():
if hasattr(track, key):
setattr(track, key, value)
for key, value in self.audio_metadata._asdict().items():
if hasattr(track, key):
setattr(track, key, value)
track.path = self.destination_track_path
else:
log.error(f"Unable to retrieve {self.track_id=}")
return
session.commit()
helpers.normalise_track(self.destination_track_path)
self.signals.status_message_signal.emit(
f"{os.path.basename(self.import_file_path)} imported", 10000
)
self.import_finished.emit(self.import_file_path, track.id)
class PickMatch(QDialog):
"""
Dialog for user to select which existing track to replace or to
import to a new track
"""
def __init__(
self,
new_track_description: str,
choices: list[tuple[str, int, str]],
default: int,
) -> None:
super().__init__()
self.new_track_description = new_track_description
self.default = default
self.init_ui(choices)
self.selected_track_id = -1
def init_ui(self, choices: list[tuple[str, int, str]]) -> None:
"""
Set up dialog
"""
self.setWindowTitle("New or replace")
layout = QVBoxLayout()
# Add instructions
instructions = (
f"Importing {self.new_track_description}.\n"
"Import as a new track or replace existing track?"
)
instructions_label = QLabel(instructions)
layout.addWidget(instructions_label)
# Create a button group for radio buttons
self.button_group = QButtonGroup()
# Add radio buttons for each item
for idx, (track_description, track_id, track_path) in enumerate(choices):
if (
track_sequence.current
and track_id
and track_sequence.current.track_id == track_id
):
# Don't allow current track to be replaced
track_description = "(Currently playing) " + track_description
radio_button = QRadioButton(track_description)
radio_button.setDisabled(True)
self.button_group.addButton(radio_button, -1)
else:
radio_button = QRadioButton(track_description)
radio_button.setToolTip(track_path)
self.button_group.addButton(radio_button, track_id)
layout.addWidget(radio_button)
# Select the second item by default (import as new)
if idx == self.default:
radio_button.setChecked(True)
# Add OK and Cancel buttons
button_layout = QHBoxLayout()
ok_button = QPushButton("OK")
cancel_button = QPushButton("Cancel")
button_layout.addWidget(ok_button)
button_layout.addWidget(cancel_button)
layout.addLayout(button_layout)
self.setLayout(layout)
# Connect buttons to actions
ok_button.clicked.connect(self.on_ok)
cancel_button.clicked.connect(self.reject)
def on_ok(self):
# Get the ID of the selected button
self.selected_track_id = self.button_group.checkedId()
self.accept()

View File

@ -1,6 +1,298 @@
def ms_to_mmss(ms, decimals=0, negative=False):
# Standard library imports
import datetime as dt
from email.message import EmailMessage
from typing import Optional
import os
import re
import shutil
import smtplib
import ssl
import tempfile
# PyQt imports
from PyQt6.QtWidgets import QInputDialog, QMainWindow, QMessageBox, QWidget
# Third party imports
import filetype
from mutagen.flac import FLAC # type: ignore
from mutagen.mp3 import MP3 # type: ignore
from pydub import AudioSegment, effects
from pydub.utils import mediainfo
from tinytag import TinyTag, TinyTagException # type: ignore
# App imports
from classes import AudioMetadata, ApplicationError, Tags
from config import Config
from log import log
from models import Tracks
start_time_re = re.compile(r"@\d\d:\d\d")
def ask_yes_no(
title: str,
question: str,
default_yes: bool = False,
parent: Optional[QMainWindow] = None,
) -> bool:
"""Ask question; return True for yes, False for no"""
dlg = QMessageBox(parent)
dlg.setWindowTitle(title)
dlg.setText(question)
dlg.setStandardButtons(
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No
)
dlg.setIcon(QMessageBox.Icon.Question)
if default_yes:
dlg.setDefaultButton(QMessageBox.StandardButton.Yes)
button = dlg.exec()
return button == QMessageBox.StandardButton.Yes
def audio_file_extension(fpath: str) -> str | None:
"""
Return the correct extension for this type of file.
"""
return filetype.guess(fpath).extension
def fade_point(
audio_segment: AudioSegment,
fade_threshold: float = 0.0,
chunk_size: int = Config.AUDIO_SEGMENT_CHUNK_SIZE,
) -> int:
"""
Returns the millisecond/index of the point where the volume drops below
the maximum and doesn't get louder again.
audio_segment - the sdlg_search_database_uiegment to find silence in
fade_threshold - the upper bound for how quiet is silent in dFBS
chunk_size - chunk size for interating over the segment in ms
"""
assert chunk_size > 0 # to avoid infinite loop
segment_length: int = audio_segment.duration_seconds * 1000 # ms
trim_ms = segment_length - chunk_size
max_vol = audio_segment.dBFS
if fade_threshold == 0:
fade_threshold = max_vol
while (
audio_segment[trim_ms: trim_ms + chunk_size].dBFS < fade_threshold
and trim_ms > 0
): # noqa W503
trim_ms -= chunk_size
# if there is no trailing silence, return lenght of track (it's less
# the chunk_size, but for chunk_size = 10ms, this may be ignored)
return int(trim_ms)
def file_is_unreadable(path: Optional[str]) -> bool:
"""
Returns True if passed path is readable, else False
"""
if not path:
return True
return not os.access(path, os.R_OK)
def get_audio_segment(path: str) -> Optional[AudioSegment]:
if not path.endswith(audio_file_extension(path)):
return None
try:
if path.endswith(".mp3"):
return AudioSegment.from_mp3(path)
elif path.endswith(".flac"):
return AudioSegment.from_file(path, "flac") # type: ignore
except AttributeError:
return None
return None
def get_embedded_time(text: str) -> Optional[dt.datetime]:
"""Return datetime specified as @hh:mm in text"""
try:
match = start_time_re.search(text)
except TypeError:
return None
if not match:
return None
try:
return dt.datetime.strptime(match.group(0)[1:], Config.NOTE_TIME_FORMAT)
except ValueError:
return None
def get_all_track_metadata(filepath: str) -> dict[str, str | int | float]:
"""Return all track metadata"""
return (
get_audio_metadata(filepath)._asdict()
| get_tags(filepath)._asdict()
| dict(path=filepath)
)
def get_audio_metadata(filepath: str) -> AudioMetadata:
"""Return audio metadata"""
# Set start_gap, fade_at and silence_at
audio = get_audio_segment(filepath)
if not audio:
return AudioMetadata()
else:
return AudioMetadata(
start_gap=leading_silence(audio),
fade_at=int(
round(fade_point(audio) / 1000, Config.MILLISECOND_SIGFIGS) * 1000
),
silence_at=int(
round(trailing_silence(audio) / 1000, Config.MILLISECOND_SIGFIGS) * 1000
),
)
def get_name(prompt: str, default: str = "") -> str | None:
"""Get a name from the user"""
dlg = QInputDialog()
dlg.setInputMode(QInputDialog.InputMode.TextInput)
dlg.setLabelText(prompt)
while True:
if default:
dlg.setTextValue(default)
dlg.resize(500, 100)
ok = dlg.exec()
if ok:
return dlg.textValue()
return None
def get_relative_date(
past_date: Optional[dt.datetime], reference_date: Optional[dt.datetime] = None
) -> str:
"""
Return how long before reference_date past_date is as string.
Params:
@past_date: datetime
@reference_date: datetime, defaults to current date and time
@return: string
"""
if not past_date or past_date == Config.EPOCH:
return "Never"
if not reference_date:
reference_date = dt.datetime.now()
# Check parameters
if past_date > reference_date:
return "get_relative_date() past_date is after relative_date"
days: int
days_str: str
weeks: int
weeks_str: str
weeks, days = divmod((reference_date.date() - past_date.date()).days, 7)
if weeks == days == 0:
# Same day so return time instead
return Config.LAST_PLAYED_TODAY_STRING + " " + past_date.strftime("%H:%M")
if weeks == 1:
weeks_str = "week"
else:
weeks_str = "weeks"
if days == 1:
days_str = "day"
else:
days_str = "days"
return f"{weeks} {weeks_str}, {days} {days_str}"
def get_tags(path: str) -> Tags:
"""
Return a dictionary of title, artist, bitrate and duration-in-milliseconds.
"""
try:
tag = TinyTag.get(path)
except FileNotFoundError:
raise ApplicationError(f"File not found: {path}")
except TinyTagException:
raise ApplicationError(f"Can't read tags in {path}")
if (
tag.title is None
or tag.artist is None
or tag.bitrate is None
or tag.duration is None
):
raise ApplicationError(f"Missing tags in {path}")
return Tags(
title=tag.title,
artist=tag.artist,
bitrate=round(tag.bitrate),
duration=int(round(tag.duration, Config.MILLISECOND_SIGFIGS) * 1000),
)
def leading_silence(
audio_segment: AudioSegment,
silence_threshold: int = Config.DBFS_SILENCE,
chunk_size: int = Config.AUDIO_SEGMENT_CHUNK_SIZE,
) -> int:
"""
Returns the millisecond/index that the leading silence ends.
audio_segment - the segment to find silence in
silence_threshold - the upper bound for how quiet is silent in dFBS
chunk_size - chunk size for interating over the segment in ms
https://github.com/jiaaro/pydub/blob/master/pydub/silence.py
"""
trim_ms: int = 0 # ms
assert chunk_size > 0 # to avoid infinite loop
while audio_segment[
trim_ms : trim_ms + chunk_size
].dBFS < silence_threshold and trim_ms < len( # noqa W504
audio_segment
):
trim_ms += chunk_size
# if there is no end it should return the length of the segment
return min(trim_ms, len(audio_segment))
def ms_to_mmss(
ms: Optional[int],
decimals: int = 0,
negative: bool = False,
none: Optional[str] = None,
) -> str:
"""Convert milliseconds to mm:ss"""
minutes: int
remainder: int
seconds: float
if not ms:
return "-"
if none:
return none
else:
return "-"
sign = ""
if ms < 0:
if negative:
@ -17,3 +309,149 @@ def ms_to_mmss(ms, decimals=0, negative=False):
seconds = 59.0
return f"{sign}{minutes:.0f}:{seconds:02.{decimals}f}"
def normalise_track(path: str) -> None:
"""Normalise track"""
# Check type
ftype = os.path.splitext(path)[1][1:]
if ftype not in ["mp3", "flac"]:
log.error(
f"helpers.normalise_track({path}): " f"File type {ftype} not implemented"
)
bitrate = mediainfo(path)["bit_rate"]
audio = get_audio_segment(path)
if not audio:
return
# Get current file gid, uid and permissions
stats = os.stat(path)
try:
# Copy original file
_, temp_path = tempfile.mkstemp()
shutil.copyfile(path, temp_path)
except Exception as err:
log.debug(f"helpers.normalise_track({path}): err1: {repr(err)}")
return
# Overwrite original file with normalised output
normalised = effects.normalize(audio)
try:
normalised.export(path, format=os.path.splitext(path)[1][1:], bitrate=bitrate)
# Fix up permssions and ownership
os.chown(path, stats.st_uid, stats.st_gid)
os.chmod(path, stats.st_mode)
# Copy tags
tag_handler: type[FLAC | MP3]
if ftype == "flac":
tag_handler = FLAC
elif ftype == "mp3":
tag_handler = MP3
else:
return
src = tag_handler(temp_path)
dst = tag_handler(path)
for tag in src:
dst[tag] = src[tag]
dst.save()
except Exception as err:
log.debug(f"helpers.normalise_track({path}): err2: {repr(err)}")
# Restore original file
shutil.copyfile(path, temp_path)
finally:
if os.path.exists(temp_path):
os.remove(temp_path)
def remove_substring_case_insensitive(parent_string: str, substring: str) -> str:
"""
Remove all instances of substring from parent string, case insensitively
"""
# Convert both strings to lowercase for case-insensitive comparison
lower_parent = parent_string.lower()
lower_substring = substring.lower()
# Initialize the result string
result = parent_string
# Continue removing the substring until it's no longer found
while lower_substring in lower_parent:
# Find the index of the substring
index = lower_parent.find(lower_substring)
# Remove the substring
result = result[:index] + result[index + len(substring) :]
# Update the lowercase versions
lower_parent = result.lower()
return result
def send_mail(to_addr: str, from_addr: str, subj: str, body: str) -> None:
# From https://docs.python.org/3/library/email.examples.html
# Create a text/plain message
msg = EmailMessage()
msg.set_content(body)
msg["Subject"] = subj
msg["From"] = from_addr
msg["To"] = to_addr
# Send the message via SMTP server.
context = ssl.create_default_context()
try:
s = smtplib.SMTP(host=Config.MAIL_SERVER, port=Config.MAIL_PORT)
if Config.MAIL_USE_TLS:
s.starttls(context=context)
if Config.MAIL_USERNAME and Config.MAIL_PASSWORD:
s.login(Config.MAIL_USERNAME, Config.MAIL_PASSWORD)
s.send_message(msg)
except Exception as e:
print(e)
finally:
s.quit()
def set_track_metadata(track: Tracks) -> None:
"""Set/update track metadata in database"""
audio_metadata = get_audio_metadata(track.path)
tags = get_tags(track.path)
for audio_key in AudioMetadata._fields:
setattr(track, audio_key, getattr(audio_metadata, audio_key))
for tag_key in Tags._fields:
setattr(track, tag_key, getattr(tags, tag_key))
def show_OK(title: str, msg: str, parent: Optional[QWidget] = None) -> None:
"""Display a message to user"""
dlg = QMessageBox(parent)
dlg.setIcon(QMessageBox.Icon.Information)
dlg.setWindowTitle(title)
dlg.setText(msg)
dlg.setStandardButtons(QMessageBox.StandardButton.Ok)
_ = dlg.exec()
def show_warning(parent: Optional[QMainWindow], title: str, msg: str) -> None:
"""Display a warning to user"""
QMessageBox.warning(parent, title, msg, buttons=QMessageBox.StandardButton.Cancel)
def trailing_silence(
audio_segment: AudioSegment,
silence_threshold: int = -50,
chunk_size: int = Config.AUDIO_SEGMENT_CHUNK_SIZE,
) -> int:
"""Return fade point from start in milliseconds"""
return fade_point(audio_segment, silence_threshold, chunk_size)

View File

@ -1 +0,0 @@
ui/icons_rc.py

56
app/jittermonitor.py Normal file
View File

@ -0,0 +1,56 @@
from PyQt6.QtCore import QObject, QTimer, QElapsedTimer
import logging
import time
from config import Config
class EventLoopJitterMonitor(QObject):
def __init__(
self,
parent=None,
interval_ms: int = 20,
jitter_threshold_ms: int = 100,
log_cooldown_s: float = 1.0,
):
super().__init__(parent)
self._interval = interval_ms
self._jitter_threshold = jitter_threshold_ms
self._log_cooldown_s = log_cooldown_s
self._timer = QTimer(self)
self._timer.setInterval(self._interval)
self._timer.timeout.connect(self._on_timeout)
self._elapsed = QElapsedTimer()
self._elapsed.start()
self._last = self._elapsed.elapsed()
# child logger: e.g. "musicmuster.jitter"
self._log = logging.getLogger(f"{Config.LOG_NAME}.jitter")
self._last_log_time = 0.0
def start(self) -> None:
self._timer.start()
def _on_timeout(self) -> None:
now_ms = self._elapsed.elapsed()
delta = now_ms - self._last
self._last = now_ms
if delta > (self._interval + self._jitter_threshold):
self._log_jitter(now_ms, delta)
def _log_jitter(self, now_ms: int, gap_ms: int) -> None:
now = time.monotonic()
# simple rate limit: only one log every log_cooldown_s
if now - self._last_log_time < self._log_cooldown_s:
return
self._last_log_time = now
self._log.warning(
"Event loop gap detected: t=%d ms, gap=%d ms (interval=%d ms)",
now_ms,
gap_ms,
self._interval,
)

View File

@ -1,96 +1,138 @@
#!/usr/bin/python3
#!/usr/bin/env python3
# Standard library imports
from collections import defaultdict
from functools import wraps
import logging
import logging.config
import logging.handlers
import os
import sys
import traceback
import yaml
# PyQt imports
from PyQt6.QtWidgets import QApplication, QMessageBox
# Third party imports
import stackprinter # type: ignore
# App imports
from config import Config
from classes import ApplicationError
class FunctionFilter(logging.Filter):
"""Filter to allow category-based logging to stderr."""
def __init__(self, module_functions: dict[str, list[str]]):
super().__init__()
self.modules: list[str] = []
self.functions: defaultdict[str, list[str]] = defaultdict(list)
if module_functions:
for module in module_functions.keys():
if module_functions[module]:
for function in module_functions[module]:
self.functions[module].append(function)
else:
self.modules.append(module)
def filter(self, record: logging.LogRecord) -> bool:
if not getattr(record, "levelname", None) == "DEBUG":
# Only prcess DEBUG messages
return False
module = getattr(record, "module", None)
if not module:
# No module in record
return False
# Process if this is a module we're tracking
if module in self.modules:
return True
# Process if this is a function we're tracking
if getattr(record, "funcName", None) in self.functions[module]:
return True
return False
class LevelTagFilter(logging.Filter):
"Add leveltag"
"""Add leveltag"""
def filter(self, record):
def filter(self, record: logging.LogRecord) -> bool:
# Extract the first character of the level name
record.leveltag = record.levelname[0]
# We never actually filter messages out, just abuse filtering to add an
# extra field to the LogRecord
# We never actually filter messages out, just add an extra field
# to the LogRecord
return True
# Load YAML logging configuration
with open("app/logging.yaml", "r") as f:
config = yaml.safe_load(f)
logging.config.dictConfig(config)
# Get logger
log = logging.getLogger(Config.LOG_NAME)
log.setLevel(logging.DEBUG)
# stderr
stderr = logging.StreamHandler()
stderr.setLevel(Config.LOG_LEVEL_STDERR)
# syslog
syslog = logging.handlers.SysLogHandler(address='/dev/log')
syslog.setLevel(Config.LOG_LEVEL_SYSLOG)
# Filter
filter = LevelTagFilter()
syslog.addFilter(filter)
stderr.addFilter(filter)
# create formatter and add it to the handlers
stderr_fmt = logging.Formatter('[%(asctime)s] %(leveltag)s: %(message)s',
datefmt='%H:%M:%S')
syslog_fmt = logging.Formatter('[%(name)s] %(leveltag)s: %(message)s')
stderr.setFormatter(stderr_fmt)
syslog.setFormatter(syslog_fmt)
# add the handlers to the log
log.addHandler(stderr)
log.addHandler(syslog)
def log_uncaught_exceptions(ex_cls, ex, tb):
def handle_exception(exc_type, exc_value, exc_traceback):
error = str(exc_value)
if issubclass(exc_type, ApplicationError):
log.error(error)
else:
# Handle unexpected errors (log and display)
error_msg = "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
print("\033[1;31;47m")
logging.critical(''.join(traceback.format_tb(tb)))
print("\033[1;37;40m")
logging.critical('{0}: {1}'.format(ex_cls, ex))
print(stackprinter.format(exc_value, suppressed_paths=['/.venv'], style='darkbg'))
msg = stackprinter.format(exc_value)
log.error(msg)
log.error(error_msg)
print("Critical error:", error_msg) # Consider logging instead of print
if os.environ["MM_ENV"] == "PRODUCTION":
from helpers import send_mail
send_mail(
Config.ERRORS_TO,
Config.ERRORS_FROM,
"Exception (log_uncaught_exceptions) from musicmuster",
msg,
)
if QApplication.instance() is not None:
fname = os.path.split(exc_traceback.tb_frame.f_code.co_filename)[1]
msg = f"ApplicationError: {error}\nat {fname}:{exc_traceback.tb_lineno}"
QMessageBox.critical(None, "Application Error", msg)
sys.excepthook = log_uncaught_exceptions
def truncate_large(obj, limit=5):
"""Helper to truncate large lists or other iterables."""
if isinstance(obj, (list, tuple, set)):
if len(obj) > limit:
return f"{type(obj).__name__}(len={len(obj)}, items={list(obj)[:limit]}...)"
return repr(obj)
def DEBUG(msg):
log.debug(msg)
def log_call(func):
@wraps(func)
def wrapper(*args, **kwargs):
args_repr = [truncate_large(a) for a in args]
kwargs_repr = [f"{k}={truncate_large(v)}" for k, v in kwargs.items()]
params_repr = ", ".join(args_repr + kwargs_repr)
log.debug(f"call {func.__name__}({params_repr})")
try:
result = func(*args, **kwargs)
log.debug(f"return {func.__name__}: {truncate_large(result)}")
return result
except Exception as e:
log.debug(f"exception in {func.__name__}: {e}")
raise
return wrapper
def EXCEPTION(msg):
log.exception(msg, exc_info=True, stack_info=True)
def ERROR(msg):
log.error(msg)
def INFO(msg):
log.info(msg)
if __name__ == "__main__":
DEBUG("hi debug")
ERROR("hi error")
INFO("hi info")
EXCEPTION("hi exception")
def f():
return g()
def g():
return h()
def h():
return i()
def i():
1 / 0
f()
sys.excepthook = handle_exception

55
app/logging.yaml Normal file
View File

@ -0,0 +1,55 @@
version: 1
disable_existing_loggers: True
formatters:
colored:
(): colorlog.ColoredFormatter
format: "%(log_color)s[%(asctime)s] %(filename)s.%(funcName)s:%(lineno)s %(blue)s%(message)s"
datefmt: "%H:%M:%S"
syslog:
format: "[%(name)s] %(filename)s:%(lineno)s %(leveltag)s: %(message)s"
filters:
leveltag:
(): log.LevelTagFilter
category_filter:
(): log.FunctionFilter
module_functions:
# Optionally additionally log some debug calls to stderr
# log all debug calls in a module:
# module-name: []
# log debug calls for some functions in a module:
# module-name:
# - function-name-1
# - function-name-2
musicmuster:
- play_next
jittermonitor: []
handlers:
stderr:
class: colorlog.StreamHandler
level: INFO
formatter: colored
filters: [leveltag]
stream: ext://sys.stderr
syslog:
class: logging.handlers.SysLogHandler
level: DEBUG
formatter: syslog
filters: [leveltag]
address: "/dev/log"
debug_stderr:
class: colorlog.StreamHandler
level: DEBUG
formatter: colored
filters: [leveltag, category_filter]
stream: ext://sys.stderr
loggers:
musicmuster:
level: DEBUG
handlers: [stderr, syslog, debug_stderr]
propagate: false

29
app/logging_tester.py Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env python3
from log import log
# Testing
def fa():
log.debug("fa Debug message")
log.info("fa Info message")
log.warning("fa Warning message")
log.error("fa Error message")
log.critical("fa Critical message")
print()
def fb():
log.debug("fb Debug message")
log.info("fb Info message")
log.warning("fb Warning message")
log.error("fb Error message")
log.critical("fb Critical message")
print()
def testing():
fa()
fb()
testing()

104
app/menu.yaml Normal file
View File

@ -0,0 +1,104 @@
menus:
- title: "&File"
actions:
- text: "Save as Template"
handler: "save_as_template"
- text: "Manage Templates"
handler: "manage_templates_wrapper"
- separator: true
- text: "Manage Queries"
handler: "manage_queries_wrapper"
- separator: true
- text: "Exit"
handler: "close"
- title: "&Playlist"
actions:
- text: "Open Playlist"
handler: "open_existing_playlist"
shortcut: "Ctrl+O"
- text: "New Playlist"
handler: "new_playlist_dynamic_submenu"
submenu: true
- text: "Close Playlist"
handler: "close_playlist_tab"
- text: "Rename Playlist"
handler: "rename_playlist"
- text: "Delete Playlist"
handler: "delete_playlist"
- separator: true
- text: "Insert Track"
handler: "insert_track"
shortcut: "Ctrl+T"
- text: "Select Track from Query"
handler: "query_dynamic_submenu"
submenu: true
- text: "Insert Section Header"
handler: "insert_header"
shortcut: "Ctrl+H"
- text: "Import Files"
handler: "import_files_wrapper"
shortcut: "Ctrl+Shift+I"
- separator: true
- text: "Mark for Moving"
handler: "mark_rows_for_moving"
shortcut: "Ctrl+C"
- text: "Paste"
handler: "paste_rows"
shortcut: "Ctrl+V"
- separator: true
- text: "Export Playlist"
handler: "export_playlist_tab"
- text: "Download CSV of Played Tracks"
handler: "download_played_tracks"
- separator: true
- text: "Select Duplicate Rows"
handler: "select_duplicate_rows"
- text: "Move Selected"
handler: "move_selected"
- text: "Move Unplayed"
handler: "move_unplayed"
- separator: true
- text: "Clear Selection"
handler: "clear_selection"
shortcut: "Esc"
store_reference: true # So we can enable/disable later
- title: "&Music"
actions:
- text: "Set Next"
handler: "set_selected_track_next"
shortcut: "Ctrl+N"
- text: "Play Next"
handler: "play_next"
shortcut: "Return"
- text: "Fade"
handler: "fade"
shortcut: "Ctrl+Z"
- text: "Stop"
handler: "stop"
shortcut: "Ctrl+Alt+S"
- text: "Resume"
handler: "resume"
shortcut: "Ctrl+R"
- text: "Skip to Next"
handler: "play_next"
shortcut: "Ctrl+Alt+Return"
- separator: true
- text: "Search"
handler: "search_playlist"
shortcut: "/"
- text: "Search Title in Wikipedia"
handler: "lookup_row_in_wikipedia"
shortcut: "Ctrl+W"
- text: "Search Title in Songfacts"
handler: "lookup_row_in_songfacts"
shortcut: "Ctrl+S"
- title: "Help"
actions:
- text: "About"
handler: "about"
- text: "Debug"
handler: "debug"

View File

@ -1,469 +0,0 @@
#!/usr/bin/python3
import sqlalchemy
from datetime import datetime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import (
Boolean,
Column,
DateTime,
Float,
ForeignKey,
Integer,
String,
func
)
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound
from sqlalchemy.orm import relationship, sessionmaker
from config import Config
from log import DEBUG, ERROR
# Create session at the global level as per
# https://docs.sqlalchemy.org/en/13/orm/session_basics.html
# Set up database connection
engine = sqlalchemy.create_engine(f"{Config.MYSQL_CONNECT}?charset=utf8",
encoding='utf-8',
echo=Config.DISPLAY_SQL,
pool_pre_ping=True)
Base = declarative_base()
Base.metadata.create_all(engine)
# Create a Session factory
Session = sessionmaker(bind=engine)
# Database classes
class Notes(Base):
__tablename__ = 'notes'
id = Column(Integer, primary_key=True, autoincrement=True)
playlist_id = Column(Integer, ForeignKey('playlists.id'))
playlist = relationship("Playlists", back_populates="notes")
row = Column(Integer, nullable=False)
note = Column(String(256), index=False)
def __repr__(self):
return (
f"<Note(id={self.id}, row={self.row}, note={self.note}>"
)
@staticmethod
def add_note(session, playlist_id, row, text):
DEBUG(f"add_note(playlist_id={playlist_id}, row={row}, text={text})")
note = Notes()
note.playlist_id = playlist_id
note.row = row
note.note = text
session.add(note)
session.commit()
return note
@staticmethod
def delete_note(session, id):
DEBUG(f"delete_note(id={id}")
session.query(Notes).filter(Notes.id == id).delete()
session.commit()
# Not currently used 1 June 2021
# @staticmethod
# def get_note(session, id):
# return session.query(Notes).filter(Notes.id == id).one()
@classmethod
def update_note(cls, session, id, row, text=None):
"""
Update note details. If text=None, don't change text.
"""
DEBUG(f"update_note(id={id}, row={row}, text={text})")
note = session.query(cls).filter(cls.id == id).one()
note.row = row
if text:
note.note = text
session.commit()
class Playdates(Base):
__tablename__ = 'playdates'
id = Column(Integer, primary_key=True, autoincrement=True)
lastplayed = Column(DateTime, index=True, default=None)
track_id = Column(Integer, ForeignKey('tracks.id'))
tracks = relationship("Tracks", back_populates="playdates")
@staticmethod
def add_playdate(session, track):
DEBUG(f"add_playdate(track={track})")
pd = Playdates()
pd.lastplayed = datetime.now()
pd.track_id = track.id
session.add(pd)
track.update_lastplayed()
session.commit()
class Playlists(Base):
"""
Usage:
pl = session.query(Playlists).filter(Playlists.id == 1).one()
pl
<Playlist(id=1, name=Default>
pl.tracks
[<__main__.PlaylistTracks at 0x7fcd20181c18>,
<__main__.PlaylistTracks at 0x7fcd20181c88>,
<__main__.PlaylistTracks at 0x7fcd20181be0>,
<__main__.PlaylistTracks at 0x7fcd20181c50>]
[a.tracks for a in pl.tracks]
[<Track(id=3992, title=Yesterday Man, artist=Various, path=/h[...]
<Track(id=2238, title=These Boots Are Made For Walkin', arti[...]
<Track(id=3837, title=Babe, artist=Various, path=/home/kae/m[...]
<Track(id=2332, title=Such Great Heights - Remastered, artis[...]]
glue = PlaylistTracks(row=5)
tr = session.query(Tracks).filter(Tracks.id == 676).one()
tr
<Track(id=676, title=Seven Nation Army, artist=White Stripes,
path=/home/kae/music/White Stripes/Elephant/01. Seven Nation Army.flac>
glue.track_id = tr.id
pl.tracks.append(glue)
session.commit()
[a.tracks for a in pl.tracks]
[<Track(id=3992, title=Yesterday Man, artist=Various, path=/h[...]
<Track(id=2238, title=These Boots Are Made For Walkin', arti[...]
<Track(id=3837, title=Babe, artist=Various, path=/home/kae/m[...]
<Track(id=2332, title=Such Great Heights - Remastered, artis[...]
<Track(id=676, title=Seven Nation Army, artist=White Stripes[...]]
"""
__tablename__ = "playlists"
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(32), nullable=False, unique=True)
last_used = Column(DateTime, default=None, nullable=True)
loaded = Column(Boolean, default=True)
notes = relationship("Notes",
order_by="Notes.row",
back_populates="playlist")
tracks = relationship("PlaylistTracks",
order_by="PlaylistTracks.row",
back_populates="playlists")
def __repr__(self):
return (f"<Playlist(id={self.id}, name={self.name}>")
def add_track(self, session, track, row=None):
"""
Add track to playlist at given row.
If row=None, add to end of playlist
"""
if not row:
row = PlaylistTracks.new_row(session, self.id)
glue = PlaylistTracks(row=row)
glue.track_id = track.id
self.tracks.append(glue)
session.commit()
def close(self, session):
"Record playlist as no longer loaded"
self.loaded = False
session.add(self)
session.commit()
@staticmethod
def get_all_closed_playlists(session):
"Returns a list of all playlists not currently open"
return (
session.query(Playlists)
.filter(
(Playlists.loaded == False) | # noqa E712
(Playlists.loaded == None)
)
.order_by(Playlists.last_used.desc())
).all()
@staticmethod
def get_all_playlists(session):
"Returns a list of all playlists"
return session.query(Playlists).all()
@staticmethod
def get_last_used(session):
"""
Return a list of playlists marked "loaded", ordered by loaded date.
"""
return (
session.query(Playlists)
.filter(Playlists.loaded == True) # noqa E712
.order_by(Playlists.last_used.desc())
).all()
def get_notes(self):
return [a.note for a in self.notes]
@staticmethod
def get_playlist(session, playlist_id):
return (
session.query(Playlists)
.filter(
Playlists.id == playlist_id # noqa E712
)
).one()
def get_tracks(self):
return [a.tracks for a in self.tracks]
@staticmethod
def new(session, name):
DEBUG(f"Playlists.new(name={name})")
playlist = Playlists()
playlist.name = name
session.add(playlist)
session.commit()
return playlist
@staticmethod
def open(session, plid):
"Record playlist as loaded and used now"
p = session.query(Playlists).filter(Playlists.id == plid).one()
p.loaded = True
p.last_used = datetime.now()
session.commit()
return p
class PlaylistTracks(Base):
__tablename__ = 'playlisttracks'
id = Column(Integer, primary_key=True, autoincrement=True)
playlist_id = Column(Integer, ForeignKey('playlists.id'), primary_key=True)
track_id = Column(Integer, ForeignKey('tracks.id'), primary_key=True)
row = Column(Integer, nullable=False)
tracks = relationship("Tracks", back_populates="playlists")
playlists = relationship("Playlists", back_populates="tracks")
@staticmethod
def add_track(session, playlist_id, track_id, row):
DEBUG(
f"PlaylistTracks.add_track(playlist_id={playlist_id}, "
f"track_id={track_id}, row={row})"
)
plt = PlaylistTracks()
plt.playlist_id = playlist_id,
plt.track_id = track_id,
plt.row = row
session.add(plt)
session.commit()
@staticmethod
def move_track(session, from_playlist_id, row, to_playlist_id):
DEBUG(
"PlaylistTracks.move_tracks(from_playlist_id="
f"{from_playlist_id}, row={row}, "
f"to_playlist_id={to_playlist_id})"
)
new_row = (
session.query(func.max(PlaylistTracks.row)).filter(
PlaylistTracks.playlist_id == to_playlist_id).scalar()
) + 1
record = session.query(PlaylistTracks).filter(
PlaylistTracks.playlist_id == from_playlist_id,
PlaylistTracks.row == row
).one()
record.playlist_id = to_playlist_id
record.row = new_row
session.commit()
@staticmethod
def new_row(session, playlist_id):
"Return row number > largest existing row number"
last_row = session.query(func.max(PlaylistTracks.row)).one()[0]
return last_row + 1
@staticmethod
def remove_all_tracks(session, playlist_id):
"""
Remove all tracks from passed playlist_id
"""
session.query(PlaylistTracks).filter(
PlaylistTracks.playlist_id == playlist_id,
).delete()
session.commit()
@staticmethod
def remove_track(session, playlist_id, row):
DEBUG(
f"PlaylistTracks.remove_track(playlist_id={playlist_id}, "
f"row={row})"
)
session.query(PlaylistTracks).filter(
PlaylistTracks.playlist_id == playlist_id,
PlaylistTracks.row == row
).delete()
session.commit()
@staticmethod
def update_row_track(session, playlist_id, row, track_id):
DEBUG(
f"PlaylistTracks.update_track_row(playlist_id={playlist_id}, "
f"row={row}, track_id={track_id})"
)
try:
plt = session.query(PlaylistTracks).filter(
PlaylistTracks.playlist_id == playlist_id,
PlaylistTracks.row == row
).one()
except MultipleResultsFound:
ERROR(
f"Multiple rows matched in query: "
f"PlaylistTracks.playlist_id == {playlist_id}, "
f"PlaylistTracks.row == {row}"
)
return
except NoResultFound:
ERROR(
f"No rows matched in query: "
f"PlaylistTracks.playlist_id == {playlist_id}, "
f"PlaylistTracks.row == {row}"
)
return
plt.track_id = track_id
session.commit()
class Settings(Base):
__tablename__ = 'settings'
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String(32), nullable=False, unique=True)
f_datetime = Column(DateTime, default=None, nullable=True)
f_int = Column(Integer, default=None, nullable=True)
f_string = Column(String(128), default=None, nullable=True)
@classmethod
def get_int(cls, session, name):
try:
int_setting = session.query(cls).filter(
cls.name == name).one()
except NoResultFound:
int_setting = Settings()
int_setting.name = name
int_setting.f_int = None
session.add(int_setting)
session.commit()
return int_setting
def update(self, session, data):
for key, value in data.items():
assert hasattr(self, key)
setattr(self, key, value)
session.commit()
class Tracks(Base):
__tablename__ = 'tracks'
id = Column(Integer, primary_key=True, autoincrement=True)
title = Column(String(256), index=True)
artist = Column(String(256), index=True)
duration = Column(Integer, index=True)
start_gap = Column(Integer, index=False)
fade_at = Column(Integer, index=False)
silence_at = Column(Integer, index=False)
path = Column(String(2048), index=False, nullable=False)
mtime = Column(Float, index=True)
lastplayed = Column(DateTime, index=True, default=None)
playlists = relationship("PlaylistTracks", back_populates="tracks")
playdates = relationship("Playdates", back_populates="tracks")
def __repr__(self):
return (
f"<Track(id={self.id}, title={self.title}, "
f"artist={self.artist}, path={self.path}>"
)
@classmethod
def get_or_create(cls, session, path):
DEBUG(f"Tracks.get_or_create(path={path})")
try:
track = session.query(cls).filter(cls.path == path).one()
except NoResultFound:
track = Tracks()
track.path = path
session.add(track)
return track
@staticmethod
def get_duration(session, id):
try:
return session.query(
Tracks.duration).filter(Tracks.id == id).one()[0]
except NoResultFound:
ERROR(f"Can't find track id {id}")
return None
@staticmethod
def get_all_paths(session):
"Return a list of paths of all tracks"
return [a[0] for a in session.query(Tracks.path).all()]
@staticmethod
def get_path(session, id):
try:
return session.query(Tracks.path).filter(Tracks.id == id).one()[0]
except NoResultFound:
ERROR(f"Can't find track id {id}")
return None
@staticmethod
def get_track(session, id):
try:
DEBUG(f"Tracks.get_track(track_id={id})")
track = session.query(Tracks).filter(Tracks.id == id).one()
return track
except NoResultFound:
ERROR(f"get_track({id}): not found")
return None
@staticmethod
def search_titles(session, text):
return (
session.query(Tracks)
.filter(Tracks.title.ilike(f"%{text}%"))
.order_by(Tracks.title)
).all()
@staticmethod
def track_from_id(session, id):
return session.query(Tracks).filter(
Tracks.id == id).one()
def update_lastplayed(self):
self.lastplayed = datetime.now()

873
app/models.py Normal file
View File

@ -0,0 +1,873 @@
# Standard library imports
from __future__ import annotations
from typing import Optional, Sequence
import datetime as dt
import os
import re
import sys
# PyQt imports
# Third party imports
from dogpile.cache import make_region
from dogpile.cache.api import NO_VALUE
from sqlalchemy import (
bindparam,
delete,
func,
select,
text,
update,
)
from sqlalchemy.exc import IntegrityError, ProgrammingError
from sqlalchemy.orm.exc import NoResultFound
from sqlalchemy.orm import joinedload, selectinload
from sqlalchemy.orm.session import Session
from sqlalchemy.engine.row import RowMapping
# App imports
from classes import ApplicationError, Filter
from config import Config
from dbmanager import DatabaseManager
import dbtables
from log import log
# Establish database connection
DATABASE_URL = os.environ.get("DATABASE_URL")
if DATABASE_URL is None:
raise ValueError("DATABASE_URL is undefined")
if "unittest" in sys.modules and "sqlite" not in DATABASE_URL:
raise ValueError("Unit tests running on non-Sqlite database")
db = DatabaseManager.get_instance(DATABASE_URL, engine_options=Config.ENGINE_OPTIONS).db
# Configure the cache region
cache_region = make_region().configure(
'dogpile.cache.memory', # Use in-memory caching for now (switch to Redis if needed)
expiration_time=600 # Cache expires after 10 minutes
)
def run_sql(session: Session, sql: str) -> Sequence[RowMapping]:
"""
Run a sql string and return results
"""
try:
return session.execute(text(sql)).mappings().all()
except ProgrammingError as e:
raise ApplicationError(e)
# Database classes
class NoteColours(dbtables.NoteColoursTable):
def __init__(
self,
session: Session,
substring: str,
colour: str,
enabled: bool = True,
is_regex: bool = False,
is_casesensitive: bool = False,
order: Optional[int] = 0,
) -> None:
self.substring = substring
self.colour = colour
self.enabled = enabled
self.is_regex = is_regex
self.is_casesensitive = is_casesensitive
self.order = order
session.add(self)
session.commit()
@classmethod
def get_all(cls, session: Session) -> Sequence["NoteColours"]:
"""
Return all records
"""
cache_key = "note_colours_all"
cached_result = cache_region.get(cache_key)
if cached_result is not NO_VALUE:
return cached_result
# Query the database
result = session.scalars(
select(cls)
.where(
cls.enabled.is_(True),
)
.order_by(cls.order)
).all()
cache_region.set(cache_key, result)
return result
@staticmethod
def get_colour(
session: Session, text: str, foreground: bool = False
) -> str:
"""
Parse text and return background (foreground if foreground==True) colour
string if matched, else None
"""
if not text:
return ""
match = False
for rec in NoteColours.get_all(session):
if rec.is_regex:
flags = re.UNICODE
if not rec.is_casesensitive:
flags |= re.IGNORECASE
p = re.compile(rec.substring, flags)
if p.match(text):
match = True
else:
if rec.is_casesensitive:
if rec.substring in text:
match = True
else:
if rec.substring.lower() in text.lower():
match = True
if match:
if foreground:
return rec.foreground or ""
else:
return rec.colour
return ""
@staticmethod
def invalidate_cache() -> None:
"""Invalidate dogpile cache"""
cache_region.delete("note_colours_all")
class Playdates(dbtables.PlaydatesTable):
def __init__(
self, session: Session, track_id: int, when: Optional[dt.datetime] = None
) -> None:
"""Record that track was played"""
if not when:
self.lastplayed = dt.datetime.now()
else:
self.lastplayed = when
self.track_id = track_id
session.add(self)
session.commit()
@staticmethod
def last_playdates(
session: Session, track_id: int, limit: int = 5
) -> Sequence["Playdates"]:
"""
Return a list of the last limit playdates for this track, sorted
latest to earliest.
"""
return session.scalars(
Playdates.select()
.where(Playdates.track_id == track_id)
.order_by(Playdates.lastplayed.desc())
.limit(limit)
).all()
@staticmethod
def last_played(session: Session, track_id: int) -> dt.datetime:
"""Return datetime track last played or None"""
last_played = session.execute(
select(Playdates.lastplayed)
.where(Playdates.track_id == track_id)
.order_by(Playdates.lastplayed.desc())
.limit(1)
).first()
if last_played:
return last_played[0]
else:
# Should never be reached as we create record with a
# last_played value
return Config.EPOCH # pragma: no cover
@staticmethod
def last_played_tracks(session: Session, limit: int = 5) -> Sequence["Playdates"]:
"""
Return a list of the last limit tracks played, sorted
earliest to latest.
"""
return session.scalars(
Playdates.select().order_by(Playdates.lastplayed.desc()).limit(limit)
).all()
@staticmethod
def played_after(session: Session, since: dt.datetime) -> Sequence["Playdates"]:
"""Return a list of Playdates objects since passed time"""
return session.scalars(
select(Playdates)
.where(Playdates.lastplayed >= since)
.order_by(Playdates.lastplayed)
).all()
class Playlists(dbtables.PlaylistsTable):
def __init__(self, session: Session, name: str, template_id: int) -> None:
"""Create playlist with passed name"""
self.name = name
self.last_used = dt.datetime.now()
session.add(self)
session.commit()
# If a template is specified, copy from it
if template_id:
PlaylistRows.copy_playlist(session, template_id, self.id)
@staticmethod
def clear_tabs(session: Session, playlist_ids: list[int]) -> None:
"""
Make all tab records NULL
"""
session.execute(
update(Playlists).where((Playlists.id.in_(playlist_ids))).values(tab=None)
)
def close(self, session: Session) -> None:
"""Mark playlist as unloaded"""
self.open = False
session.commit()
@classmethod
def get_all(cls, session: Session) -> Sequence["Playlists"]:
"""Returns a list of all playlists ordered by last use"""
return session.scalars(
select(cls)
.filter(cls.is_template.is_(False))
.order_by(cls.last_used.desc())
).all()
@classmethod
def get_all_templates(cls, session: Session) -> Sequence["Playlists"]:
"""Returns a list of all templates ordered by name"""
return session.scalars(
select(cls).where(cls.is_template.is_(True)).order_by(cls.name)
).all()
@classmethod
def get_favourite_templates(cls, session: Session) -> Sequence["Playlists"]:
"""Returns a list of favourite templates ordered by name"""
return session.scalars(
select(cls)
.where(cls.is_template.is_(True), cls.favourite.is_(True))
.order_by(cls.name)
).all()
@classmethod
def get_closed(cls, session: Session) -> Sequence["Playlists"]:
"""Returns a list of all closed playlists ordered by last use"""
return session.scalars(
select(cls)
.filter(
cls.open.is_(False),
cls.is_template.is_(False),
)
.order_by(cls.last_used.desc())
).all()
@classmethod
def get_open(cls, session: Session) -> Sequence[Optional["Playlists"]]:
"""
Return a list of loaded playlists ordered by tab.
"""
return session.scalars(
select(cls).where(cls.open.is_(True)).order_by(cls.tab)
).all()
def mark_open(self) -> None:
"""Mark playlist as loaded and used now"""
self.open = True
self.last_used = dt.datetime.now()
@staticmethod
def name_is_available(session: Session, name: str) -> bool:
"""
Return True if no playlist of this name exists else false.
"""
return (
session.execute(select(Playlists).where(Playlists.name == name)).first()
is None
)
def rename(self, session: Session, new_name: str) -> None:
"""
Rename playlist
"""
self.name = new_name
session.commit()
@staticmethod
def save_as_template(
session: Session, playlist_id: int, template_name: str
) -> None:
"""Save passed playlist as new template"""
template = Playlists(session, template_name, template_id=0)
if not template or not template.id:
return
template.is_template = True
session.commit()
PlaylistRows.copy_playlist(session, playlist_id, template.id)
class PlaylistRows(dbtables.PlaylistRowsTable):
def __init__(
self,
session: Session,
playlist_id: int,
row_number: int,
note: str = "",
track_id: Optional[int] = None,
) -> None:
"""Create PlaylistRows object"""
self.playlist_id = playlist_id
self.track_id = track_id
self.row_number = row_number
self.note = note
session.add(self)
session.commit()
def append_note(self, extra_note: str) -> None:
"""Append passed note to any existing note"""
current_note = self.note
if current_note:
self.note = current_note + "\n" + extra_note
else:
self.note = extra_note
@staticmethod
def copy_playlist(session: Session, src_id: int, dst_id: int) -> None:
"""Copy playlist entries"""
src_rows = session.scalars(
select(PlaylistRows).filter(PlaylistRows.playlist_id == src_id)
).all()
for plr in src_rows:
PlaylistRows(
session=session,
playlist_id=dst_id,
row_number=plr.row_number,
note=plr.note,
track_id=plr.track_id,
)
@classmethod
def deep_row(
cls, session: Session, playlist_id: int, row_number: int
) -> "PlaylistRows":
"""
Return a playlist row that includes full track and lastplayed data for
given playlist_id and row
"""
stmt = (
select(PlaylistRows)
.options(joinedload(cls.track))
.where(
PlaylistRows.playlist_id == playlist_id,
PlaylistRows.row_number == row_number,
)
# .options(joinedload(Tracks.playdates))
)
return session.execute(stmt).unique().scalar_one()
@staticmethod
def delete_higher_rows(session: Session, playlist_id: int, maxrow: int) -> None:
"""
Delete rows in given playlist that have a higher row number
than 'maxrow'
"""
session.execute(
delete(PlaylistRows).where(
PlaylistRows.playlist_id == playlist_id,
PlaylistRows.row_number > maxrow,
)
)
session.commit()
@staticmethod
def delete_row(session: Session, playlist_id: int, row_number: int) -> None:
"""
Delete passed row in given playlist.
"""
session.execute(
delete(PlaylistRows).where(
PlaylistRows.playlist_id == playlist_id,
PlaylistRows.row_number == row_number,
)
)
@staticmethod
def fixup_rownumbers(session: Session, playlist_id: int) -> None:
"""
Ensure the row numbers for passed playlist have no gaps
"""
plrs = session.scalars(
select(PlaylistRows)
.where(PlaylistRows.playlist_id == playlist_id)
.order_by(PlaylistRows.row_number)
).all()
for i, plr in enumerate(plrs):
plr.row_number = i
# Ensure new row numbers are available to the caller
session.commit()
@classmethod
def plrids_to_plrs(
cls, session: Session, playlist_id: int, plr_ids: list[int]
) -> Sequence["PlaylistRows"]:
"""
Take a list of PlaylistRows ids and return a list of corresponding
PlaylistRows objects
"""
plrs = session.scalars(
select(cls)
.where(cls.playlist_id == playlist_id, cls.id.in_(plr_ids))
.order_by(cls.row_number)
).all()
return plrs
@staticmethod
def get_last_used_row(session: Session, playlist_id: int) -> Optional[int]:
"""Return the last used row for playlist, or None if no rows"""
return session.execute(
select(func.max(PlaylistRows.row_number)).where(
PlaylistRows.playlist_id == playlist_id
)
).scalar_one()
@staticmethod
def get_track_plr(
session: Session, track_id: int, playlist_id: int
) -> Optional["PlaylistRows"]:
"""Return first matching PlaylistRows object or None"""
return session.scalars(
select(PlaylistRows)
.where(
PlaylistRows.track_id == track_id,
PlaylistRows.playlist_id == playlist_id,
)
.limit(1)
).first()
@classmethod
def get_played_rows(
cls, session: Session, playlist_id: int
) -> Sequence["PlaylistRows"]:
"""
For passed playlist, return a list of rows that
have been played.
"""
plrs = session.scalars(
select(cls)
.where(cls.playlist_id == playlist_id, cls.played.is_(True))
.order_by(cls.row_number)
).all()
return plrs
@classmethod
def get_playlist_rows(
cls, session: Session, playlist_id: int
) -> Sequence["PlaylistRows"]:
"""
For passed playlist, return a list of rows.
"""
stmt = (
select(cls)
.where(cls.playlist_id == playlist_id)
.options(selectinload(cls.track))
.order_by(cls.row_number)
)
plrs = session.execute(stmt).scalars().all()
return plrs
@classmethod
def get_rows_with_tracks(
cls,
session: Session,
playlist_id: int,
) -> Sequence["PlaylistRows"]:
"""
For passed playlist, return a list of rows that
contain tracks
"""
query = select(cls).where(
cls.playlist_id == playlist_id, cls.track_id.is_not(None)
)
plrs = session.scalars((query).order_by(cls.row_number)).all()
return plrs
@classmethod
def get_unplayed_rows(
cls, session: Session, playlist_id: int
) -> Sequence["PlaylistRows"]:
"""
For passed playlist, return a list of playlist rows that
have not been played.
"""
plrs = session.scalars(
select(cls)
.where(
cls.playlist_id == playlist_id,
cls.track_id.is_not(None),
cls.played.is_(False),
)
.order_by(cls.row_number)
).all()
return plrs
@classmethod
def insert_row(
cls,
session: Session,
playlist_id: int,
new_row_number: int,
note: str = "",
track_id: Optional[int] = None,
) -> "PlaylistRows":
cls.move_rows_down(session, playlist_id, new_row_number, 1)
return cls(
session,
playlist_id=playlist_id,
row_number=new_row_number,
note=note,
track_id=track_id,
)
@staticmethod
def move_rows_down(
session: Session, playlist_id: int, starting_row: int, move_by: int
) -> None:
"""
Create space to insert move_by additional rows by incremented row
number from starting_row to end of playlist
"""
log.debug(f"(move_rows_down({playlist_id=}, {starting_row=}, {move_by=}")
session.execute(
update(PlaylistRows)
.where(
(PlaylistRows.playlist_id == playlist_id),
(PlaylistRows.row_number >= starting_row),
)
.values(row_number=PlaylistRows.row_number + move_by)
)
@staticmethod
def update_plr_row_numbers(
session: Session,
playlist_id: int,
sqla_map: list[dict[str, int]],
) -> None:
"""
Take a {plrid: row_number} dictionary and update the row numbers accordingly
"""
# Update database. Ref:
# https://docs.sqlalchemy.org/en/20/tutorial/data_update.html#the-update-sql-expression-construct
stmt = (
update(PlaylistRows)
.where(
PlaylistRows.playlist_id == playlist_id,
PlaylistRows.id == bindparam("playlistrow_id"),
)
.values(row_number=bindparam("row_number"))
)
session.connection().execute(stmt, sqla_map)
class Queries(dbtables.QueriesTable):
def __init__(
self,
session: Session,
name: str,
filter: dbtables.Filter,
favourite: bool = False,
) -> None:
"""Create new query"""
self.name = name
self.filter = filter
self.favourite = favourite
session.add(self)
session.commit()
@classmethod
def get_all(cls, session: Session) -> Sequence["Queries"]:
"""Returns a list of all queries ordered by name"""
return session.scalars(select(cls).order_by(cls.name)).all()
@classmethod
def get_favourites(cls, session: Session) -> Sequence["Queries"]:
"""Returns a list of favourite queries ordered by name"""
return session.scalars(
select(cls).where(cls.favourite.is_(True)).order_by(cls.name)
).all()
class Settings(dbtables.SettingsTable):
def __init__(self, session: Session, name: str) -> None:
self.name = name
session.add(self)
session.commit()
@classmethod
def get_setting(cls, session: Session, name: str) -> "Settings":
"""Get existing setting or return new setting record"""
try:
return session.execute(select(cls).where(cls.name == name)).scalar_one()
except NoResultFound:
return Settings(session, name)
class Tracks(dbtables.TracksTable):
def __init__(
self,
session: Session,
path: str,
title: str,
artist: str,
duration: int,
start_gap: int,
fade_at: int,
silence_at: int,
bitrate: int,
) -> None:
self.path = path
self.title = title
self.artist = artist
self.bitrate = bitrate
self.duration = duration
self.start_gap = start_gap
self.fade_at = fade_at
self.silence_at = silence_at
try:
session.add(self)
session.commit()
except IntegrityError as error:
session.rollback()
log.error(f"Error ({error=}) importing track ({path=})")
raise ValueError(error)
@classmethod
def get_all(cls, session: Session) -> Sequence["Tracks"]:
"""Return a list of all tracks"""
return session.scalars(select(cls)).unique().all()
@classmethod
def all_tracks_indexed_by_id(cls, session: Session) -> dict[int, Tracks]:
"""
Return a dictionary of all tracks, keyed by title
"""
result: dict[int, Tracks] = {}
for track in cls.get_all(session):
result[track.id] = track
return result
@classmethod
def exact_title_and_artist(
cls, session: Session, title: str, artist: str
) -> Sequence["Tracks"]:
"""
Search for exact but case-insensitive match of title and artist
"""
return (
session.scalars(
select(cls)
.where(cls.title.ilike(title), cls.artist.ilike(artist))
.order_by(cls.title)
)
.unique()
.all()
)
@classmethod
def get_filtered_tracks(
cls, session: Session, filter: Filter
) -> Sequence["Tracks"]:
"""
Return tracks matching filter
"""
query = select(cls)
# Path specification
if filter.path:
if filter.path_type == "contains":
query = query.where(cls.path.ilike(f"%{filter.path}%"))
elif filter.path_type == "excluding":
query = query.where(cls.path.notilike(f"%{filter.path}%"))
else:
raise ApplicationError(f"Can't process filter path ({filter=})")
# Duration specification
seconds_duration = filter.duration_number
if filter.duration_unit == Config.FILTER_DURATION_MINUTES:
seconds_duration *= 60
elif filter.duration_unit != Config.FILTER_DURATION_SECONDS:
raise ApplicationError(f"Can't process filter duration ({filter=})")
if filter.duration_type == Config.FILTER_DURATION_LONGER:
query = query.where(cls.duration >= seconds_duration)
elif filter.duration_unit == Config.FILTER_DURATION_SHORTER:
query = query.where(cls.duration <= seconds_duration)
else:
raise ApplicationError(f"Can't process filter duration type ({filter=})")
# Process comparator
if filter.last_played_comparator == Config.FILTER_PLAYED_COMPARATOR_NEVER:
# Select tracks that have never been played
query = query.outerjoin(Playdates, cls.id == Playdates.track_id).where(
Playdates.id.is_(None)
)
else:
# Last played specification
now = dt.datetime.now()
# Set sensible default, and correct for Config.FILTER_PLAYED_COMPARATOR_ANYTIME
before = now
# If not ANYTIME, set 'before' appropriates
if filter.last_played_comparator != Config.FILTER_PLAYED_COMPARATOR_ANYTIME:
if filter.last_played_unit == Config.FILTER_PLAYED_DAYS:
before = now - dt.timedelta(days=filter.last_played_number)
elif filter.last_played_unit == Config.FILTER_PLAYED_WEEKS:
before = now - dt.timedelta(days=7 * filter.last_played_number)
elif filter.last_played_unit == Config.FILTER_PLAYED_MONTHS:
before = now - dt.timedelta(days=30 * filter.last_played_number)
elif filter.last_played_unit == Config.FILTER_PLAYED_YEARS:
before = now - dt.timedelta(days=365 * filter.last_played_number)
subquery = (
select(
Playdates.track_id,
func.max(Playdates.lastplayed).label("max_last_played"),
)
.group_by(Playdates.track_id)
.subquery()
)
query = query.join(subquery, Tracks.id == subquery.c.track_id).where(
subquery.c.max_last_played < before
)
records = session.scalars(query).unique().all()
return records
@classmethod
def get_by_path(cls, session: Session, path: str) -> Optional["Tracks"]:
"""
Return track with passed path, or None.
"""
try:
return (
session.execute(select(Tracks).where(Tracks.path == path))
.unique()
.scalar_one()
)
except NoResultFound:
return None
@classmethod
def search_artists(cls, session: Session, text: str) -> Sequence["Tracks"]:
"""
Search case-insenstively for artists containing str
The query performs an outer join with 'joinedload' to populate the results
from the Playdates table at the same time. unique() needed; see
https://docs.sqlalchemy.org/en/20/orm/queryguide/relationships.html#joined-eager-loading
"""
return (
session.scalars(
select(cls)
.options(joinedload(Tracks.playdates))
.where(cls.artist.ilike(f"%{text}%"))
.order_by(cls.title)
)
.unique()
.all()
)
@classmethod
def search_titles(cls, session: Session, text: str) -> Sequence["Tracks"]:
"""
Search case-insenstively for titles containing str
The query performs an outer join with 'joinedload' to populate the results
from the Playdates table at the same time. unique() needed; see
https://docs.sqlalchemy.org/en/20/orm/queryguide/relationships.html#joined-eager-loading
"""
return (
session.scalars(
select(cls)
.options(joinedload(Tracks.playdates))
.where(cls.title.like(f"{text}%"))
.order_by(cls.title)
)
.unique()
.all()
)

View File

@ -1,154 +0,0 @@
import os
import threading
import vlc
from config import Config
from datetime import datetime
from time import sleep
from log import DEBUG, ERROR
class Music:
"""
Manage the playing of music tracks
"""
def __init__(self):
self.current_track_start_time = None
self.fading = False
self.VLC = vlc.Instance()
self.player = None
self.track_path = None
self.max_volume = Config.VOLUME_VLC_DEFAULT
def fade(self):
"""
Fade the currently playing track.
The actual management of fading runs in its own thread so as not
to hold up the UI during the fade.
"""
DEBUG("music.fade()")
if not self.playing():
return None
self.fading = True
thread = threading.Thread(target=self._fade)
thread.start()
def _fade(self):
"""
Implementation of fading the current track in a separate thread.
"""
DEBUG("music._fade()")
fade_time = Config.FADE_TIME / 1000
steps = Config.FADE_STEPS
sleep_time = fade_time / steps
# We reduce volume by one mesure first, then by two measures,
# then three, and so on.
# The sum of the arithmetic sequence 1, 2, 3, ..n is
# (n**2 + n) / 2
total_measures_count = (steps**2 + steps) / 2
# Take a copy of current player to allow another track to be
# started without interfering here
p = self.player
measures_to_reduce_by = 0
for i in range(1, steps + 1):
measures_to_reduce_by += i
volume_factor = 1 - (measures_to_reduce_by / total_measures_count)
p.audio_set_volume(int(self.max_volume * volume_factor))
sleep(sleep_time)
p.stop()
p.release()
self.fading = False
def get_playtime(self):
"Return elapsed play time"
if not self.player:
return None
return self.player.get_time()
def get_position(self):
"Return current position"
DEBUG("music.get_position")
return self.player.get_position()
def play(self, path):
"""
Start playing the track at path.
Log and return if path not found.
"""
DEBUG(f"music.play({path})")
if not os.access(path, os.R_OK):
ERROR(f"play({path}): path not found")
return
self.track_path = path
self.player = self.VLC.media_player_new(path)
self.player.audio_set_volume(self.max_volume)
self.player.play()
self.current_track_start_time = datetime.now()
def playing(self):
"""
Return True if currently playing a track, else False
vlc.is_playing() returns True if track was faded out.
get_position seems more reliable.
"""
if self.player:
if self.player.get_position() > 0 and self.player.is_playing():
return True
# We take a copy of the player when fading, so we could be
# playing in a fade nowFalse
return self.fading
def set_position(self, ms):
"Set current play time in milliseconds from start"
return self.player.set_time(ms)
def set_volume(self, volume):
"Set maximum volume used for player"
if not self.player:
return
self.max_volume = volume
self.player.audio_set_volume(volume)
def stop(self):
"Immediately stop playing"
DEBUG("music.stop()")
if not self.player:
return None
position = self.player.get_position()
self.player.stop()
self.player.release()
# Ensure we don't reference player after release
self.player = None
return position

724
app/music_manager.py Normal file
View File

@ -0,0 +1,724 @@
# Standard library imports
from __future__ import annotations
import datetime as dt
from time import sleep
from typing import Optional
# Third party imports
# import line_profiler
import numpy as np
import pyqtgraph as pg # type: ignore
from sqlalchemy.orm.session import Session
import vlc # type: ignore
# PyQt imports
from PyQt6.QtCore import (
pyqtSignal,
QObject,
QThread,
)
from pyqtgraph import PlotWidget
from pyqtgraph.graphicsItems.PlotDataItem import PlotDataItem # type: ignore
from pyqtgraph.graphicsItems.LinearRegionItem import LinearRegionItem # type: ignore
# App imports
from classes import ApplicationError, MusicMusterSignals
from config import Config
import helpers
from log import log
from models import PlaylistRows
from vlcmanager import VLCManager
# Define the VLC callback function type
# import ctypes
# import platform
# VLC logging is very noisy so comment out unless needed
# VLC_LOG_CB = ctypes.CFUNCTYPE(
# None,
# ctypes.c_void_p,
# ctypes.c_int,
# ctypes.c_void_p,
# ctypes.c_char_p,
# ctypes.c_void_p,
# )
# # Determine the correct C library for vsnprintf based on the platform
# if platform.system() == "Windows":
# libc = ctypes.CDLL("msvcrt")
# elif platform.system() == "Linux":
# libc = ctypes.CDLL("libc.so.6")
# elif platform.system() == "Darwin": # macOS
# libc = ctypes.CDLL("libc.dylib")
# else:
# raise OSError("Unsupported operating system")
# # Define the vsnprintf function
# libc.vsnprintf.argtypes = [
# ctypes.c_char_p,
# ctypes.c_size_t,
# ctypes.c_char_p,
# ctypes.c_void_p,
# ]
# libc.vsnprintf.restype = ctypes.c_int
class _AddFadeCurve(QObject):
"""
Initialising a fade curve introduces a noticeable delay so carry out in
a thread.
"""
finished = pyqtSignal()
def __init__(
self,
rat: RowAndTrack,
track_path: str,
track_fade_at: int,
track_silence_at: int,
) -> None:
super().__init__()
self.rat = rat
self.track_path = track_path
self.track_fade_at = track_fade_at
self.track_silence_at = track_silence_at
def run(self) -> None:
"""
Create fade curve and add to PlaylistTrack object
"""
fc = _FadeCurve(self.track_path, self.track_fade_at, self.track_silence_at)
if not fc:
log.error(f"Failed to create FadeCurve for {self.track_path=}")
else:
self.rat.fade_graph = fc
self.finished.emit()
class _FadeCurve:
GraphWidget: Optional[PlotWidget] = None
def __init__(
self, track_path: str, track_fade_at: int, track_silence_at: int
) -> None:
"""
Set up fade graph array
"""
audio = helpers.get_audio_segment(track_path)
if not audio:
log.error(f"FadeCurve: could not get audio for {track_path=}")
return None
# Start point of curve is Config.FADE_CURVE_MS_BEFORE_FADE
# milliseconds before fade starts to silence
self.start_ms: int = max(
0, track_fade_at - Config.FADE_CURVE_MS_BEFORE_FADE - 1
)
self.end_ms: int = track_silence_at
audio_segment = audio[self.start_ms : self.end_ms]
self.graph_array = np.array(audio_segment.get_array_of_samples())
# Calculate the factor to map milliseconds of track to array
self.ms_to_array_factor = len(self.graph_array) / (self.end_ms - self.start_ms)
self.curve: Optional[PlotDataItem] = None
self.region: Optional[LinearRegionItem] = None
def clear(self) -> None:
"""Clear the current graph"""
if self.GraphWidget:
self.GraphWidget.clear()
def plot(self) -> None:
if self.GraphWidget:
self.curve = self.GraphWidget.plot(self.graph_array)
if self.curve:
self.curve.setPen(Config.FADE_CURVE_FOREGROUND)
else:
log.debug("_FadeCurve.plot: no curve")
else:
log.debug("_FadeCurve.plot: no GraphWidget")
def tick(self, play_time: int) -> None:
"""Update volume fade curve"""
if not self.GraphWidget:
return
ms_of_graph = play_time - self.start_ms
if ms_of_graph < 0:
return
if self.region is None:
# Create the region now that we're into fade
self.region = pg.LinearRegionItem([0, 0], bounds=[0, len(self.graph_array)])
self.GraphWidget.addItem(self.region)
# Update region position
if self.region:
self.region.setRegion([0, ms_of_graph * self.ms_to_array_factor])
class _FadeTrack(QThread):
finished = pyqtSignal()
def __init__(self, player: vlc.MediaPlayer, fade_seconds: int) -> None:
super().__init__()
self.player = player
self.fade_seconds = fade_seconds
def run(self) -> None:
"""
Implementation of fading the player
"""
if not self.player:
return
# Reduce volume logarithmically
total_steps = self.fade_seconds * Config.FADEOUT_STEPS_PER_SECOND
if total_steps > 0:
db_reduction_per_step = Config.FADEOUT_DB / total_steps
reduction_factor_per_step = pow(10, (db_reduction_per_step / 20))
volume = self.player.audio_get_volume()
for i in range(1, total_steps + 1):
self.player.audio_set_volume(
int(volume * pow(reduction_factor_per_step, i))
)
sleep(1 / Config.FADEOUT_STEPS_PER_SECOND)
self.finished.emit()
# TODO can we move this into the _Music class?
vlc_instance = VLCManager().vlc_instance
class _Music:
"""
Manage the playing of music tracks
"""
def __init__(self, name: str) -> None:
vlc_instance.set_user_agent(name, name)
self.player: Optional[vlc.MediaPlayer] = None
self.name = name
self.max_volume: int = Config.VLC_VOLUME_DEFAULT
self.start_dt: Optional[dt.datetime] = None
# Set up logging
# self._set_vlc_log()
# VLC logging very noisy so comment out unless needed
# @VLC_LOG_CB
# def log_callback(data, level, ctx, fmt, args):
# try:
# # Create a ctypes string buffer to hold the formatted message
# buf = ctypes.create_string_buffer(1024)
# # Use vsnprintf to format the string with the va_list
# libc.vsnprintf(buf, len(buf), fmt, args)
# # Decode the formatted message
# message = buf.value.decode("utf-8", errors="replace")
# log.debug("VLC: " + message)
# except Exception as e:
# log.error(f"Error in VLC log callback: {e}")
# def _set_vlc_log(self):
# try:
# vlc.libvlc_log_set(vlc_instance, self.log_callback, None)
# log.debug("VLC logging set up successfully")
# except Exception as e:
# log.error(f"Failed to set up VLC logging: {e}")
def adjust_by_ms(self, ms: int) -> None:
"""Move player position by ms milliseconds"""
if not self.player:
return
elapsed_ms = self.get_playtime()
position = self.get_position()
if not position:
position = 0.0
new_position = max(0.0, position + ((position * ms) / elapsed_ms))
self.set_position(new_position)
# Adjus start time so elapsed time calculations are correct
if new_position == 0:
self.start_dt = dt.datetime.now()
else:
if self.start_dt:
self.start_dt -= dt.timedelta(milliseconds=ms)
else:
self.start_dt = dt.datetime.now() - dt.timedelta(milliseconds=ms)
def fade(self, fade_seconds: int) -> None:
"""
Fade the currently playing track.
The actual management of fading runs in its own thread so as not
to hold up the UI during the fade.
"""
if not self.player:
return
if not self.player.get_position() > 0 and self.player.is_playing():
return
self.fader_worker = _FadeTrack(self.player, fade_seconds=fade_seconds)
self.fader_worker.finished.connect(self.player.release)
self.fader_worker.start()
self.start_dt = None
def get_playtime(self) -> int:
"""
Return number of milliseconds current track has been playing or
zero if not playing. The vlc function get_time() only updates 3-4
times a second; this function has much better resolution.
"""
if self.start_dt is None:
return 0
now = dt.datetime.now()
elapsed_seconds = (now - self.start_dt).total_seconds()
return int(elapsed_seconds * 1000)
def get_position(self) -> Optional[float]:
"""Return current position"""
if not self.player:
return None
return self.player.get_position()
def is_playing(self) -> bool:
"""
Return True if we're playing
"""
if not self.player:
return False
# There is a discrete time between starting playing a track and
# player.is_playing() returning True, so assume playing if less
# than Config.PLAY_SETTLE microseconds have passed since
# starting play.
return self.start_dt is not None and (
self.player.is_playing()
or (dt.datetime.now() - self.start_dt)
< dt.timedelta(microseconds=Config.PLAY_SETTLE)
)
def play(
self,
path: str,
start_time: dt.datetime,
position: Optional[float] = None,
) -> None:
"""
Start playing the track at path.
Log and return if path not found.
start_time ensures our version and our caller's version of
the start time is the same
"""
log.debug(f"Music[{self.name}].play({path=}, {position=}")
if helpers.file_is_unreadable(path):
log.error(f"play({path}): path not readable")
return None
self.player = vlc.MediaPlayer(vlc_instance, path)
if self.player is None:
log.error(f"_Music:play: failed to create MediaPlayer ({path=})")
helpers.show_warning(
None, "Error creating MediaPlayer", f"Cannot play file ({path})"
)
return
_ = self.player.play()
self.set_volume(self.max_volume)
if position:
self.player.set_position(position)
self.start_dt = start_time
def set_position(self, position: float) -> None:
"""
Set player position
"""
if self.player:
self.player.set_position(position)
def set_volume(
self, volume: Optional[int] = None, set_default: bool = True
) -> None:
"""Set maximum volume used for player"""
if not self.player:
return
if set_default and volume:
self.max_volume = volume
if volume is None:
volume = Config.VLC_VOLUME_DEFAULT
self.player.audio_set_volume(volume)
def stop(self) -> None:
"""Immediately stop playing"""
log.debug(f"Music[{self.name}].stop()")
self.start_dt = None
if not self.player:
return
if self.player.is_playing():
self.player.stop()
self.player.release()
self.player = None
class RowAndTrack:
"""
Object to manage playlist rows and tracks.
"""
def __init__(self, playlist_row: PlaylistRows) -> None:
"""
Initialises data structure.
The passed PlaylistRows object will include a Tracks object if this
row has a track.
"""
# Collect playlistrow data
self.note = playlist_row.note
self.played = playlist_row.played
self.playlist_id = playlist_row.playlist_id
self.playlistrow_id = playlist_row.id
self.row_number = playlist_row.row_number
self.track_id = playlist_row.track_id
# Playlist display data
self.row_fg: Optional[str] = None
self.row_bg: Optional[str] = None
self.note_fg: Optional[str] = None
self.note_bg: Optional[str] = None
# Collect track data if there's a track
if playlist_row.track_id:
self.artist = playlist_row.track.artist
self.bitrate = playlist_row.track.bitrate
self.duration = playlist_row.track.duration
self.fade_at = playlist_row.track.fade_at
self.intro = playlist_row.track.intro
if playlist_row.track.playdates:
self.lastplayed = max(
[a.lastplayed for a in playlist_row.track.playdates]
)
else:
self.lastplayed = Config.EPOCH
self.path = playlist_row.track.path
self.silence_at = playlist_row.track.silence_at
self.start_gap = playlist_row.track.start_gap
self.title = playlist_row.track.title
else:
self.artist = ""
self.bitrate = 0
self.duration = 0
self.fade_at = 0
self.intro = None
self.lastplayed = Config.EPOCH
self.path = ""
self.silence_at = 0
self.start_gap = 0
self.title = ""
# Track playing data
self.end_of_track_signalled: bool = False
self.end_time: Optional[dt.datetime] = None
self.fade_graph: Optional[_FadeCurve] = None
self.fade_graph_start_updates: Optional[dt.datetime] = None
self.resume_marker: Optional[float] = 0.0
self.forecast_end_time: Optional[dt.datetime] = None
self.forecast_start_time: Optional[dt.datetime] = None
self.start_time: Optional[dt.datetime] = None
# Other object initialisation
self.music = _Music(name=Config.VLC_MAIN_PLAYER_NAME)
self.signals = MusicMusterSignals()
def __repr__(self) -> str:
return (
f"<RowAndTrack(playlist_id={self.playlist_id}, "
f"row_number={self.row_number}, "
f"playlistrow_id={self.playlistrow_id}, "
f"note={self.note}, track_id={self.track_id}>"
)
def check_for_end_of_track(self) -> None:
"""
Check whether track has ended. If so, emit track_ended_signal
"""
if self.start_time is None:
return
if self.end_of_track_signalled:
return
if self.music.is_playing():
return
self.start_time = None
if self.fade_graph:
self.fade_graph.clear()
# Ensure that player is released
self.music.fade(0)
self.signals.track_ended_signal.emit()
self.end_of_track_signalled = True
def create_fade_graph(self) -> None:
"""
Initialise and add FadeCurve in a thread as it's slow
"""
self.fadecurve_thread = QThread()
self.worker = _AddFadeCurve(
self,
track_path=self.path,
track_fade_at=self.fade_at,
track_silence_at=self.silence_at,
)
self.worker.moveToThread(self.fadecurve_thread)
self.fadecurve_thread.started.connect(self.worker.run)
self.worker.finished.connect(self.fadecurve_thread.quit)
self.worker.finished.connect(self.worker.deleteLater)
self.fadecurve_thread.finished.connect(self.fadecurve_thread.deleteLater)
self.fadecurve_thread.start()
def drop3db(self, enable: bool) -> None:
"""
If enable is true, drop output by 3db else restore to full volume
"""
if enable:
self.music.set_volume(volume=Config.VLC_VOLUME_DROP3db, set_default=False)
else:
self.music.set_volume(volume=Config.VLC_VOLUME_DEFAULT, set_default=False)
def fade(self, fade_seconds: int = Config.FADEOUT_SECONDS) -> None:
"""Fade music"""
self.resume_marker = self.music.get_position()
self.music.fade(fade_seconds)
self.signals.track_ended_signal.emit()
def is_playing(self) -> bool:
"""
Return True if we're currently playing else False
"""
if self.start_time is None:
return False
return self.music.is_playing()
def move_back(self, ms: int = Config.PREVIEW_BACK_MS) -> None:
"""
Rewind player by ms milliseconds
"""
self.music.adjust_by_ms(ms * -1)
def move_forward(self, ms: int = Config.PREVIEW_ADVANCE_MS) -> None:
"""
Rewind player by ms milliseconds
"""
self.music.adjust_by_ms(ms)
def play(self, position: Optional[float] = None) -> None:
"""Play track"""
now = dt.datetime.now()
self.start_time = now
# Initialise player
self.music.play(self.path, start_time=now, position=position)
self.end_time = now + dt.timedelta(milliseconds=self.duration)
# Calculate time fade_graph should start updating
if self.fade_at:
update_graph_at_ms = max(
0, self.fade_at - Config.FADE_CURVE_MS_BEFORE_FADE - 1
)
self.fade_graph_start_updates = now + dt.timedelta(
milliseconds=update_graph_at_ms
)
def restart(self) -> None:
"""
Restart player
"""
self.music.adjust_by_ms(self.time_playing() * -1)
def set_forecast_start_time(
self, modified_rows: list[int], start: Optional[dt.datetime]
) -> Optional[dt.datetime]:
"""
Set forecast start time for this row
Update passed modified rows list if we changed the row.
Return new start time
"""
changed = False
if self.forecast_start_time != start:
self.forecast_start_time = start
changed = True
if start is None:
if self.forecast_end_time is not None:
self.forecast_end_time = None
changed = True
new_start_time = None
else:
end_time = start + dt.timedelta(milliseconds=self.duration)
new_start_time = end_time
if self.forecast_end_time != end_time:
self.forecast_end_time = end_time
changed = True
if changed and self.row_number not in modified_rows:
modified_rows.append(self.row_number)
return new_start_time
def stop(self, fade_seconds: int = 0) -> None:
"""
Stop this track playing
"""
self.resume_marker = self.music.get_position()
self.fade(fade_seconds)
# Reset fade graph
if self.fade_graph:
self.fade_graph.clear()
def time_playing(self) -> int:
"""
Return time track has been playing in milliseconds, zero if not playing
"""
if self.start_time is None:
return 0
return self.music.get_playtime()
def time_remaining_intro(self) -> int:
"""
Return milliseconds of intro remaining. Return 0 if no intro time in track
record or if intro has finished.
"""
if not self.intro:
return 0
return max(0, self.intro - self.time_playing())
def time_to_fade(self) -> int:
"""
Return milliseconds until fade time. Return zero if we're not playing.
"""
if self.start_time is None:
return 0
return self.fade_at - self.time_playing()
def time_to_silence(self) -> int:
"""
Return milliseconds until silent. Return zero if we're not playing.
"""
if self.start_time is None:
return 0
return self.silence_at - self.time_playing()
def update_fade_graph(self) -> None:
"""
Update fade graph
"""
if (
not self.is_playing()
or not self.fade_graph_start_updates
or not self.fade_graph
):
return
now = dt.datetime.now()
if self.fade_graph_start_updates > now:
return
self.fade_graph.tick(self.time_playing())
def update_playlist_and_row(self, session: Session) -> None:
"""
Update local playlist_id and row_number from playlistrow_id
"""
plr = session.get(PlaylistRows, self.playlistrow_id)
if not plr:
raise ApplicationError(f"(Can't retrieve PlaylistRows entry, {self=}")
self.playlist_id = plr.playlist_id
self.row_number = plr.row_number
class TrackSequence:
next: Optional[RowAndTrack] = None
current: Optional[RowAndTrack] = None
previous: Optional[RowAndTrack] = None
def set_next(self, rat: Optional[RowAndTrack]) -> None:
"""
Set the 'next' track to be passed rat. Clear
any previous next track. If passed rat is None
just clear existing next track.
"""
# Clear any existing fade graph
if self.next and self.next.fade_graph:
self.next.fade_graph.clear()
if rat is None:
self.next = None
else:
self.next = rat
self.next.create_fade_graph()
track_sequence = TrackSequence()

File diff suppressed because it is too large Load Diff

1836
app/playlistmodel.py Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

290
app/querylistmodel.py Normal file
View File

@ -0,0 +1,290 @@
# Standard library imports
# Allow forward reference to PlaylistModel
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from typing import Optional
import datetime as dt
# PyQt imports
from PyQt6.QtCore import (
QAbstractTableModel,
QModelIndex,
Qt,
QVariant,
)
from PyQt6.QtGui import (
QBrush,
QColor,
QFont,
)
# Third party imports
from sqlalchemy.orm.session import Session
# import snoop # type: ignore
# App imports
from classes import (
ApplicationError,
Filter,
QueryCol,
)
from config import Config
from helpers import (
file_is_unreadable,
get_relative_date,
ms_to_mmss,
show_warning,
)
from log import log
from models import db, Playdates, Tracks
from music_manager import RowAndTrack
@dataclass
class QueryRow:
artist: str
bitrate: int
duration: int
lastplayed: Optional[dt.datetime]
path: str
title: str
track_id: int
class QuerylistModel(QAbstractTableModel):
"""
The Querylist Model
Used to support query lists. The underlying database is never
updated. We just present tracks that match a query and allow the user
to copy those to a playlist.
"""
def __init__(self, session: Session, filter: Filter) -> None:
"""
Load query
"""
log.debug(f"QuerylistModel.__init__({filter=})")
super().__init__()
self.session = session
self.filter = filter
self.querylist_rows: dict[int, QueryRow] = {}
self._selected_rows: set[int] = set()
self.load_data()
def __repr__(self) -> str:
return f"<QuerylistModel: filter={self.filter}, {self.rowCount()} rows>"
def _background_role(self, row: int, column: int, qrow: QueryRow) -> QBrush:
"""Return background setting"""
# Unreadable track file
if file_is_unreadable(qrow.path):
return QBrush(QColor(Config.COLOUR_UNREADABLE))
# Selected row
if row in self._selected_rows:
return QBrush(QColor(Config.COLOUR_QUERYLIST_SELECTED))
# Individual cell colouring
if column == QueryCol.BITRATE.value:
if not qrow.bitrate or qrow.bitrate < Config.BITRATE_LOW_THRESHOLD:
return QBrush(QColor(Config.COLOUR_BITRATE_LOW))
elif qrow.bitrate < Config.BITRATE_OK_THRESHOLD:
return QBrush(QColor(Config.COLOUR_BITRATE_MEDIUM))
else:
return QBrush(QColor(Config.COLOUR_BITRATE_OK))
return QBrush()
def columnCount(self, parent: QModelIndex = QModelIndex()) -> int:
"""Standard function for view"""
return len(QueryCol)
def data(
self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole
) -> QVariant:
"""Return data to view"""
if (
not index.isValid()
or not (0 <= index.row() < len(self.querylist_rows))
or role
in [
Qt.ItemDataRole.CheckStateRole,
Qt.ItemDataRole.DecorationRole,
Qt.ItemDataRole.EditRole,
Qt.ItemDataRole.FontRole,
Qt.ItemDataRole.ForegroundRole,
Qt.ItemDataRole.InitialSortOrderRole,
Qt.ItemDataRole.SizeHintRole,
Qt.ItemDataRole.StatusTipRole,
Qt.ItemDataRole.TextAlignmentRole,
Qt.ItemDataRole.WhatsThisRole,
]
):
return QVariant()
row = index.row()
column = index.column()
# rat for playlist row data as it's used a lot
qrow = self.querylist_rows[row]
# Dispatch to role-specific functions
dispatch_table: dict[int, Callable] = {
int(Qt.ItemDataRole.BackgroundRole): self._background_role,
int(Qt.ItemDataRole.DisplayRole): self._display_role,
int(Qt.ItemDataRole.ToolTipRole): self._tooltip_role,
}
if role in dispatch_table:
return QVariant(dispatch_table[role](row, column, qrow))
# Fall through to no-op
return QVariant()
def _display_role(self, row: int, column: int, qrow: QueryRow) -> str:
"""
Return text for display
"""
dispatch_table = {
QueryCol.ARTIST.value: qrow.artist,
QueryCol.BITRATE.value: str(qrow.bitrate),
QueryCol.DURATION.value: ms_to_mmss(qrow.duration),
QueryCol.LAST_PLAYED.value: get_relative_date(qrow.lastplayed),
QueryCol.TITLE.value: qrow.title,
}
if column in dispatch_table:
return dispatch_table[column]
return ""
def flags(self, index: QModelIndex) -> Qt.ItemFlag:
"""
Standard model flags
"""
if not index.isValid():
return Qt.ItemFlag.NoItemFlags
return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
def get_selected_track_ids(self) -> list[int]:
"""
Return a list of track_ids from selected tracks
"""
return [self.querylist_rows[row].track_id for row in self._selected_rows]
def headerData(
self,
section: int,
orientation: Qt.Orientation,
role: int = Qt.ItemDataRole.DisplayRole,
) -> QVariant:
"""
Return text for headers
"""
display_dispatch_table = {
QueryCol.TITLE.value: QVariant(Config.HEADER_TITLE),
QueryCol.ARTIST.value: QVariant(Config.HEADER_ARTIST),
QueryCol.DURATION.value: QVariant(Config.HEADER_DURATION),
QueryCol.LAST_PLAYED.value: QVariant(Config.HEADER_LAST_PLAYED),
QueryCol.BITRATE.value: QVariant(Config.HEADER_BITRATE),
}
if role == Qt.ItemDataRole.DisplayRole:
if orientation == Qt.Orientation.Horizontal:
return display_dispatch_table[section]
else:
if Config.ROWS_FROM_ZERO:
return QVariant(str(section))
else:
return QVariant(str(section + 1))
elif role == Qt.ItemDataRole.FontRole:
boldfont = QFont()
boldfont.setBold(True)
return QVariant(boldfont)
return QVariant()
def load_data(self) -> None:
"""
Populate self.querylist_rows
"""
# Clear any exsiting rows
self.querylist_rows = {}
row = 0
try:
results = Tracks.get_filtered_tracks(self.session, self.filter)
for result in results:
lastplayed = None
if hasattr(result, "playdates"):
pds = result.playdates
if pds:
lastplayed = max([a.lastplayed for a in pds])
queryrow = QueryRow(
artist=result.artist,
bitrate=result.bitrate or 0,
duration=result.duration,
lastplayed=lastplayed,
path=result.path,
title=result.title,
track_id=result.id,
)
self.querylist_rows[row] = queryrow
row += 1
except ApplicationError as e:
show_warning(None, "Query error", f"Error loading query data ({e})")
def rowCount(self, index: QModelIndex = QModelIndex()) -> int:
"""Standard function for view"""
return len(self.querylist_rows)
def toggle_row_selection(self, row: int) -> None:
if row in self._selected_rows:
self._selected_rows.discard(row)
else:
self._selected_rows.add(row)
# Emit dataChanged for the entire row
top_left = self.index(row, 0)
bottom_right = self.index(row, self.columnCount() - 1)
self.dataChanged.emit(top_left, bottom_right, [Qt.ItemDataRole.BackgroundRole])
def _tooltip_role(self, row: int, column: int, rat: RowAndTrack) -> str | QVariant:
"""
Return tooltip. Currently only used for last_played column.
"""
if column != QueryCol.LAST_PLAYED.value:
return QVariant()
with db.Session() as session:
track_id = self.querylist_rows[row].track_id
if not track_id:
return QVariant()
playdates = Playdates.last_playdates(session, track_id)
return (
"<br>".join(
[
a.lastplayed.strftime(Config.LAST_PLAYED_TOOLTIP_DATE_FORMAT)
for a in reversed(playdates)
]
)
)

View File

@ -1,197 +0,0 @@
#!/usr/bin/env python
import argparse
import os
import shutil
import tempfile
from config import Config
from log import DEBUG, INFO
from model import Tracks, Session
from mutagen.flac import FLAC
from pydub import AudioSegment, effects
from tinytag import TinyTag
def main():
"Main loop"
INFO("Starting")
# Parse command line
p = argparse.ArgumentParser()
p.add_argument('-u', '--update',
action="store_true", dest="update",
default=True, help="Update database")
args = p.parse_args()
# Run as required
if args.update:
INFO("Updating database")
with Session() as session:
update_db(session)
INFO("Finished")
def add_path_to_db(session, path):
"Add passed path to database along with metadata"
track = Tracks.get_or_create(session, path)
tag = TinyTag.get(path)
audio = get_audio_segment(path)
track.title = tag.title
track.artist = tag.artist
track.duration = int(round(tag.duration,
Config.MILLISECOND_SIGFIGS) * 1000)
track.start_gap = leading_silence(audio)
track.fade_at = round(fade_point(audio) / 1000,
Config.MILLISECOND_SIGFIGS) * 1000
track.silence_at = round(trailing_silence(audio) / 1000,
Config.MILLISECOND_SIGFIGS) * 1000
track.mtime = os.path.getmtime(path)
session.commit()
if Config.NORMALISE_ON_IMPORT:
# Get current file gid, uid and permissions
stats = os.stat(path)
try:
# Copy original file
fd, temp_path = tempfile.mkstemp()
shutil.copyfile(path, temp_path)
except Exception as err:
DEBUG(f"songdb.add_path_to_db({path}): err1: {str(err)}")
return
# Overwrite original file with normalised output
normalised = effects.normalize(audio)
try:
normalised.export(path, format=os.path.splitext(path)[1][1:])
# Fix up permssions and ownership
os.chown(path, stats.st_uid, stats.st_gid)
os.chmod(path, stats.st_mode)
# Copy tags
src = FLAC(temp_path)
dst = FLAC(path)
for tag in src:
dst[tag] = src[tag]
dst.save()
except Exception as err:
DEBUG(f"songdb.add_path_to_db({path}): err2: {str(err)}")
# Restore original file
shutil.copyfile(path, temp_path)
finally:
if os.path.exists(temp_path):
os.remove(temp_path)
return track
def get_audio_segment(path):
try:
if path.endswith('.mp3'):
return AudioSegment.from_mp3(path)
elif path.endswith('.flac'):
return AudioSegment.from_file(path, "flac")
except AttributeError:
return None
def leading_silence(audio_segment, silence_threshold=Config.DBFS_SILENCE,
chunk_size=Config.AUDIO_SEGMENT_CHUNK_SIZE):
"""
Returns the millisecond/index that the leading silence ends.
audio_segment - the segment to find silence in
silence_threshold - the upper bound for how quiet is silent in dFBS
chunk_size - chunk size for interating over the segment in ms
https://github.com/jiaaro/pydub/blob/master/pydub/silence.py
"""
trim_ms = 0 # ms
assert chunk_size > 0 # to avoid infinite loop
while (
audio_segment[trim_ms:trim_ms + chunk_size].dBFS < # noqa W504
silence_threshold and trim_ms < len(audio_segment)):
trim_ms += chunk_size
# if there is no end it should return the length of the segment
return min(trim_ms, len(audio_segment))
def fade_point(audio_segment, fade_threshold=Config.DBFS_FADE,
chunk_size=Config.AUDIO_SEGMENT_CHUNK_SIZE):
"""
Returns the millisecond/index of the point where the fade is down to
fade_threshold and doesn't get louder again.
audio_segment - the sdlg_search_database_uiegment to find silence in
fade_threshold - the upper bound for how quiet is silent in dFBS
chunk_size - chunk size for interating over the segment in ms
"""
assert chunk_size > 0 # to avoid infinite loop
segment_length = audio_segment.duration_seconds * 1000 # ms
trim_ms = segment_length - chunk_size
while (
audio_segment[trim_ms:trim_ms + chunk_size].dBFS < fade_threshold
and trim_ms > 0): # noqa W503
trim_ms -= chunk_size
# if there is no trailing silence, return lenght of track (it's less
# the chunk_size, but for chunk_size = 10ms, this may be ignored)
return int(trim_ms)
# Current unused (1 June 2021)
# def rescan_database(session):
#
# tracks = Tracks.get_all_tracks(session)
# total_tracks = len(tracks)
# track_count = 0
# for track in tracks:
# track_count += 1
# print(f"Track {track_count} of {total_tracks}")
# audio = get_audio_segment(track.path)
# track.start_gap = leading_silence(audio)
# track.fade_at = fade_point(audio)
# track.silence_at = trailing_silence(audio)
# session.commit()
def trailing_silence(audio_segment, silence_threshold=-50.0,
chunk_size=Config.AUDIO_SEGMENT_CHUNK_SIZE):
return fade_point(audio_segment, silence_threshold, chunk_size)
def update_db(session):
"""
Repopulate database
"""
# Search for tracks in only one of directory and database
db_paths = set(Tracks.get_all_paths(session))
os_paths_list = []
for root, dirs, files in os.walk(Config.ROOT):
for f in files:
path = os.path.join(root, f)
ext = os.path.splitext(f)[1]
if ext in [".flac", ".mp3"]:
os_paths_list.append(path)
os_paths = set(os_paths_list)
for path in list(db_paths - os_paths):
# TODO
INFO(f"To remove from database: {path}")
for path in list(os_paths - db_paths):
# TODO
INFO(f"Adding to dataabase: {path}")
add_path_to_db(session, path)
if __name__ == '__main__' and '__file__' in globals():
main()

94
app/ui/dlgQuery.ui Normal file
View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>queryDialog</class>
<widget class="QDialog" name="queryDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>762</width>
<height>686</height>
</rect>
</property>
<property name="windowTitle">
<string>Query</string>
</property>
<widget class="QTableView" name="tableView">
<property name="geometry">
<rect>
<x>10</x>
<y>65</y>
<width>741</width>
<height>561</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>61</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>Query:</string>
</property>
</widget>
<widget class="QComboBox" name="cboQuery">
<property name="geometry">
<rect>
<x>80</x>
<y>10</y>
<width>221</width>
<height>32</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="btnAddTracks">
<property name="geometry">
<rect>
<x>530</x>
<y>640</y>
<width>102</width>
<height>36</height>
</rect>
</property>
<property name="text">
<string>Add &amp;tracks</string>
</property>
</widget>
<widget class="QLabel" name="lblDescription">
<property name="geometry">
<rect>
<x>330</x>
<y>10</y>
<width>401</width>
<height>46</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>650</x>
<y>640</y>
<width>102</width>
<height>36</height>
</rect>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

45
app/ui/dlgQuery_ui.py Normal file
View File

@ -0,0 +1,45 @@
# Form implementation generated from reading ui file 'app/ui/dlgQuery.ui'
#
# Created by: PyQt6 UI code generator 6.8.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_queryDialog(object):
def setupUi(self, queryDialog):
queryDialog.setObjectName("queryDialog")
queryDialog.resize(762, 686)
self.tableView = QtWidgets.QTableView(parent=queryDialog)
self.tableView.setGeometry(QtCore.QRect(10, 65, 741, 561))
self.tableView.setObjectName("tableView")
self.label = QtWidgets.QLabel(parent=queryDialog)
self.label.setGeometry(QtCore.QRect(20, 10, 61, 24))
self.label.setObjectName("label")
self.cboQuery = QtWidgets.QComboBox(parent=queryDialog)
self.cboQuery.setGeometry(QtCore.QRect(80, 10, 221, 32))
self.cboQuery.setObjectName("cboQuery")
self.btnAddTracks = QtWidgets.QPushButton(parent=queryDialog)
self.btnAddTracks.setGeometry(QtCore.QRect(530, 640, 102, 36))
self.btnAddTracks.setObjectName("btnAddTracks")
self.lblDescription = QtWidgets.QLabel(parent=queryDialog)
self.lblDescription.setGeometry(QtCore.QRect(330, 10, 401, 46))
self.lblDescription.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop)
self.lblDescription.setObjectName("lblDescription")
self.pushButton = QtWidgets.QPushButton(parent=queryDialog)
self.pushButton.setGeometry(QtCore.QRect(650, 640, 102, 36))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(queryDialog)
QtCore.QMetaObject.connectSlotsByName(queryDialog)
def retranslateUi(self, queryDialog):
_translate = QtCore.QCoreApplication.translate
queryDialog.setWindowTitle(_translate("queryDialog", "Query"))
self.label.setText(_translate("queryDialog", "Query:"))
self.btnAddTracks.setText(_translate("queryDialog", "Add &tracks"))
self.lblDescription.setText(_translate("queryDialog", "TextLabel"))
self.pushButton.setText(_translate("queryDialog", "Close"))

145
app/ui/dlgReplaceFiles.ui Normal file
View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1038</width>
<height>774</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>680</x>
<y>730</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>15</y>
<width>181</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>Source directory:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>181</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>Destination directory:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="lblSourceDirectory">
<property name="geometry">
<rect>
<x>200</x>
<y>15</y>
<width>811</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>lblSourceDirectory</string>
</property>
</widget>
<widget class="QLabel" name="lblDestinationDirectory">
<property name="geometry">
<rect>
<x>200</x>
<y>50</y>
<width>811</width>
<height>24</height>
</rect>
</property>
<property name="text">
<string>lblDestinationDirectory</string>
</property>
</widget>
<widget class="QTableWidget" name="tableWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>90</y>
<width>1001</width>
<height>621</height>
</rect>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="columnCount">
<number>3</number>
</property>
<column/>
<column/>
<column/>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

164
app/ui/dlg_Cart.ui Normal file
View File

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogCartEdit</class>
<widget class="QDialog" name="DialogCartEdit">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>564</width>
<height>148</height>
</rect>
</property>
<property name="windowTitle">
<string>Carts</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>56</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Name:</string>
</property>
<property name="buddy">
<cstring>lineEditName</cstring>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="lineEditName">
<property name="inputMask">
<string/>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="chkEnabled">
<property name="text">
<string>&amp;Enabled</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="maximumSize">
<size>
<width>56</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>File:</string>
</property>
<property name="buddy">
<cstring>lblPath</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lblPath">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>301</width>
<height>41</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="btnFile">
<property name="maximumSize">
<size>
<width>31</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>116</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogCartEdit</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogCartEdit</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,86 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>383</width>
<height>270</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Title:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="searchString"/>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="matchList"/>
</item>
<item>
<widget class="QLabel" name="dbPath">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>88</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnAdd">
<property name="text">
<string>&amp;Add</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnAddClose">
<property name="text">
<string>A&amp;dd and close</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClose">
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,34 @@
# Form implementation generated from reading ui file 'app/ui/dlg_SelectPlaylist.ui'
#
# Created by: PyQt6 UI code generator 6.5.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_dlgSelectPlaylist(object):
def setupUi(self, dlgSelectPlaylist):
dlgSelectPlaylist.setObjectName("dlgSelectPlaylist")
dlgSelectPlaylist.resize(276, 150)
self.verticalLayout = QtWidgets.QVBoxLayout(dlgSelectPlaylist)
self.verticalLayout.setObjectName("verticalLayout")
self.lstPlaylists = QtWidgets.QListWidget(parent=dlgSelectPlaylist)
self.lstPlaylists.setObjectName("lstPlaylists")
self.verticalLayout.addWidget(self.lstPlaylists)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=dlgSelectPlaylist)
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonBox.setObjectName("buttonBox")
self.verticalLayout.addWidget(self.buttonBox)
self.retranslateUi(dlgSelectPlaylist)
self.buttonBox.accepted.connect(dlgSelectPlaylist.accept) # type: ignore
self.buttonBox.rejected.connect(dlgSelectPlaylist.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(dlgSelectPlaylist)
def retranslateUi(self, dlgSelectPlaylist):
_translate = QtCore.QCoreApplication.translate
dlgSelectPlaylist.setWindowTitle(_translate("dlgSelectPlaylist", "Dialog"))

131
app/ui/dlg_TrackSelect.ui Normal file
View File

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>584</width>
<height>377</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Title:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="searchString"/>
</item>
<item row="1" column="0" colspan="2">
<widget class="QListWidget" name="matchList"/>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="lblNote">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>46</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>&amp;Note:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy">
<cstring>txtNote</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="txtNote"/>
</item>
</layout>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="dbPath">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="radioTitle">
<property name="text">
<string>&amp;Title</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioArtist">
<property name="text">
<string>&amp;Artist</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btnAdd">
<property name="text">
<string>&amp;Add</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnAddClose">
<property name="text">
<string>A&amp;dd and close</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClose">
<property name="text">
<string>&amp;Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,83 @@
# Form implementation generated from reading ui file 'dlg_TrackSelect.ui'
#
# Created by: PyQt6 UI code generator 6.5.3
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(584, 377)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.label = QtWidgets.QLabel(parent=Dialog)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.searchString = QtWidgets.QLineEdit(parent=Dialog)
self.searchString.setObjectName("searchString")
self.gridLayout.addWidget(self.searchString, 0, 1, 1, 1)
self.matchList = QtWidgets.QListWidget(parent=Dialog)
self.matchList.setObjectName("matchList")
self.gridLayout.addWidget(self.matchList, 1, 0, 1, 2)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.lblNote = QtWidgets.QLabel(parent=Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Fixed, QtWidgets.QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lblNote.sizePolicy().hasHeightForWidth())
self.lblNote.setSizePolicy(sizePolicy)
self.lblNote.setMaximumSize(QtCore.QSize(46, 16777215))
self.lblNote.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop)
self.lblNote.setObjectName("lblNote")
self.horizontalLayout.addWidget(self.lblNote)
self.txtNote = QtWidgets.QLineEdit(parent=Dialog)
self.txtNote.setObjectName("txtNote")
self.horizontalLayout.addWidget(self.txtNote)
self.gridLayout.addLayout(self.horizontalLayout, 2, 0, 1, 2)
self.dbPath = QtWidgets.QLabel(parent=Dialog)
self.dbPath.setText("")
self.dbPath.setObjectName("dbPath")
self.gridLayout.addWidget(self.dbPath, 3, 0, 1, 2)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.radioTitle = QtWidgets.QRadioButton(parent=Dialog)
self.radioTitle.setChecked(True)
self.radioTitle.setObjectName("radioTitle")
self.horizontalLayout_2.addWidget(self.radioTitle)
self.radioArtist = QtWidgets.QRadioButton(parent=Dialog)
self.radioArtist.setObjectName("radioArtist")
self.horizontalLayout_2.addWidget(self.radioArtist)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.btnAdd = QtWidgets.QPushButton(parent=Dialog)
self.btnAdd.setDefault(True)
self.btnAdd.setObjectName("btnAdd")
self.horizontalLayout_2.addWidget(self.btnAdd)
self.btnAddClose = QtWidgets.QPushButton(parent=Dialog)
self.btnAddClose.setObjectName("btnAddClose")
self.horizontalLayout_2.addWidget(self.btnAddClose)
self.btnClose = QtWidgets.QPushButton(parent=Dialog)
self.btnClose.setObjectName("btnClose")
self.horizontalLayout_2.addWidget(self.btnClose)
self.gridLayout.addLayout(self.horizontalLayout_2, 4, 0, 1, 2)
self.lblNote.setBuddy(self.txtNote)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Title:"))
self.lblNote.setText(_translate("Dialog", "&Note:"))
self.radioTitle.setText(_translate("Dialog", "&Title"))
self.radioArtist.setText(_translate("Dialog", "&Artist"))
self.btnAdd.setText(_translate("Dialog", "&Add"))
self.btnAddClose.setText(_translate("Dialog", "A&dd and close"))
self.btnClose.setText(_translate("Dialog", "&Close"))

71
app/ui/dlg_cart_ui.py Normal file
View File

@ -0,0 +1,71 @@
# Form implementation generated from reading ui file 'dlg_Cart.ui'
#
# Created by: PyQt6 UI code generator 6.5.3
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_DialogCartEdit(object):
def setupUi(self, DialogCartEdit):
DialogCartEdit.setObjectName("DialogCartEdit")
DialogCartEdit.resize(564, 148)
self.gridLayout = QtWidgets.QGridLayout(DialogCartEdit)
self.gridLayout.setObjectName("gridLayout")
self.label = QtWidgets.QLabel(parent=DialogCartEdit)
self.label.setMaximumSize(QtCore.QSize(56, 16777215))
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.lineEditName = QtWidgets.QLineEdit(parent=DialogCartEdit)
self.lineEditName.setInputMask("")
self.lineEditName.setObjectName("lineEditName")
self.gridLayout.addWidget(self.lineEditName, 0, 1, 1, 2)
self.chkEnabled = QtWidgets.QCheckBox(parent=DialogCartEdit)
self.chkEnabled.setObjectName("chkEnabled")
self.gridLayout.addWidget(self.chkEnabled, 0, 3, 1, 1)
self.label_2 = QtWidgets.QLabel(parent=DialogCartEdit)
self.label_2.setMaximumSize(QtCore.QSize(56, 16777215))
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)
self.lblPath = QtWidgets.QLabel(parent=DialogCartEdit)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lblPath.sizePolicy().hasHeightForWidth())
self.lblPath.setSizePolicy(sizePolicy)
self.lblPath.setMinimumSize(QtCore.QSize(301, 41))
self.lblPath.setText("")
self.lblPath.setTextFormat(QtCore.Qt.TextFormat.PlainText)
self.lblPath.setAlignment(QtCore.Qt.AlignmentFlag.AlignLeading|QtCore.Qt.AlignmentFlag.AlignLeft|QtCore.Qt.AlignmentFlag.AlignTop)
self.lblPath.setWordWrap(True)
self.lblPath.setObjectName("lblPath")
self.gridLayout.addWidget(self.lblPath, 1, 1, 1, 1)
self.btnFile = QtWidgets.QPushButton(parent=DialogCartEdit)
self.btnFile.setMaximumSize(QtCore.QSize(31, 16777215))
self.btnFile.setObjectName("btnFile")
self.gridLayout.addWidget(self.btnFile, 1, 3, 1, 1)
spacerItem = QtWidgets.QSpacerItem(116, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
self.gridLayout.addItem(spacerItem, 2, 1, 1, 1)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=DialogCartEdit)
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonBox.setObjectName("buttonBox")
self.gridLayout.addWidget(self.buttonBox, 2, 2, 1, 2)
self.label.setBuddy(self.lineEditName)
self.label_2.setBuddy(self.lblPath)
self.retranslateUi(DialogCartEdit)
self.buttonBox.accepted.connect(DialogCartEdit.accept) # type: ignore
self.buttonBox.rejected.connect(DialogCartEdit.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(DialogCartEdit)
def retranslateUi(self, DialogCartEdit):
_translate = QtCore.QCoreApplication.translate
DialogCartEdit.setWindowTitle(_translate("DialogCartEdit", "Carts"))
self.label.setText(_translate("DialogCartEdit", "&Name:"))
self.chkEnabled.setText(_translate("DialogCartEdit", "&Enabled"))
self.label_2.setText(_translate("DialogCartEdit", "File:"))
self.btnFile.setText(_translate("DialogCartEdit", "..."))

View File

@ -0,0 +1,53 @@
# Form implementation generated from reading ui file 'app/ui/dlgReplaceFiles.ui'
#
# Created by: PyQt6 UI code generator 6.7.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(1038, 774)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=Dialog)
self.buttonBox.setGeometry(QtCore.QRect(680, 730, 341, 32))
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonBox.setObjectName("buttonBox")
self.label = QtWidgets.QLabel(parent=Dialog)
self.label.setGeometry(QtCore.QRect(10, 15, 181, 24))
self.label.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(parent=Dialog)
self.label_2.setGeometry(QtCore.QRect(10, 50, 181, 24))
self.label_2.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter)
self.label_2.setObjectName("label_2")
self.lblSourceDirectory = QtWidgets.QLabel(parent=Dialog)
self.lblSourceDirectory.setGeometry(QtCore.QRect(200, 15, 811, 24))
self.lblSourceDirectory.setObjectName("lblSourceDirectory")
self.lblDestinationDirectory = QtWidgets.QLabel(parent=Dialog)
self.lblDestinationDirectory.setGeometry(QtCore.QRect(200, 50, 811, 24))
self.lblDestinationDirectory.setObjectName("lblDestinationDirectory")
self.tableWidget = QtWidgets.QTableWidget(parent=Dialog)
self.tableWidget.setGeometry(QtCore.QRect(20, 90, 1001, 621))
self.tableWidget.setAlternatingRowColors(True)
self.tableWidget.setColumnCount(3)
self.tableWidget.setObjectName("tableWidget")
self.tableWidget.setRowCount(0)
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
self.buttonBox.rejected.connect(Dialog.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Source directory:"))
self.label_2.setText(_translate("Dialog", "Destination directory:"))
self.lblSourceDirectory.setText(_translate("Dialog", "lblSourceDirectory"))
self.lblDestinationDirectory.setText(_translate("Dialog", "lblDestinationDirectory"))

107
app/ui/downloadcsv.ui Normal file
View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DateSelect</class>
<widget class="QDialog" name="DateSelect">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>280</width>
<height>166</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>70</x>
<y>110</y>
<width>191</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QDateTimeEdit" name="dateTimeEdit">
<property name="geometry">
<rect>
<x>70</x>
<y>60</y>
<width>194</width>
<height>28</height>
</rect>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>261</width>
<height>19</height>
</rect>
</property>
<property name="text">
<string>Download CSV of tracks played</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>15</x>
<y>66</y>
<width>51</width>
<height>19</height>
</rect>
</property>
<property name="text">
<string>Since:</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DateSelect</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DateSelect</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

41
app/ui/downloadcsv_ui.py Normal file
View File

@ -0,0 +1,41 @@
# Form implementation generated from reading ui file 'app/ui/downloadcsv.ui'
#
# Created by: PyQt6 UI code generator 6.5.0
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_DateSelect(object):
def setupUi(self, DateSelect):
DateSelect.setObjectName("DateSelect")
DateSelect.resize(280, 166)
self.buttonBox = QtWidgets.QDialogButtonBox(parent=DateSelect)
self.buttonBox.setGeometry(QtCore.QRect(70, 110, 191, 32))
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.StandardButton.Cancel|QtWidgets.QDialogButtonBox.StandardButton.Ok)
self.buttonBox.setObjectName("buttonBox")
self.dateTimeEdit = QtWidgets.QDateTimeEdit(parent=DateSelect)
self.dateTimeEdit.setGeometry(QtCore.QRect(70, 60, 194, 28))
self.dateTimeEdit.setCalendarPopup(True)
self.dateTimeEdit.setObjectName("dateTimeEdit")
self.label = QtWidgets.QLabel(parent=DateSelect)
self.label.setGeometry(QtCore.QRect(10, 20, 261, 19))
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(parent=DateSelect)
self.label_2.setGeometry(QtCore.QRect(15, 66, 51, 19))
self.label_2.setObjectName("label_2")
self.retranslateUi(DateSelect)
self.buttonBox.accepted.connect(DateSelect.accept) # type: ignore
self.buttonBox.rejected.connect(DateSelect.reject) # type: ignore
QtCore.QMetaObject.connectSlotsByName(DateSelect)
def retranslateUi(self, DateSelect):
_translate = QtCore.QCoreApplication.translate
DateSelect.setWindowTitle(_translate("DateSelect", "Dialog"))
self.label.setText(_translate("DateSelect", "Download CSV of tracks played"))
self.label_2.setText(_translate("DateSelect", "Since:"))

BIN
app/ui/green-circle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
app/ui/headphone-symbol.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -1,5 +1,14 @@
<RCC>
<qresource prefix="icons">
<file>yellow-circle.png</file>
<file>redstar.png</file>
<file>green-circle.png</file>
<file>star.png</file>
<file>star_empty.png</file>
<file>record-red-button.png</file>
<file>record-button.png</file>
<file alias="headphones">headphone-symbol.png</file>
<file alias="musicmuster">musicmuster.png</file>
<file alias="stopsign">stopsign.png</file>
<file alias="wikipedia">wikipedia-logo.png</file>
<file alias="songsearch">songsearch_icon.png</file>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,589 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FooterSection</class>
<widget class="QWidget" name="FooterSection">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1237</width>
<height>154</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QFrame" name="InfoFooterFrame">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(192, 191, 188)</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="FadeStopInfoFrame">
<property name="minimumSize">
<size>
<width>152</width>
<height>112</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>184</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QPushButton" name="btnPreview">
<property name="minimumSize">
<size>
<width>132</width>
<height>41</height>
</size>
</property>
<property name="text">
<string> Preview</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/headphones</normaloff>:/icons/headphones</iconset>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxIntroControls">
<property name="minimumSize">
<size>
<width>132</width>
<height>46</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>132</width>
<height>46</height>
</size>
</property>
<property name="title">
<string/>
</property>
<widget class="QPushButton" name="btnPreviewStart">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>44</width>
<height>23</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>&lt;&lt;</string>
</property>
</widget>
<widget class="QPushButton" name="btnPreviewArm">
<property name="geometry">
<rect>
<x>44</x>
<y>0</y>
<width>44</width>
<height>23</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/record-button.png</normaloff>
<normalon>:/icons/record-red-button.png</normalon>:/icons/record-button.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="btnPreviewEnd">
<property name="geometry">
<rect>
<x>88</x>
<y>0</y>
<width>44</width>
<height>23</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>&gt;&gt;</string>
</property>
</widget>
<widget class="QPushButton" name="btnPreviewBack">
<property name="geometry">
<rect>
<x>0</x>
<y>23</y>
<width>44</width>
<height>23</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>&lt;</string>
</property>
</widget>
<widget class="QPushButton" name="btnPreviewMark">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>44</x>
<y>23</y>
<width>44</width>
<height>23</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/star.png</normalon>
<disabledoff>:/icons/star_empty.png</disabledoff>
</iconset>
</property>
</widget>
<widget class="QPushButton" name="btnPreviewFwd">
<property name="geometry">
<rect>
<x>88</x>
<y>23</y>
<width>44</width>
<height>23</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>44</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>&gt;</string>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_intro">
<property name="minimumSize">
<size>
<width>152</width>
<height>112</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Intro</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_intro_timer">
<property name="font">
<font>
<family>FreeSans</family>
<pointsize>40</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>0:0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_toggleplayed_3db">
<property name="minimumSize">
<size>
<width>152</width>
<height>112</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>184</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QPushButton" name="btnDrop3db">
<property name="minimumSize">
<size>
<width>132</width>
<height>41</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>164</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>-3dB to talk</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnHidePlayed">
<property name="minimumSize">
<size>
<width>132</width>
<height>41</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>164</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Hide played</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_fade">
<property name="minimumSize">
<size>
<width>152</width>
<height>112</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Fade</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_fade_timer">
<property name="font">
<font>
<family>FreeSans</family>
<pointsize>40</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>00:00</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_silent">
<property name="minimumSize">
<size>
<width>152</width>
<height>112</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Silent</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_silent_timer">
<property name="font">
<font>
<family>FreeSans</family>
<pointsize>40</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>00:00</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="PlotWidget" name="widgetFadeVolume" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="minimumSize">
<size>
<width>151</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>151</width>
<height>112</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QPushButton" name="btnFade">
<property name="minimumSize">
<size>
<width>132</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>164</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string> Fade</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/fade</normaloff>:/icons/fade</iconset>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnStop">
<property name="minimumSize">
<size>
<width>0</width>
<height>36</height>
</size>
</property>
<property name="text">
<string> Stop</string>
</property>
<property name="icon">
<iconset resource="icons.qrc">
<normaloff>:/icons/stopsign</normaloff>:/icons/stopsign</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PlotWidget</class>
<extends>QWidget</extends>
<header>pyqtgraph</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,274 @@
# Form implementation generated from reading ui file 'app/ui/main_window_footer.ui'
#
# Created by: PyQt6 UI code generator 6.8.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_FooterSection(object):
def setupUi(self, FooterSection):
FooterSection.setObjectName("FooterSection")
FooterSection.resize(1237, 154)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(FooterSection)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.InfoFooterFrame = QtWidgets.QFrame(parent=FooterSection)
self.InfoFooterFrame.setMaximumSize(QtCore.QSize(16777215, 16777215))
self.InfoFooterFrame.setStyleSheet("background-color: rgb(192, 191, 188)")
self.InfoFooterFrame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.InfoFooterFrame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.InfoFooterFrame.setObjectName("InfoFooterFrame")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.InfoFooterFrame)
self.horizontalLayout.setObjectName("horizontalLayout")
self.FadeStopInfoFrame = QtWidgets.QFrame(parent=self.InfoFooterFrame)
self.FadeStopInfoFrame.setMinimumSize(QtCore.QSize(152, 112))
self.FadeStopInfoFrame.setMaximumSize(QtCore.QSize(184, 16777215))
self.FadeStopInfoFrame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.FadeStopInfoFrame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.FadeStopInfoFrame.setObjectName("FadeStopInfoFrame")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.FadeStopInfoFrame)
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.btnPreview = QtWidgets.QPushButton(parent=self.FadeStopInfoFrame)
self.btnPreview.setMinimumSize(QtCore.QSize(132, 41))
icon = QtGui.QIcon()
icon.addPixmap(
QtGui.QPixmap(":/icons/headphones"),
QtGui.QIcon.Mode.Normal,
QtGui.QIcon.State.Off,
)
self.btnPreview.setIcon(icon)
self.btnPreview.setIconSize(QtCore.QSize(30, 30))
self.btnPreview.setCheckable(True)
self.btnPreview.setObjectName("btnPreview")
self.verticalLayout_4.addWidget(self.btnPreview)
self.groupBoxIntroControls = QtWidgets.QGroupBox(parent=self.FadeStopInfoFrame)
self.groupBoxIntroControls.setMinimumSize(QtCore.QSize(132, 46))
self.groupBoxIntroControls.setMaximumSize(QtCore.QSize(132, 46))
self.groupBoxIntroControls.setTitle("")
self.groupBoxIntroControls.setObjectName("groupBoxIntroControls")
self.btnPreviewStart = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
self.btnPreviewStart.setGeometry(QtCore.QRect(0, 0, 44, 23))
self.btnPreviewStart.setMinimumSize(QtCore.QSize(44, 23))
self.btnPreviewStart.setMaximumSize(QtCore.QSize(44, 23))
self.btnPreviewStart.setObjectName("btnPreviewStart")
self.btnPreviewArm = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
self.btnPreviewArm.setGeometry(QtCore.QRect(44, 0, 44, 23))
self.btnPreviewArm.setMinimumSize(QtCore.QSize(44, 23))
self.btnPreviewArm.setMaximumSize(QtCore.QSize(44, 23))
self.btnPreviewArm.setText("")
icon1 = QtGui.QIcon()
icon1.addPixmap(
QtGui.QPixmap(":/icons/record-button.png"),
QtGui.QIcon.Mode.Normal,
QtGui.QIcon.State.Off,
)
icon1.addPixmap(
QtGui.QPixmap(":/icons/record-red-button.png"),
QtGui.QIcon.Mode.Normal,
QtGui.QIcon.State.On,
)
self.btnPreviewArm.setIcon(icon1)
self.btnPreviewArm.setCheckable(True)
self.btnPreviewArm.setObjectName("btnPreviewArm")
self.btnPreviewEnd = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
self.btnPreviewEnd.setGeometry(QtCore.QRect(88, 0, 44, 23))
self.btnPreviewEnd.setMinimumSize(QtCore.QSize(44, 23))
self.btnPreviewEnd.setMaximumSize(QtCore.QSize(44, 23))
self.btnPreviewEnd.setObjectName("btnPreviewEnd")
self.btnPreviewBack = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
self.btnPreviewBack.setGeometry(QtCore.QRect(0, 23, 44, 23))
self.btnPreviewBack.setMinimumSize(QtCore.QSize(44, 23))
self.btnPreviewBack.setMaximumSize(QtCore.QSize(44, 23))
self.btnPreviewBack.setObjectName("btnPreviewBack")
self.btnPreviewMark = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
self.btnPreviewMark.setEnabled(False)
self.btnPreviewMark.setGeometry(QtCore.QRect(44, 23, 44, 23))
self.btnPreviewMark.setMinimumSize(QtCore.QSize(44, 23))
self.btnPreviewMark.setMaximumSize(QtCore.QSize(44, 23))
self.btnPreviewMark.setText("")
icon2 = QtGui.QIcon()
icon2.addPixmap(
QtGui.QPixmap(":/icons/star.png"),
QtGui.QIcon.Mode.Normal,
QtGui.QIcon.State.On,
)
icon2.addPixmap(
QtGui.QPixmap(":/icons/star_empty.png"),
QtGui.QIcon.Mode.Disabled,
QtGui.QIcon.State.Off,
)
self.btnPreviewMark.setIcon(icon2)
self.btnPreviewMark.setObjectName("btnPreviewMark")
self.btnPreviewFwd = QtWidgets.QPushButton(parent=self.groupBoxIntroControls)
self.btnPreviewFwd.setGeometry(QtCore.QRect(88, 23, 44, 23))
self.btnPreviewFwd.setMinimumSize(QtCore.QSize(44, 23))
self.btnPreviewFwd.setMaximumSize(QtCore.QSize(44, 23))
self.btnPreviewFwd.setObjectName("btnPreviewFwd")
self.verticalLayout_4.addWidget(self.groupBoxIntroControls)
self.horizontalLayout.addWidget(self.FadeStopInfoFrame)
self.frame_intro = QtWidgets.QFrame(parent=self.InfoFooterFrame)
self.frame_intro.setMinimumSize(QtCore.QSize(152, 112))
self.frame_intro.setStyleSheet("")
self.frame_intro.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame_intro.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame_intro.setObjectName("frame_intro")
self.verticalLayout_9 = QtWidgets.QVBoxLayout(self.frame_intro)
self.verticalLayout_9.setObjectName("verticalLayout_9")
self.label_7 = QtWidgets.QLabel(parent=self.frame_intro)
self.label_7.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_7.setObjectName("label_7")
self.verticalLayout_9.addWidget(self.label_7)
self.label_intro_timer = QtWidgets.QLabel(parent=self.frame_intro)
font = QtGui.QFont()
font.setFamily("FreeSans")
font.setPointSize(40)
font.setBold(False)
font.setWeight(50)
self.label_intro_timer.setFont(font)
self.label_intro_timer.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_intro_timer.setObjectName("label_intro_timer")
self.verticalLayout_9.addWidget(self.label_intro_timer)
self.horizontalLayout.addWidget(self.frame_intro)
self.frame_toggleplayed_3db = QtWidgets.QFrame(parent=self.InfoFooterFrame)
self.frame_toggleplayed_3db.setMinimumSize(QtCore.QSize(152, 112))
self.frame_toggleplayed_3db.setMaximumSize(QtCore.QSize(184, 16777215))
self.frame_toggleplayed_3db.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame_toggleplayed_3db.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame_toggleplayed_3db.setObjectName("frame_toggleplayed_3db")
self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.frame_toggleplayed_3db)
self.verticalLayout_6.setObjectName("verticalLayout_6")
self.btnDrop3db = QtWidgets.QPushButton(parent=self.frame_toggleplayed_3db)
self.btnDrop3db.setMinimumSize(QtCore.QSize(132, 41))
self.btnDrop3db.setMaximumSize(QtCore.QSize(164, 16777215))
self.btnDrop3db.setCheckable(True)
self.btnDrop3db.setObjectName("btnDrop3db")
self.verticalLayout_6.addWidget(self.btnDrop3db)
self.btnHidePlayed = QtWidgets.QPushButton(parent=self.frame_toggleplayed_3db)
self.btnHidePlayed.setMinimumSize(QtCore.QSize(132, 41))
self.btnHidePlayed.setMaximumSize(QtCore.QSize(164, 16777215))
self.btnHidePlayed.setCheckable(True)
self.btnHidePlayed.setObjectName("btnHidePlayed")
self.verticalLayout_6.addWidget(self.btnHidePlayed)
self.horizontalLayout.addWidget(self.frame_toggleplayed_3db)
self.frame_fade = QtWidgets.QFrame(parent=self.InfoFooterFrame)
self.frame_fade.setMinimumSize(QtCore.QSize(152, 112))
self.frame_fade.setStyleSheet("")
self.frame_fade.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame_fade.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame_fade.setObjectName("frame_fade")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frame_fade)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.label_4 = QtWidgets.QLabel(parent=self.frame_fade)
self.label_4.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_4.setObjectName("label_4")
self.verticalLayout_2.addWidget(self.label_4)
self.label_fade_timer = QtWidgets.QLabel(parent=self.frame_fade)
font = QtGui.QFont()
font.setFamily("FreeSans")
font.setPointSize(40)
font.setBold(False)
font.setWeight(50)
self.label_fade_timer.setFont(font)
self.label_fade_timer.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_fade_timer.setObjectName("label_fade_timer")
self.verticalLayout_2.addWidget(self.label_fade_timer)
self.horizontalLayout.addWidget(self.frame_fade)
self.frame_silent = QtWidgets.QFrame(parent=self.InfoFooterFrame)
self.frame_silent.setMinimumSize(QtCore.QSize(152, 112))
self.frame_silent.setStyleSheet("")
self.frame_silent.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame_silent.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame_silent.setObjectName("frame_silent")
self.verticalLayout_7 = QtWidgets.QVBoxLayout(self.frame_silent)
self.verticalLayout_7.setObjectName("verticalLayout_7")
self.label_5 = QtWidgets.QLabel(parent=self.frame_silent)
self.label_5.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_5.setObjectName("label_5")
self.verticalLayout_7.addWidget(self.label_5)
self.label_silent_timer = QtWidgets.QLabel(parent=self.frame_silent)
font = QtGui.QFont()
font.setFamily("FreeSans")
font.setPointSize(40)
font.setBold(False)
font.setWeight(50)
self.label_silent_timer.setFont(font)
self.label_silent_timer.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_silent_timer.setObjectName("label_silent_timer")
self.verticalLayout_7.addWidget(self.label_silent_timer)
self.horizontalLayout.addWidget(self.frame_silent)
self.widgetFadeVolume = PlotWidget(parent=self.InfoFooterFrame)
sizePolicy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Policy.Preferred,
QtWidgets.QSizePolicy.Policy.Preferred,
)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(
self.widgetFadeVolume.sizePolicy().hasHeightForWidth()
)
self.widgetFadeVolume.setSizePolicy(sizePolicy)
self.widgetFadeVolume.setMinimumSize(QtCore.QSize(0, 0))
self.widgetFadeVolume.setObjectName("widgetFadeVolume")
self.horizontalLayout.addWidget(self.widgetFadeVolume)
self.frame = QtWidgets.QFrame(parent=self.InfoFooterFrame)
self.frame.setMinimumSize(QtCore.QSize(151, 0))
self.frame.setMaximumSize(QtCore.QSize(151, 112))
self.frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame.setObjectName("frame")
self.verticalLayout_5 = QtWidgets.QVBoxLayout(self.frame)
self.verticalLayout_5.setObjectName("verticalLayout_5")
self.btnFade = QtWidgets.QPushButton(parent=self.frame)
self.btnFade.setMinimumSize(QtCore.QSize(132, 32))
self.btnFade.setMaximumSize(QtCore.QSize(164, 16777215))
icon3 = QtGui.QIcon()
icon3.addPixmap(
QtGui.QPixmap(":/icons/fade"),
QtGui.QIcon.Mode.Normal,
QtGui.QIcon.State.Off,
)
self.btnFade.setIcon(icon3)
self.btnFade.setIconSize(QtCore.QSize(30, 30))
self.btnFade.setObjectName("btnFade")
self.verticalLayout_5.addWidget(self.btnFade)
self.btnStop = QtWidgets.QPushButton(parent=self.frame)
self.btnStop.setMinimumSize(QtCore.QSize(0, 36))
icon4 = QtGui.QIcon()
icon4.addPixmap(
QtGui.QPixmap(":/icons/stopsign"),
QtGui.QIcon.Mode.Normal,
QtGui.QIcon.State.Off,
)
self.btnStop.setIcon(icon4)
self.btnStop.setObjectName("btnStop")
self.verticalLayout_5.addWidget(self.btnStop)
self.horizontalLayout.addWidget(self.frame)
self.horizontalLayout_2.addWidget(self.InfoFooterFrame)
self.retranslateUi(FooterSection)
QtCore.QMetaObject.connectSlotsByName(FooterSection)
def retranslateUi(self, FooterSection):
_translate = QtCore.QCoreApplication.translate
FooterSection.setWindowTitle(_translate("FooterSection", "Form"))
self.btnPreview.setText(_translate("FooterSection", " Preview"))
self.btnPreviewStart.setText(_translate("FooterSection", "<<"))
self.btnPreviewEnd.setText(_translate("FooterSection", ">>"))
self.btnPreviewBack.setText(_translate("FooterSection", "<"))
self.btnPreviewFwd.setText(_translate("FooterSection", ">"))
self.label_7.setText(_translate("FooterSection", "Intro"))
self.label_intro_timer.setText(_translate("FooterSection", "0:0"))
self.btnDrop3db.setText(_translate("FooterSection", "-3dB to talk"))
self.btnHidePlayed.setText(_translate("FooterSection", "Hide played"))
self.label_4.setText(_translate("FooterSection", "Fade"))
self.label_fade_timer.setText(_translate("FooterSection", "00:00"))
self.label_5.setText(_translate("FooterSection", "Silent"))
self.label_silent_timer.setText(_translate("FooterSection", "00:00"))
self.btnFade.setText(_translate("FooterSection", " Fade"))
self.btnStop.setText(_translate("FooterSection", " Stop"))
from pyqtgraph import PlotWidget # type: ignore

View File

@ -0,0 +1,314 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HeaderSection</class>
<widget class="QWidget" name="HeaderSection">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1273</width>
<height>179</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="previous_track_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>230</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Sans</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: #f8d7da;
border: 1px solid rgb(85, 87, 83);</string>
</property>
<property name="text">
<string>Last track:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="current_track_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>230</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Sans</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: #d4edda;
border: 1px solid rgb(85, 87, 83);</string>
</property>
<property name="text">
<string>Current track:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="next_track_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>230</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Sans</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: #fff3cd;
border: 1px solid rgb(85, 87, 83);</string>
</property>
<property name="text">
<string>Next track:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="hdrPreviousTrack">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Sans</family>
<pointsize>20</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: #f8d7da;
border: 1px solid rgb(85, 87, 83);</string>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="hdrCurrentTrack">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: #d4edda;
border: 1px solid rgb(85, 87, 83);
text-align: left;
padding-left: 8px;
</string>
</property>
<property name="text">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="hdrNextTrack">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: #fff3cd;
border: 1px solid rgb(85, 87, 83);
text-align: left;
padding-left: 8px;</string>
</property>
<property name="text">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="frame_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>131</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>230</width>
<height>131</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QLabel" name="lblTOD">
<property name="minimumSize">
<size>
<width>208</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>35</pointsize>
</font>
</property>
<property name="text">
<string>00:00:00</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_elapsed_timer">
<property name="font">
<font>
<family>FreeSans</family>
<pointsize>18</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: black;</string>
</property>
<property name="text">
<string>00:00 / 00:00</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QFrame" name="frame_4">
<property name="minimumSize">
<size>
<width>0</width>
<height>16</height>
</size>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(154, 153, 150)</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,178 @@
# Form implementation generated from reading ui file 'app/ui/main_window_header.ui'
#
# Created by: PyQt6 UI code generator 6.8.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_HeaderSection(object):
def setupUi(self, HeaderSection):
HeaderSection.setObjectName("HeaderSection")
HeaderSection.resize(1273, 179)
self.horizontalLayout = QtWidgets.QHBoxLayout(HeaderSection)
self.horizontalLayout.setObjectName("horizontalLayout")
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.verticalLayout_3 = QtWidgets.QVBoxLayout()
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.previous_track_2 = QtWidgets.QLabel(parent=HeaderSection)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.previous_track_2.sizePolicy().hasHeightForWidth())
self.previous_track_2.setSizePolicy(sizePolicy)
self.previous_track_2.setMaximumSize(QtCore.QSize(230, 16777215))
font = QtGui.QFont()
font.setFamily("Sans")
font.setPointSize(20)
self.previous_track_2.setFont(font)
self.previous_track_2.setStyleSheet("background-color: #f8d7da;\n"
"border: 1px solid rgb(85, 87, 83);")
self.previous_track_2.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter)
self.previous_track_2.setObjectName("previous_track_2")
self.verticalLayout_3.addWidget(self.previous_track_2)
self.current_track_2 = QtWidgets.QLabel(parent=HeaderSection)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.current_track_2.sizePolicy().hasHeightForWidth())
self.current_track_2.setSizePolicy(sizePolicy)
self.current_track_2.setMaximumSize(QtCore.QSize(230, 16777215))
font = QtGui.QFont()
font.setFamily("Sans")
font.setPointSize(20)
self.current_track_2.setFont(font)
self.current_track_2.setStyleSheet("background-color: #d4edda;\n"
"border: 1px solid rgb(85, 87, 83);")
self.current_track_2.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter)
self.current_track_2.setObjectName("current_track_2")
self.verticalLayout_3.addWidget(self.current_track_2)
self.next_track_2 = QtWidgets.QLabel(parent=HeaderSection)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.next_track_2.sizePolicy().hasHeightForWidth())
self.next_track_2.setSizePolicy(sizePolicy)
self.next_track_2.setMaximumSize(QtCore.QSize(230, 16777215))
font = QtGui.QFont()
font.setFamily("Sans")
font.setPointSize(20)
self.next_track_2.setFont(font)
self.next_track_2.setStyleSheet("background-color: #fff3cd;\n"
"border: 1px solid rgb(85, 87, 83);")
self.next_track_2.setAlignment(QtCore.Qt.AlignmentFlag.AlignRight|QtCore.Qt.AlignmentFlag.AlignTrailing|QtCore.Qt.AlignmentFlag.AlignVCenter)
self.next_track_2.setObjectName("next_track_2")
self.verticalLayout_3.addWidget(self.next_track_2)
self.horizontalLayout_3.addLayout(self.verticalLayout_3)
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setObjectName("verticalLayout")
self.hdrPreviousTrack = QtWidgets.QLabel(parent=HeaderSection)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.hdrPreviousTrack.sizePolicy().hasHeightForWidth())
self.hdrPreviousTrack.setSizePolicy(sizePolicy)
self.hdrPreviousTrack.setMinimumSize(QtCore.QSize(0, 0))
self.hdrPreviousTrack.setMaximumSize(QtCore.QSize(16777215, 16777215))
font = QtGui.QFont()
font.setFamily("Sans")
font.setPointSize(20)
self.hdrPreviousTrack.setFont(font)
self.hdrPreviousTrack.setStyleSheet("background-color: #f8d7da;\n"
"border: 1px solid rgb(85, 87, 83);")
self.hdrPreviousTrack.setText("")
self.hdrPreviousTrack.setWordWrap(False)
self.hdrPreviousTrack.setObjectName("hdrPreviousTrack")
self.verticalLayout.addWidget(self.hdrPreviousTrack)
self.hdrCurrentTrack = QtWidgets.QPushButton(parent=HeaderSection)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.hdrCurrentTrack.sizePolicy().hasHeightForWidth())
self.hdrCurrentTrack.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(20)
self.hdrCurrentTrack.setFont(font)
self.hdrCurrentTrack.setStyleSheet("background-color: #d4edda;\n"
"border: 1px solid rgb(85, 87, 83);\n"
"text-align: left;\n"
"padding-left: 8px;\n"
"")
self.hdrCurrentTrack.setText("")
self.hdrCurrentTrack.setFlat(True)
self.hdrCurrentTrack.setObjectName("hdrCurrentTrack")
self.verticalLayout.addWidget(self.hdrCurrentTrack)
self.hdrNextTrack = QtWidgets.QPushButton(parent=HeaderSection)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.hdrNextTrack.sizePolicy().hasHeightForWidth())
self.hdrNextTrack.setSizePolicy(sizePolicy)
font = QtGui.QFont()
font.setPointSize(20)
self.hdrNextTrack.setFont(font)
self.hdrNextTrack.setStyleSheet("background-color: #fff3cd;\n"
"border: 1px solid rgb(85, 87, 83);\n"
"text-align: left;\n"
"padding-left: 8px;")
self.hdrNextTrack.setText("")
self.hdrNextTrack.setFlat(True)
self.hdrNextTrack.setObjectName("hdrNextTrack")
self.verticalLayout.addWidget(self.hdrNextTrack)
self.horizontalLayout_3.addLayout(self.verticalLayout)
self.frame_2 = QtWidgets.QFrame(parent=HeaderSection)
self.frame_2.setMinimumSize(QtCore.QSize(0, 131))
self.frame_2.setMaximumSize(QtCore.QSize(230, 131))
self.frame_2.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame_2.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame_2.setObjectName("frame_2")
self.verticalLayout_10 = QtWidgets.QVBoxLayout(self.frame_2)
self.verticalLayout_10.setObjectName("verticalLayout_10")
self.lblTOD = QtWidgets.QLabel(parent=self.frame_2)
self.lblTOD.setMinimumSize(QtCore.QSize(208, 0))
font = QtGui.QFont()
font.setPointSize(35)
self.lblTOD.setFont(font)
self.lblTOD.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.lblTOD.setObjectName("lblTOD")
self.verticalLayout_10.addWidget(self.lblTOD)
self.label_elapsed_timer = QtWidgets.QLabel(parent=self.frame_2)
font = QtGui.QFont()
font.setFamily("FreeSans")
font.setPointSize(18)
font.setBold(False)
font.setWeight(50)
self.label_elapsed_timer.setFont(font)
self.label_elapsed_timer.setStyleSheet("color: black;")
self.label_elapsed_timer.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
self.label_elapsed_timer.setObjectName("label_elapsed_timer")
self.verticalLayout_10.addWidget(self.label_elapsed_timer)
self.horizontalLayout_3.addWidget(self.frame_2)
self.gridLayout.addLayout(self.horizontalLayout_3, 0, 0, 1, 1)
self.frame_4 = QtWidgets.QFrame(parent=HeaderSection)
self.frame_4.setMinimumSize(QtCore.QSize(0, 16))
self.frame_4.setAutoFillBackground(False)
self.frame_4.setStyleSheet("background-color: rgb(154, 153, 150)")
self.frame_4.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
self.frame_4.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
self.frame_4.setObjectName("frame_4")
self.gridLayout.addWidget(self.frame_4, 1, 0, 1, 1)
self.horizontalLayout.addLayout(self.gridLayout)
self.retranslateUi(HeaderSection)
QtCore.QMetaObject.connectSlotsByName(HeaderSection)
def retranslateUi(self, HeaderSection):
_translate = QtCore.QCoreApplication.translate
HeaderSection.setWindowTitle(_translate("HeaderSection", "Form"))
self.previous_track_2.setText(_translate("HeaderSection", "Last track:"))
self.current_track_2.setText(_translate("HeaderSection", "Current track:"))
self.next_track_2.setText(_translate("HeaderSection", "Next track:"))
self.lblTOD.setText(_translate("HeaderSection", "00:00:00"))
self.label_elapsed_timer.setText(_translate("HeaderSection", "00:00 / 00:00"))

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlaylistSection</class>
<widget class="QWidget" name="PlaylistSection">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1249</width>
<height>538</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QTabWidget" name="tabPlaylist">
<property name="currentIndex">
<number>-1</number>
</property>
<property name="documentMode">
<bool>false</bool>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
<property name="movable">
<bool>true</bool>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,34 @@
# Form implementation generated from reading ui file 'app/ui/main_window_playlist.ui'
#
# Created by: PyQt6 UI code generator 6.8.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt6 import QtCore, QtGui, QtWidgets
class Ui_PlaylistSection(object):
def setupUi(self, PlaylistSection):
PlaylistSection.setObjectName("PlaylistSection")
PlaylistSection.resize(1249, 499)
self.horizontalLayout = QtWidgets.QHBoxLayout(PlaylistSection)
self.horizontalLayout.setObjectName("horizontalLayout")
self.splitter = QtWidgets.QSplitter(parent=PlaylistSection)
self.splitter.setOrientation(QtCore.Qt.Orientation.Vertical)
self.splitter.setObjectName("splitter")
self.tabPlaylist = QtWidgets.QTabWidget(parent=self.splitter)
self.tabPlaylist.setDocumentMode(False)
self.tabPlaylist.setTabsClosable(True)
self.tabPlaylist.setMovable(True)
self.tabPlaylist.setObjectName("tabPlaylist")
self.horizontalLayout.addWidget(self.splitter)
self.retranslateUi(PlaylistSection)
self.tabPlaylist.setCurrentIndex(-1)
QtCore.QMetaObject.connectSlotsByName(PlaylistSection)
def retranslateUi(self, PlaylistSection):
_translate = QtCore.QCoreApplication.translate
PlaylistSection.setWindowTitle(_translate("PlaylistSection", "Form"))

BIN
app/ui/musicmuster.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

BIN
app/ui/musicmuster.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
app/ui/record-button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
app/ui/redstar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
app/ui/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
app/ui/star_empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
app/ui/yellow-circle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

97
app/utilities.py Executable file
View File

@ -0,0 +1,97 @@
#!/usr/bin/env python
# Standard library imports
import os
# PyQt imports
# Third party imports
from sqlalchemy.orm.session import Session
# App imports
from config import Config
from helpers import (
get_tags,
)
from log import log
from models import Tracks
def check_db(session: Session) -> None:
"""
Database consistency check.
A report is generated if issues are found, but there are no automatic
corrections made.
Search for tracks that are in the music directory but not the datebase
Check all paths in database exist
"""
db_paths = set([a.path for a in Tracks.get_all(session)])
os_paths_list = []
for root, _dirs, files in os.walk(Config.ROOT):
for f in files:
path = os.path.join(root, f)
ext = os.path.splitext(f)[1]
if ext in [".flac", ".mp3"]:
os_paths_list.append(path)
os_paths = set(os_paths_list)
# Find any files in music directory that are not in database
files_not_in_db = list(os_paths - db_paths)
# Find paths in database missing in music directory
paths_not_found = []
missing_file_count = 0
more_files_to_report = False
for path in list(db_paths - os_paths):
if missing_file_count >= Config.MAX_MISSING_FILES_TO_REPORT:
more_files_to_report = True
break
missing_file_count += 1
track = Tracks.get_by_path(session, path)
if not track:
# This shouldn't happen as we're looking for paths in
# database that aren't in filesystem, but just in case...
log.error(f"update_db: {path} not found in db")
continue
paths_not_found.append(track)
# Output messages (so if running via cron, these will get sent to
# user)
if files_not_in_db:
print("Files in music directory but not in database")
print("--------------------------------------------")
print("\n".join(files_not_in_db))
print("\n")
if paths_not_found:
print("Invalid paths in database")
print("-------------------------")
for t in paths_not_found:
print(
f"""
Track ID: {t.id}
Path: {t.path}
Title: {t.title}
Artist: {t.artist}
"""
)
if more_files_to_report:
print("There were more paths than listed that were not found")
def update_bitrates(session: Session) -> None:
"""
Update bitrates on all tracks in database
"""
for track in Tracks.get_all(session):
try:
t = get_tags(track.path)
track.bitrate = t.bitrate
except FileNotFoundError:
continue

29
app/vlcmanager.py Normal file
View File

@ -0,0 +1,29 @@
# Standard library imports
# PyQt imports
# Third party imports
import vlc # type: ignore
# App imports
class VLCManager:
"""
Singleton class to ensure we only ever have one vlc Instance
"""
__instance = None
def __init__(self) -> None:
if VLCManager.__instance is None:
self.vlc_instance = vlc.Instance()
VLCManager.__instance = self
else:
raise Exception("Attempted to create a second VLCManager instance")
@staticmethod
def get_instance() -> vlc.Instance:
if VLCManager.__instance is None:
VLCManager()
return VLCManager.__instance

190
archive/DragAndDropReference.py Executable file
View File

@ -0,0 +1,190 @@
#!/usr/bin/python3
# vim: set expandtab tabstop=4 shiftwidth=4:
# PyQt Functionality Snippet by Apocalyptech
# "Licensed" in the Public Domain under CC0 1.0 Universal (CC0 1.0)
# Public Domain Dedication. Use it however you like!
#
# https://creativecommons.org/publicdomain/zero/1.0/
# https://creativecommons.org/publicdomain/zero/1.0/legalcode
from PyQt6 import QtWidgets, QtCore
# class MyModel(QtGui.QStandardItemModel):
class MyModel(QtCore.QAbstractTableModel):
def __init__(self, parent=None):
super().__init__(parent)
def columnCount(self, parent=None):
return 5
def rowCount(self, parent=None):
return 20
# def headerData(self, column: int, orientation, role: QtCore.Qt.ItemDataRole):
# return (('Regex', 'Category')[column]
# if role == QtCore.Qt.DisplayRole and orientation == QtCore.Qt.Horizontal
# else None)
def headerData(self, column, orientation, role):
if role == QtCore.Qt.ItemDataRole.DisplayRole and orientation == QtCore.Qt.Orientation.Horizontal:
return f"{column=}"
return None
def data(self, index: QtCore.QModelIndex, role: QtCore.Qt.ItemDataRole):
if not index.isValid() or role not in {
QtCore.Qt.ItemDataRole.DisplayRole,
QtCore.Qt.ItemDataRole.EditRole,
}:
return None
# return (self._data[index.row()][index.column()] if index.row() < len(self._data) else
# "edit me" if role == QtCore.Qt.DisplayRole else "")
# def data(self, index, role):
# if not index.isValid() or role not in [QtCore.Qt.DisplayRole,
# QtCore.Qt.EditRole]:
# return None
# return (self._data[index.row()][index.column()] if index.row() < len(self._data) else
# "edit me" if role == QtCore.Qt.DisplayRole else "")
row = index.row()
column = index.column()
return f"Row {row}, Col {column}"
def flags(self, index: QtCore.QModelIndex) -> QtCore.Qt.ItemFlag:
# https://doc.qt.io/qt-5/qt.html#ItemFlag-enum
if not index.isValid():
return QtCore.Qt.ItemFlag.ItemIsEnabled
if index.row() < 20:
return (
QtCore.Qt.ItemFlag.ItemIsEnabled
| QtCore.Qt.ItemFlag.ItemIsEditable
| QtCore.Qt.ItemFlag.ItemIsSelectable
| QtCore.Qt.ItemFlag.ItemIsDragEnabled
)
return QtCore.Qt.ItemFlag.ItemIsEnabled | QtCore.Qt.ItemFlag.ItemIsEditable
# def flags(self, index):
# if not index.isValid():
# return QtCore.Qt.ItemIsDropEnabled
# if index.row() < 5:
# return (
# QtCore.Qt.ItemIsEnabled
# | QtCore.Qt.ItemIsEditable
# | QtCore.Qt.ItemIsSelectable
# | QtCore.Qt.ItemIsDragEnabled
# )
# return QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsEditable
# def supportedDragOptions(self):
# return QtCore.Qt.MoveAction | QtCore.Qt.CopyAction
# def supportedDropActions(self) -> bool:
# return QtCore.Qt.MoveAction | QtCore.Qt.CopyAction
def relocateRow(self, row_source, row_target) -> None:
return
row_a, row_b = max(row_source, row_target), min(row_source, row_target)
self.beginMoveRows(
QtCore.QModelIndex(), row_a, row_a, QtCore.QModelIndex(), row_b
)
self._data.insert(row_target, self._data.pop(row_source))
self.endMoveRows()
def supportedDropActions(self):
return QtCore.Qt.DropAction.MoveAction | QtCore.Qt.DropAction.CopyAction
# def relocateRow(self, src, dst):
# print("relocateRow")
# def dropMimeData(self, data, action, row, col, parent):
# """
# Always move the entire row, and don't allow column "shifting"
# """
# # return super().dropMimeData(data, action, row, 0, parent)
# print("dropMimeData")
# super().dropMimeData(data, action, row, col, parent)
class MyStyle(QtWidgets.QProxyStyle):
def drawPrimitive(self, element, option, painter, widget=None):
"""
Draw a line across the entire row rather than just the column
we're hovering over. This may not always work depending on global
style - for instance I think it won't work on OSX.
"""
if element == QtWidgets.QStyle.PrimitiveElement.PE_IndicatorItemViewItemDrop and not option.rect.isNull():
option_new = QtWidgets.QStyleOption(option)
option_new.rect.setLeft(0)
if widget:
option_new.rect.setRight(widget.width())
option = option_new
super().drawPrimitive(element, option, painter, widget)
class MyTableView(QtWidgets.QTableView):
def __init__(self, parent):
super().__init__(parent)
self.verticalHeader().hide()
self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
self.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)
self.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove)
self.setDragDropOverwriteMode(False)
self.setAcceptDrops(True)
# self.horizontalHeader().hide()
# self.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
# self.setShowGrid(False)
# Set our custom style - this draws the drop indicator across the whole row
self.setStyle(MyStyle())
# Set our custom model - this prevents row "shifting"
# self.model = MyModel()
# self.setModel(self.model)
self.setModel(MyModel())
# for (idx, data) in enumerate(['foo', 'bar', 'baz']):
# item_1 = QtGui.QStandardItem('Item {}'.format(idx))
# item_1.setEditable(False)
# item_1.setDropEnabled(False)
# item_2 = QtGui.QStandardItem(data)
# item_2.setEditable(False)
# item_2.setDropEnabled(False)
# self.model.appendRow([item_1, item_2])
def dropEvent(self, event):
if event.source() is not self or (
event.dropAction() != QtCore.Qt.DropAction.MoveAction
and self.dragDropMode() != QtWidgets.QAbstractItemView.InternalMove
):
super().dropEvent(event)
from_rows = list(set([a.row() for a in self.selectedIndexes()]))
to_row = self.indexAt(event.position().toPoint()).row()
if (
0 <= min(from_rows) <= self.model().rowCount()
and 0 <= max(from_rows) <= self.model().rowCount()
and 0 <= to_row <= self.model().rowCount()
):
print(f"move_rows({from_rows=}, {to_row=})")
event.accept()
super().dropEvent(event)
class Testing(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
view = MyTableView(self)
view.setModel(MyModel())
self.setCentralWidget(view)
self.show()
if __name__ == "__main__":
app = QtWidgets.QApplication([])
test = Testing()
raise SystemExit(app.exec())

View File

@ -1,11 +1,11 @@
#!/usr/bin/python3
from datetime import datetime, timedelta
import datetime as dt
from threading import Timer
from pydub import AudioSegment
from time import sleep
from timeloop import Timeloop
import vlc
from timeloop import Timeloop # type: ignore
import vlc # type: ignore
class RepeatedTimer(object):
@ -49,9 +49,9 @@ def leading_silence(audio_segment, silence_threshold=-50.0, chunk_size=10):
trim_ms = 0 # ms
assert chunk_size > 0 # to avoid infinite loop
while (
audio_segment[trim_ms:trim_ms + chunk_size].dBFS < silence_threshold
and trim_ms < len(audio_segment)):
while audio_segment[
trim_ms : trim_ms + chunk_size
].dBFS < silence_threshold and trim_ms < len(audio_segment):
trim_ms += chunk_size
# if there is no end it should return the length of the segment
@ -72,8 +72,9 @@ def significant_fade(audio_segment, fade_threshold=-20.0, chunk_size=10):
segment_length = audio_segment.duration_seconds * 1000 # ms
trim_ms = segment_length - chunk_size
while (
audio_segment[trim_ms:trim_ms + chunk_size].dBFS < fade_threshold
and trim_ms > 0):
audio_segment[trim_ms : trim_ms + chunk_size].dBFS < fade_threshold
and trim_ms > 0
):
trim_ms -= chunk_size
# if there is no trailing silence, return lenght of track (it's less
@ -94,8 +95,9 @@ def trailing_silence(audio_segment, silence_threshold=-50.0, chunk_size=10):
segment_length = audio_segment.duration_seconds * 1000 # ms
trim_ms = segment_length - chunk_size
while (
audio_segment[trim_ms:trim_ms + chunk_size].dBFS < silence_threshold
and trim_ms > 0):
audio_segment[trim_ms : trim_ms + chunk_size].dBFS < silence_threshold
and trim_ms > 0
):
trim_ms -= chunk_size
# if there is no trailing silence, return lenght of track (it's less
@ -124,15 +126,17 @@ def update_progress(player, talk_at, silent_at):
remaining_time = total_time - elapsed_time
talk_time = remaining_time - (total_time - talk_at)
silent_time = remaining_time - (total_time - silent_at)
end_time = (datetime.now() + timedelta(
milliseconds=remaining_time)).strftime("%H:%M:%S")
end_time = (dt.datetime.now() + timedelta(milliseconds=remaining_time)).strftime(
"%H:%M:%S"
)
print(
f"\t{ms_to_mmss(elapsed_time)}/"
f"{ms_to_mmss(total_time)}\t\t"
f"Talk in: {ms_to_mmss(talk_time)} "
f"Silent in: {ms_to_mmss(silent_time)} "
f"Ends at: {end_time} [{ms_to_mmss(remaining_time)}]"
, end="\r")
f"Ends at: {end_time} [{ms_to_mmss(remaining_time)}]",
end="\r",
)
# Print name of current song, print name of next song. Play current when
@ -163,21 +167,21 @@ def test():
test()
# next_song = get_next_song
#
#
# def play_track():
# r = run_aud_cmd("--current-song-length
#
#
#
#
#
#
# def play():
# play_track()
# songtimer_start()
#
#
#
#
# print("Start playing in 3 seconds")
#
#
# sleep(3)
#
#
# play()

84
archive/db_experiments.py Executable file
View File

@ -0,0 +1,84 @@
#!/usr/bin/env python3
from sqlalchemy import create_engine, String, update, bindparam, case
from sqlalchemy.orm import (
DeclarativeBase,
Mapped,
mapped_column,
sessionmaker,
scoped_session,
)
from typing import Generator
from contextlib import contextmanager
db_url = "sqlite:////tmp/rhys.db"
class Base(DeclarativeBase):
pass
class Rhys(Base):
__tablename__ = "rhys"
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
ref_number: Mapped[int] = mapped_column()
name: Mapped[str] = mapped_column(String(256), index=True)
def __init__(self, session, ref_number: int, name: str) -> None:
self.ref_number = ref_number
self.name = name
session.add(self)
session.flush()
@contextmanager
def Session() -> Generator[scoped_session, None, None]:
Session = scoped_session(sessionmaker(bind=engine))
yield Session
Session.commit()
Session.close()
engine = create_engine(db_url)
Base.metadata.create_all(engine)
inital_number_of_records = 10
def move_rows(session):
new_row = 6
with Session() as session:
# new_record = Rhys(session, new_row, f"new {new_row=}")
# Move rows
stmt = (
update(Rhys)
.where(Rhys.ref_number > new_row)
# .where(Rhys.id.in_(session.query(Rhys.id).order_by(Rhys.id.desc())))
.values({Rhys.ref_number: Rhys.ref_number + 1})
)
session.execute(stmt)
sqla_map = []
for k, v in zip(range(11), [0, 1, 2, 3, 4, 7, 8, 10, 5, 6, 9]):
sqla_map.append({"oldrow": k, "newrow": v})
# for a, b in sqla_map.items():
# print(f"{a} > {b}")
with Session() as session:
for a in range(inital_number_of_records):
_ = Rhys(session, a, f"record: {a}")
stmt = update(Rhys).values(
ref_number=case(
{item['oldrow']: item['newrow'] for item in sqla_map},
value=Rhys.ref_number
)
)
session.connection().execute(stmt, sqla_map)

101
archive/dragdrop.py Executable file
View File

@ -0,0 +1,101 @@
#!/usr/bin/env python3
# https://stackoverflow.com/questions/26227885/drag-and-drop-rows-within-qtablewidget
import sys
from PyQt6.QtWidgets import (
QTableWidget,
QAbstractItemView,
QTableWidgetItem,
QWidget,
QHBoxLayout,
QApplication,
)
from PyQt6.QtCore import Qt
class TableWidgetDragRows(QTableWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setDragEnabled(True)
self.setAcceptDrops(True)
self.viewport().setAcceptDrops(True)
self.setDragDropOverwriteMode(False)
self.setDropIndicatorShown(True)
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
self.setSelectionBehavior(QAbstractItemView.SelectionBehavior.SelectRows)
self.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
self.DropIndicatorPosition(QAbstractItemView.DropIndicatorPosition.BelowItem)
def dropEvent(self, event):
if event.source() == self:
rows = set([mi.row() for mi in self.selectedIndexes()])
targetRow = self.indexAt(event.position().toPoint()).row()
if self.dropIndicatorPosition() == QAbstractItemView.DropIndicatorPosition.BelowItem:
targetRow += 1
rows.discard(targetRow)
rows = sorted(rows)
if not rows:
return
if targetRow == -1:
targetRow = self.rowCount()
for _ in range(len(rows)):
self.insertRow(targetRow)
rowMapping = dict() # Src row to target row.
for idx, row in enumerate(rows):
if row < targetRow:
rowMapping[row] = targetRow + idx
else:
rowMapping[row + len(rows)] = targetRow + idx
colCount = self.columnCount()
for srcRow, tgtRow in sorted(rowMapping.items()):
for col in range(0, colCount):
self.setItem(tgtRow, col, self.takeItem(srcRow, col))
for row in reversed(sorted(rowMapping.keys())):
self.removeRow(row)
event.accept()
return
class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
layout = QHBoxLayout()
self.setLayout(layout)
self.table_widget = TableWidgetDragRows()
layout.addWidget(self.table_widget)
# setup table widget
self.table_widget.setColumnCount(2)
self.table_widget.setHorizontalHeaderLabels(["Type", "Name"])
items = [
("Red", "Toyota"),
("Blue", "RV"),
("Green", "Beetle"),
("Silver", "Chevy"),
("Black", "BMW"),
]
self.table_widget.setRowCount(len(items))
for i, (color, model) in enumerate(items):
item_flags = Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsDragEnabled
colour_item = QTableWidgetItem(color)
colour_item.setFlags(item_flags)
model_item = QTableWidgetItem(model)
model_item.setFlags(item_flags)
self.table_widget.setItem(i, 0, QTableWidgetItem(color))
self.table_widget.setItem(i, 1, QTableWidgetItem(model))
self.resize(400, 400)
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
window = Window()
sys.exit(app.exec())

46
archive/play.py Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env python
from pydub import AudioSegment
def fade_point(audio_segment, fade_threshold=-12, chunk_size=10):
"""
Returns the millisecond/index of the point where the fade is down to
fade_threshold and doesn't get louder again.
audio_segment - the sdlg_search_database_uiegment to find silence in
fade_threshold - the upper bound for how quiet is silent in dFBS
chunk_size - chunk size for interating over the segment in ms
"""
assert chunk_size > 0 # to avoid infinite loop
segment_length = audio_segment.duration_seconds * 1000 # ms
print(f"segment_length={int(segment_length/1000)}")
trim_ms = segment_length - chunk_size
max_vol = audio_segment.dBFS
print(f"{max_vol=}")
fade_threshold = max_vol
while (
audio_segment[trim_ms : trim_ms + chunk_size].dBFS < fade_threshold
and trim_ms > 0
): # noqa W503
trim_ms -= chunk_size
# if there is no trailing silence, return lenght of track (it's less
# the chunk_size, but for chunk_size = 10ms, this may be ignored)
print(f"Fade last {int(segment_length - trim_ms)/1000} seconds")
# print("Shout:")
# segment = AudioSegment.from_mp3("../archive/shout.mp3")
# fade_point(segment)
# print("Champagne:")
# segment = AudioSegment.from_mp3("../archive/champ.mp3")
# fade_point(segment)
# print("Be good:")
# segment = AudioSegment.from_mp3("../archive/wibg.mp3")
# fade_point(segment)
print("Be good:")
segment = AudioSegment.from_file("/tmp/bia.flac", "flac")
fade_point(segment)

125
archive/proxymodel.py Executable file
View File

@ -0,0 +1,125 @@
#!/usr/bin/env python
import sys
from PyQt6.QtCore import (Qt, QAbstractTableModel, QModelIndex, QSortFilterProxyModel)
from PyQt6.QtWidgets import (QApplication, QMainWindow, QTableView, QLineEdit, QVBoxLayout, QWidget)
class CustomTableModel(QAbstractTableModel):
def __init__(self, data):
super().__init__()
self._data = data
def rowCount(self, parent=QModelIndex()):
return len(self._data)
def columnCount(self, parent=QModelIndex()):
return 2 # Row number and data
def data(self, index, role=Qt.ItemDataRole.DisplayRole):
if role == Qt.ItemDataRole.DisplayRole:
row, col = index.row(), index.column()
if col == 0:
return row + 1 # Row number (1-based index)
elif col == 1:
return self._data[row]
def setData(self, index, value, role=Qt.ItemDataRole.EditRole):
if role == Qt.ItemDataRole.EditRole and index.isValid():
self._data[index.row()] = value
self.dataChanged.emit(index, index, [Qt.ItemDataRole.EditRole])
return True
return False
def flags(self, index):
default_flags = Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEnabled
if index.isValid():
return default_flags | Qt.ItemFlag.ItemIsDragEnabled | Qt.ItemFlag.ItemIsDropEnabled
return default_flags | Qt.ItemFlag.ItemIsDropEnabled
def removeRow(self, row):
self.beginRemoveRows(QModelIndex(), row, row)
self._data.pop(row)
self.endRemoveRows()
def insertRow(self, row, value):
self.beginInsertRows(QModelIndex(), row, row)
self._data.insert(row, value)
self.endInsertRows()
def moveRows(self, sourceParent, sourceRow, count, destinationParent, destinationRow):
if sourceRow < destinationRow:
destinationRow -= 1
self.beginMoveRows(sourceParent, sourceRow, sourceRow, destinationParent, destinationRow)
row_data = self._data.pop(sourceRow)
self._data.insert(destinationRow, row_data)
self.endMoveRows()
return True
class ProxyModel(QSortFilterProxyModel):
def __init__(self):
super().__init__()
self.filterString = ""
def setFilterString(self, text):
self.filterString = text
self.invalidateFilter()
def filterAcceptsRow(self, source_row, source_parent):
if self.filterString:
data = self.sourceModel().data(self.sourceModel().index(source_row, 1), Qt.ItemDataRole.DisplayRole)
return self.filterString in str(data)
return True
class TableView(QTableView):
def __init__(self, model):
super().__init__()
self.setModel(model)
self.setDragDropMode(QTableView.DragDropMode.InternalMove)
self.setSelectionBehavior(QTableView.SelectionBehavior.SelectRows)
self.setSortingEnabled(False)
self.setDragDropOverwriteMode(False)
def dropEvent(self, event):
source_index = self.indexAt(event.pos())
if not source_index.isValid():
return
destination_row = source_index.row()
dragged_row = self.currentIndex().row()
if dragged_row != destination_row:
self.model().sourceModel().moveRows(QModelIndex(), dragged_row, 1, QModelIndex(), destination_row)
super().dropEvent(event)
self.model().layoutChanged.emit() # Refresh model to update row numbers
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.data = ["dog", "hog", "don", "cat", "bat"]
self.baseModel = CustomTableModel(self.data)
self.proxyModel = ProxyModel()
self.proxyModel.setSourceModel(self.baseModel)
self.view = TableView(self.proxyModel)
self.filterLineEdit = QLineEdit()
self.filterLineEdit.setPlaceholderText("Filter by substring")
self.filterLineEdit.textChanged.connect(self.proxyModel.setFilterString)
layout = QVBoxLayout()
layout.addWidget(self.filterLineEdit)
layout.addWidget(self.view)
container = QWidget()
container.setLayout(layout)
self.setCentralWidget(container)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())

View File

@ -0,0 +1,98 @@
#!/usr/bin/env python
# vim: set expandtab tabstop=4 shiftwidth=4:
# PyQt Functionality Snippet by Apocalyptech
# "Licensed" in the Public Domain under CC0 1.0 Universal (CC0 1.0)
# Public Domain Dedication. Use it however you like!
#
# https://creativecommons.org/publicdomain/zero/1.0/
# https://creativecommons.org/publicdomain/zero/1.0/legalcode
import sys
from PyQt5 import QtWidgets, QtGui, QtCore
class MyModel(QtGui.QStandardItemModel):
def dropMimeData(self, data, action, row, col, parent):
"""
Always move the entire row, and don't allow column "shifting"
"""
return super().dropMimeData(data, action, row, 0, parent)
class MyStyle(QtWidgets.QProxyStyle):
def drawPrimitive(self, element, option, painter, widget=None):
"""
Draw a line across the entire row rather than just the column
we're hovering over. This may not always work depending on global
style - for instance I think it won't work on OSX.
"""
if element == self.PE_IndicatorItemViewItemDrop and not option.rect.isNull():
option_new = QtWidgets.QStyleOption(option)
option_new.rect.setLeft(0)
if widget:
option_new.rect.setRight(widget.width())
option = option_new
super().drawPrimitive(element, option, painter, widget)
class MyTableView(QtWidgets.QTableView):
def __init__(self, parent):
super().__init__(parent)
self.verticalHeader().hide()
self.horizontalHeader().hide()
self.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
self.setSelectionBehavior(self.SelectRows)
self.setSelectionMode(self.SingleSelection)
self.setShowGrid(False)
self.setDragDropMode(self.InternalMove)
self.setDragDropOverwriteMode(False)
# Set our custom style - this draws the drop indicator across the whole row
self.setStyle(MyStyle())
# Set our custom model - this prevents row "shifting"
self.model = MyModel()
self.setModel(self.model)
for (idx, data) in enumerate(['foo', 'bar', 'baz']):
item_1 = QtGui.QStandardItem('Item {}'.format(idx))
item_1.setEditable(False)
item_1.setDropEnabled(False)
item_2 = QtGui.QStandardItem(data)
item_2.setEditable(False)
item_2.setDropEnabled(False)
self.model.appendRow([item_1, item_2])
class Testing(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
# Main widget
w = QtWidgets.QWidget()
l = QtWidgets.QVBoxLayout()
w.setLayout(l)
self.setCentralWidget(w)
# spacer
l.addWidget(QtWidgets.QLabel('top'), 1)
# Combo Box
l.addWidget(MyTableView(self))
# spacer
l.addWidget(QtWidgets.QLabel('bottom'), 1)
# A bit of window housekeeping
self.resize(400, 400)
self.setWindowTitle('Testing')
self.show()
if __name__ == '__main__':
app = QtWidgets.QApplication([])
test = Testing()
sys.exit(app.exec_())

View File

@ -1,5 +1,3 @@
# tl = Timeloop()
#
#
@ -48,34 +46,34 @@
# rt.stop() # better in a try/finally block to make sure the program ends!
# print("End")
#def kae2(self, index):
# print(f"table header click, index={index}")
# def kae2(self, index):
# print(f"table header click, index={index}")
#def kae(self, a, b, c):
# self.data.append(f"a={a}, b={b}, c={c}")
# def kae(self, a, b, c):
# self.data.append(f"a={a}, b={b}, c={c}")
#def mousePressEvent(self, QMouseEvent):
# print("mouse press")
# def mousePressEvent(self, QMouseEvent):
# print("mouse press")
#def mouseReleaseEvent(self, QMouseEvent):
# print("mouse release")
# # QMessageBox.about(
# # self,
# # "About Sample Editor",
# # "\n".join(self.data)
# # )
#def eventFilter(self, obj, event):
# # you could be doing different groups of actions
# # for different types of widgets and either filtering
# # the event or not.
# # Here we just check if its one of the layout widgets
# # if self.layout.indexOf(obj) != -1:
# # print(f"event received: {event.type()}")
# if event.type() == QEvent.MouseButtonPress:
# print("Widget click")
# # if I returned True right here, the event
# # would be filtered and not reach the obj,
# # meaning that I decided to handle it myself
# def mouseReleaseEvent(self, QMouseEvent):
# print("mouse release")
# # QMessageBox.about(
# # self,
# # "About Sample Editor",
# # "\n".join(self.data)
# # )
# def eventFilter(self, obj, event):
# # you could be doing different groups of actions
# # for different types of widgets and either filtering
# # the event or not.
# # Here we just check if its one of the layout widgets
# # if self.layout.indexOf(obj) != -1:
# # print(f"event received: {event.type()}")
# if event.type() == QEvent.MouseButtonPress:
# print("Widget click")
# # if I returned True right here, the event
# # would be filtered and not reach the obj,
# # meaning that I decided to handle it myself
# # regardless, just do the default
# return super().eventFilter(obj, event)
# # regardless, just do the default
# return super().eventFilter(obj, event)

BIN
archive/todo/.DS_Store vendored Normal file

Binary file not shown.

1
archive/todo/data.db Normal file
View File

@ -0,0 +1 @@
[[false, "My first todo"], [true, "My second todo"], [true, "Another todo"], [false, "as"]]

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>275</width>
<height>314</height>
</rect>
</property>
<property name="windowTitle">
<string>Todo</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListView" name="todoView">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="deleteButton">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="completeButton">
<property name="text">
<string>Complete</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLineEdit" name="todoEdit"/>
</item>
<item>
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add Todo</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>275</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

BIN
archive/todo/tick.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

104
archive/todo/todo.py Normal file
View File

@ -0,0 +1,104 @@
import sys
import datetime
import json
from PyQt5 import QtCore, QtGui, QtWidgets, uic
from PyQt5.QtCore import Qt
qt_creator_file = "mainwindow.ui"
Ui_MainWindow, QtBaseClass = uic.loadUiType(qt_creator_file)
tick = QtGui.QImage("tick.png")
class TodoModel(QtCore.QAbstractListModel):
def __init__(self, *args, todos=None, **kwargs):
super(TodoModel, self).__init__(*args, **kwargs)
self.todos = todos or []
def data(self, index, role):
if role == Qt.DisplayRole:
_, text = self.todos[index.row()]
return text
if role == Qt.DecorationRole:
status, _ = self.todos[index.row()]
if status:
return tick
def rowCount(self, index):
return len(self.todos)
def flags(self, index):
print(datetime.datetime.now().time().strftime("%H:%M:%S"))
return super().flags(index)
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.model = TodoModel()
self.load()
self.todoView.setModel(self.model)
self.addButton.pressed.connect(self.add)
self.deleteButton.pressed.connect(self.delete)
self.completeButton.pressed.connect(self.complete)
def add(self):
"""
Add an item to our todo list, getting the text from the QLineEdit .todoEdit
and then clearing it.
"""
text = self.todoEdit.text()
if text: # Don't add empty strings.
# Access the list via the model.
self.model.todos.append((False, text))
# Trigger refresh.
self.model.layoutChanged.emit()
# Empty the input
self.todoEdit.setText("")
self.save()
def delete(self):
indexes = self.todoView.selectedIndexes()
if indexes:
# Indexes is a list of a single item in single-select mode.
index = indexes[0]
# Remove the item and refresh.
del self.model.todos[index.row()]
self.model.layoutChanged.emit()
# Clear the selection (as it is no longer valid).
self.todoView.clearSelection()
self.save()
def complete(self):
indexes = self.todoView.selectedIndexes()
if indexes:
index = indexes[0]
row = index.row()
status, text = self.model.todos[row]
self.model.todos[row] = (True, text)
# .dataChanged takes top-left and bottom right, which are equal
# for a single selection.
self.model.dataChanged.emit(index, index)
# Clear the selection (as it is no longer valid).
self.todoView.clearSelection()
self.save()
def load(self):
try:
with open("data.db", "r") as f:
self.model.todos = json.load(f)
except Exception:
pass
def save(self):
with open("data.db", "w") as f:
data = json.dump(self.model.todos, f)
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()

22
archive/wheel_events.txt Normal file
View File

@ -0,0 +1,22 @@
diff --git a/app/musicmuster.py b/app/musicmuster.py
index d90644b..b53f3a8 100755
--- a/app/musicmuster.py
+++ b/app/musicmuster.py
@@ -1803,6 +1803,17 @@ class Window(QMainWindow, Ui_MainWindow):
else:
self.hdrNextTrack.setText("")
+ def wheelEvent(self, event):
+ """
+ Detect wheel events
+ """
+
+ delta = event.angleDelta().y() / 120
+ if delta > 0:
+ print("musicmuster.py Scroll Up")
+ else:
+ print("musicmuster.py Scroll Down")
+
class CartDialog(QDialog):
"""Edit cart details"""

20
docs/Makefile Normal file
View File

@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

BIN
docs/build/doctrees/development.doctree vendored Normal file

Binary file not shown.

BIN
docs/build/doctrees/environment.pickle vendored Normal file

Binary file not shown.

BIN
docs/build/doctrees/index.doctree vendored Normal file

Binary file not shown.

BIN
docs/build/doctrees/installation.doctree vendored Normal file

Binary file not shown.

BIN
docs/build/doctrees/introduction.doctree vendored Normal file

Binary file not shown.

BIN
docs/build/doctrees/reference.doctree vendored Normal file

Binary file not shown.

BIN
docs/build/doctrees/tutorial.doctree vendored Normal file

Binary file not shown.

4
docs/build/html/.buildinfo vendored Normal file
View File

@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: dcac9a6ec03f5a33392ad4b5bcf42637
tags: 645f666f9bcd5a90fca523b33c5a78b7

View File

@ -0,0 +1,2 @@
Development
===========

25
docs/build/html/_sources/index.rst.txt vendored Normal file
View File

@ -0,0 +1,25 @@
.. MusicMuster documentation master file, created by
sphinx-quickstart on Sun Jul 2 17:58:44 2023.
Welcome to MusicMuster's documentation!
=======================================
**MusicMuster** is a music player targeted at the production of live
internet radio shows.
Contents
--------
.. toctree::
introduction
installation
tutorial
reference
development
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@ -0,0 +1,2 @@
Installation
============

View File

@ -0,0 +1,87 @@
Introduction
============
Why MusicMuster?
----------------
In January 2022 I started my show on `Mixcloud
<https://www.mixcloud.com/KeithsMusicBox/>`. Until then, my show had
been on an internet radio station which required me to use a Windows
playout system. As I only use Linux, I had to set up a Windows PC
specifically for that purpose. The system I had to use had what I felt
were shortcomings in various areas.
Once I moved to Mixcloud I searched for a Linux equivalent that didn't
have the same shortcomings but was unable to find one that met my
criteria. I decided to see how practical it would be to write my own,
and MusicMuster was born.
What is MusicMuster?
--------------------
It is a Linux-based music player. Whilst it could be used as a general
home music player, there are much better applications for that role.
**MusicMuster** has been specifically designed to support the
production of live internet radio shows.
Features
--------
* Database backed
* Can be almost entirely keyboard driven
* Open multiple playlists in tabs
* Play tracks from any playlist
* Add notes/comments to tracks on playlist
* Automatatic colour-coding of notes/comments according to content
* Preview tracks before playing to audience
* Time of day clock
* Elapsed track time counter
* Time to run until track starts to fade
* Time to run until track is silent
* Graphic of volume from 5 seconds (configurable) before fade until
track is silent
* Optionally hide played tracks in playlist
* Button to drop playout volume by 3dB for talkover
* Playlist displays:
* Title
* Artist
* Length of track (mm:ss)
* Estimated start time of track
* Estimated end time of track
* When track was last played
* Bits per second (bitrate) of track
* Length of leading silence in recording before track starts
* Total track length of arbitrary sections of tracks
* Commands that are sent to OBS Studio (eg, for automated scene
changes)
* Playlist templates
* Move selected or unplayed tracks between playlists
* Download CSV of tracks played between arbitrary dates/times
* Search for tracks by title or artist
* Automatic search of current and next track in Wikipedia
* Optional search of any track in Wikipedia
* Optional search of any track in Songfacts
Requirements
------------
.. note:: MusicMuster has only been tested on Debian 12, "Bookworm";
however, it should run on most contemporary Linux systems.
The :doc:`installation` page explains how to build MusicMuster in its
own environment which will automatcally install all requirements
except the database. The current version of MusicMuster uses MariaDB
version 10.11; however, any recent version of MariaDB should suffice.
MusicMuster is a Python 3 application and requires Python 3.8 or
later.
Feedback, bugs, etc
-------------------
Please send to keith@midnighthax.com
Keith Edmunds,
July 2023

View File

@ -0,0 +1,2 @@
Reference
=========

View File

@ -0,0 +1,2 @@
Tutorial
========

703
docs/build/html/_static/alabaster.css vendored Normal file
View File

@ -0,0 +1,703 @@
@import url("basic.css");
/* -- page layout ----------------------------------------------------------- */
body {
font-family: Georgia, serif;
font-size: 17px;
background-color: #fff;
color: #000;
margin: 0;
padding: 0;
}
div.document {
width: 940px;
margin: 30px auto 0 auto;
}
div.documentwrapper {
float: left;
width: 100%;
}
div.bodywrapper {
margin: 0 0 0 220px;
}
div.sphinxsidebar {
width: 220px;
font-size: 14px;
line-height: 1.5;
}
hr {
border: 1px solid #B1B4B6;
}
div.body {
background-color: #fff;
color: #3E4349;
padding: 0 30px 0 30px;
}
div.body > .section {
text-align: left;
}
div.footer {
width: 940px;
margin: 20px auto 30px auto;
font-size: 14px;
color: #888;
text-align: right;
}
div.footer a {
color: #888;
}
p.caption {
font-family: inherit;
font-size: inherit;
}
div.relations {
display: none;
}
div.sphinxsidebar a {
color: #444;
text-decoration: none;
border-bottom: 1px dotted #999;
}
div.sphinxsidebar a:hover {
border-bottom: 1px solid #999;
}
div.sphinxsidebarwrapper {
padding: 18px 10px;
}
div.sphinxsidebarwrapper p.logo {
padding: 0;
margin: -10px 0 0 0px;
text-align: center;
}
div.sphinxsidebarwrapper h1.logo {
margin-top: -10px;
text-align: center;
margin-bottom: 5px;
text-align: left;
}
div.sphinxsidebarwrapper h1.logo-name {
margin-top: 0px;
}
div.sphinxsidebarwrapper p.blurb {
margin-top: 0;
font-style: normal;
}
div.sphinxsidebar h3,
div.sphinxsidebar h4 {
font-family: Georgia, serif;
color: #444;
font-size: 24px;
font-weight: normal;
margin: 0 0 5px 0;
padding: 0;
}
div.sphinxsidebar h4 {
font-size: 20px;
}
div.sphinxsidebar h3 a {
color: #444;
}
div.sphinxsidebar p.logo a,
div.sphinxsidebar h3 a,
div.sphinxsidebar p.logo a:hover,
div.sphinxsidebar h3 a:hover {
border: none;
}
div.sphinxsidebar p {
color: #555;
margin: 10px 0;
}
div.sphinxsidebar ul {
margin: 10px 0;
padding: 0;
color: #000;
}
div.sphinxsidebar ul li.toctree-l1 > a {
font-size: 120%;
}
div.sphinxsidebar ul li.toctree-l2 > a {
font-size: 110%;
}
div.sphinxsidebar input {
border: 1px solid #CCC;
font-family: Georgia, serif;
font-size: 1em;
}
div.sphinxsidebar hr {
border: none;
height: 1px;
color: #AAA;
background: #AAA;
text-align: left;
margin-left: 0;
width: 50%;
}
div.sphinxsidebar .badge {
border-bottom: none;
}
div.sphinxsidebar .badge:hover {
border-bottom: none;
}
/* To address an issue with donation coming after search */
div.sphinxsidebar h3.donation {
margin-top: 10px;
}
/* -- body styles ----------------------------------------------------------- */
a {
color: #004B6B;
text-decoration: underline;
}
a:hover {
color: #6D4100;
text-decoration: underline;
}
div.body h1,
div.body h2,
div.body h3,
div.body h4,
div.body h5,
div.body h6 {
font-family: Georgia, serif;
font-weight: normal;
margin: 30px 0px 10px 0px;
padding: 0;
}
div.body h1 { margin-top: 0; padding-top: 0; font-size: 240%; }
div.body h2 { font-size: 180%; }
div.body h3 { font-size: 150%; }
div.body h4 { font-size: 130%; }
div.body h5 { font-size: 100%; }
div.body h6 { font-size: 100%; }
a.headerlink {
color: #DDD;
padding: 0 4px;
text-decoration: none;
}
a.headerlink:hover {
color: #444;
background: #EAEAEA;
}
div.body p, div.body dd, div.body li {
line-height: 1.4em;
}
div.admonition {
margin: 20px 0px;
padding: 10px 30px;
background-color: #EEE;
border: 1px solid #CCC;
}
div.admonition tt.xref, div.admonition code.xref, div.admonition a tt {
background-color: #FBFBFB;
border-bottom: 1px solid #fafafa;
}
div.admonition p.admonition-title {
font-family: Georgia, serif;
font-weight: normal;
font-size: 24px;
margin: 0 0 10px 0;
padding: 0;
line-height: 1;
}
div.admonition p.last {
margin-bottom: 0;
}
div.highlight {
background-color: #fff;
}
dt:target, .highlight {
background: #FAF3E8;
}
div.warning {
background-color: #FCC;
border: 1px solid #FAA;
}
div.danger {
background-color: #FCC;
border: 1px solid #FAA;
-moz-box-shadow: 2px 2px 4px #D52C2C;
-webkit-box-shadow: 2px 2px 4px #D52C2C;
box-shadow: 2px 2px 4px #D52C2C;
}
div.error {
background-color: #FCC;
border: 1px solid #FAA;
-moz-box-shadow: 2px 2px 4px #D52C2C;
-webkit-box-shadow: 2px 2px 4px #D52C2C;
box-shadow: 2px 2px 4px #D52C2C;
}
div.caution {
background-color: #FCC;
border: 1px solid #FAA;
}
div.attention {
background-color: #FCC;
border: 1px solid #FAA;
}
div.important {
background-color: #EEE;
border: 1px solid #CCC;
}
div.note {
background-color: #EEE;
border: 1px solid #CCC;
}
div.tip {
background-color: #EEE;
border: 1px solid #CCC;
}
div.hint {
background-color: #EEE;
border: 1px solid #CCC;
}
div.seealso {
background-color: #EEE;
border: 1px solid #CCC;
}
div.topic {
background-color: #EEE;
}
p.admonition-title {
display: inline;
}
p.admonition-title:after {
content: ":";
}
pre, tt, code {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
font-size: 0.9em;
}
.hll {
background-color: #FFC;
margin: 0 -12px;
padding: 0 12px;
display: block;
}
img.screenshot {
}
tt.descname, tt.descclassname, code.descname, code.descclassname {
font-size: 0.95em;
}
tt.descname, code.descname {
padding-right: 0.08em;
}
img.screenshot {
-moz-box-shadow: 2px 2px 4px #EEE;
-webkit-box-shadow: 2px 2px 4px #EEE;
box-shadow: 2px 2px 4px #EEE;
}
table.docutils {
border: 1px solid #888;
-moz-box-shadow: 2px 2px 4px #EEE;
-webkit-box-shadow: 2px 2px 4px #EEE;
box-shadow: 2px 2px 4px #EEE;
}
table.docutils td, table.docutils th {
border: 1px solid #888;
padding: 0.25em 0.7em;
}
table.field-list, table.footnote {
border: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
table.footnote {
margin: 15px 0;
width: 100%;
border: 1px solid #EEE;
background: #FDFDFD;
font-size: 0.9em;
}
table.footnote + table.footnote {
margin-top: -15px;
border-top: none;
}
table.field-list th {
padding: 0 0.8em 0 0;
}
table.field-list td {
padding: 0;
}
table.field-list p {
margin-bottom: 0.8em;
}
/* Cloned from
* https://github.com/sphinx-doc/sphinx/commit/ef60dbfce09286b20b7385333d63a60321784e68
*/
.field-name {
-moz-hyphens: manual;
-ms-hyphens: manual;
-webkit-hyphens: manual;
hyphens: manual;
}
table.footnote td.label {
width: .1px;
padding: 0.3em 0 0.3em 0.5em;
}
table.footnote td {
padding: 0.3em 0.5em;
}
dl {
margin-left: 0;
margin-right: 0;
margin-top: 0;
padding: 0;
}
dl dd {
margin-left: 30px;
}
blockquote {
margin: 0 0 0 30px;
padding: 0;
}
ul, ol {
/* Matches the 30px from the narrow-screen "li > ul" selector below */
margin: 10px 0 10px 30px;
padding: 0;
}
pre {
background: #EEE;
padding: 7px 30px;
margin: 15px 0px;
line-height: 1.3em;
}
div.viewcode-block:target {
background: #ffd;
}
dl pre, blockquote pre, li pre {
margin-left: 0;
padding-left: 30px;
}
tt, code {
background-color: #ecf0f3;
color: #222;
/* padding: 1px 2px; */
}
tt.xref, code.xref, a tt {
background-color: #FBFBFB;
border-bottom: 1px solid #fff;
}
a.reference {
text-decoration: none;
border-bottom: 1px dotted #004B6B;
}
/* Don't put an underline on images */
a.image-reference, a.image-reference:hover {
border-bottom: none;
}
a.reference:hover {
border-bottom: 1px solid #6D4100;
}
a.footnote-reference {
text-decoration: none;
font-size: 0.7em;
vertical-align: top;
border-bottom: 1px dotted #004B6B;
}
a.footnote-reference:hover {
border-bottom: 1px solid #6D4100;
}
a:hover tt, a:hover code {
background: #EEE;
}
@media screen and (max-width: 870px) {
div.sphinxsidebar {
display: none;
}
div.document {
width: 100%;
}
div.documentwrapper {
margin-left: 0;
margin-top: 0;
margin-right: 0;
margin-bottom: 0;
}
div.bodywrapper {
margin-top: 0;
margin-right: 0;
margin-bottom: 0;
margin-left: 0;
}
ul {
margin-left: 0;
}
li > ul {
/* Matches the 30px from the "ul, ol" selector above */
margin-left: 30px;
}
.document {
width: auto;
}
.footer {
width: auto;
}
.bodywrapper {
margin: 0;
}
.footer {
width: auto;
}
.github {
display: none;
}
}
@media screen and (max-width: 875px) {
body {
margin: 0;
padding: 20px 30px;
}
div.documentwrapper {
float: none;
background: #fff;
}
div.sphinxsidebar {
display: block;
float: none;
width: 102.5%;
margin: 50px -30px -20px -30px;
padding: 10px 20px;
background: #333;
color: #FFF;
}
div.sphinxsidebar h3, div.sphinxsidebar h4, div.sphinxsidebar p,
div.sphinxsidebar h3 a {
color: #fff;
}
div.sphinxsidebar a {
color: #AAA;
}
div.sphinxsidebar p.logo {
display: none;
}
div.document {
width: 100%;
margin: 0;
}
div.footer {
display: none;
}
div.bodywrapper {
margin: 0;
}
div.body {
min-height: 0;
padding: 0;
}
.rtd_doc_footer {
display: none;
}
.document {
width: auto;
}
.footer {
width: auto;
}
.footer {
width: auto;
}
.github {
display: none;
}
}
/* misc. */
.revsys-inline {
display: none!important;
}
/* Make nested-list/multi-paragraph items look better in Releases changelog
* pages. Without this, docutils' magical list fuckery causes inconsistent
* formatting between different release sub-lists.
*/
div#changelog > div.section > ul > li > p:only-child {
margin-bottom: 0;
}
/* Hide fugly table cell borders in ..bibliography:: directive output */
table.docutils.citation, table.docutils.citation td, table.docutils.citation th {
border: none;
/* Below needed in some edge cases; if not applied, bottom shadows appear */
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
/* relbar */
.related {
line-height: 30px;
width: 100%;
font-size: 0.9rem;
}
.related.top {
border-bottom: 1px solid #EEE;
margin-bottom: 20px;
}
.related.bottom {
border-top: 1px solid #EEE;
}
.related ul {
padding: 0;
margin: 0;
list-style: none;
}
.related li {
display: inline;
}
nav#rellinks {
float: right;
}
nav#rellinks li+li:before {
content: "|";
}
nav#breadcrumbs li+li:before {
content: "\00BB";
}
/* Hide certain items when printing */
@media print {
div.related {
display: none;
}
}

903
docs/build/html/_static/basic.css vendored Normal file
View File

@ -0,0 +1,903 @@
/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* -- main layout ----------------------------------------------------------- */
div.clearer {
clear: both;
}
div.section::after {
display: block;
content: '';
clear: left;
}
/* -- relbar ---------------------------------------------------------------- */
div.related {
width: 100%;
font-size: 90%;
}
div.related h3 {
display: none;
}
div.related ul {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
}
div.related li {
display: inline;
}
div.related li.right {
float: right;
margin-right: 5px;
}
/* -- sidebar --------------------------------------------------------------- */
div.sphinxsidebarwrapper {
padding: 10px 5px 0 10px;
}
div.sphinxsidebar {
float: left;
width: 230px;
margin-left: -100%;
font-size: 90%;
word-wrap: break-word;
overflow-wrap : break-word;
}
div.sphinxsidebar ul {
list-style: none;
}
div.sphinxsidebar ul ul,
div.sphinxsidebar ul.want-points {
margin-left: 20px;
list-style: square;
}
div.sphinxsidebar ul ul {
margin-top: 0;
margin-bottom: 0;
}
div.sphinxsidebar form {
margin-top: 10px;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
div.sphinxsidebar #searchbox form.search {
overflow: hidden;
}
div.sphinxsidebar #searchbox input[type="text"] {
float: left;
width: 80%;
padding: 0.25em;
box-sizing: border-box;
}
div.sphinxsidebar #searchbox input[type="submit"] {
float: left;
width: 20%;
border-left: none;
padding: 0.25em;
box-sizing: border-box;
}
img {
border: 0;
max-width: 100%;
}
/* -- search page ----------------------------------------------------------- */
ul.search {
margin: 10px 0 0 20px;
padding: 0;
}
ul.search li {
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
}
ul.search li a {
font-weight: bold;
}
ul.search li p.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
}
ul.keywordmatches li.goodmatch a {
font-weight: bold;
}
/* -- index page ------------------------------------------------------------ */
table.contentstable {
width: 90%;
margin-left: auto;
margin-right: auto;
}
table.contentstable p.biglink {
line-height: 150%;
}
a.biglink {
font-size: 1.3em;
}
span.linkdescr {
font-style: italic;
padding-top: 5px;
font-size: 90%;
}
/* -- general index --------------------------------------------------------- */
table.indextable {
width: 100%;
}
table.indextable td {
text-align: left;
vertical-align: top;
}
table.indextable ul {
margin-top: 0;
margin-bottom: 0;
list-style-type: none;
}
table.indextable > tbody > tr > td > ul {
padding-left: 0em;
}
table.indextable tr.pcap {
height: 10px;
}
table.indextable tr.cap {
margin-top: 10px;
background-color: #f2f2f2;
}
img.toggler {
margin-right: 3px;
margin-top: 3px;
cursor: pointer;
}
div.modindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
div.genindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
/* -- domain module index --------------------------------------------------- */
table.modindextable td {
padding: 2px;
border-collapse: collapse;
}
/* -- general body styles --------------------------------------------------- */
div.body {
min-width: 360px;
max-width: 800px;
}
div.body p, div.body dd, div.body li, div.body blockquote {
-moz-hyphens: auto;
-ms-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}
a.headerlink {
visibility: hidden;
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink,
caption:hover > a.headerlink,
p.caption:hover > a.headerlink,
div.code-block-caption:hover > a.headerlink {
visibility: visible;
}
div.body p.caption {
text-align: inherit;
}
div.body td {
text-align: left;
}
.first {
margin-top: 0 !important;
}
p.rubric {
margin-top: 30px;
font-weight: bold;
}
img.align-left, figure.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em;
}
img.align-right, figure.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em;
}
img.align-center, figure.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
img.align-default, figure.align-default, .figure.align-default {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-default {
text-align: center;
}
.align-right {
text-align: right;
}
/* -- sidebars -------------------------------------------------------------- */
div.sidebar,
aside.sidebar {
margin: 0 0 0.5em 1em;
border: 1px solid #ddb;
padding: 7px;
background-color: #ffe;
width: 40%;
float: right;
clear: right;
overflow-x: auto;
}
p.sidebar-title {
font-weight: bold;
}
nav.contents,
aside.topic,
div.admonition, div.topic, blockquote {
clear: left;
}
/* -- topics ---------------------------------------------------------------- */
nav.contents,
aside.topic,
div.topic {
border: 1px solid #ccc;
padding: 7px;
margin: 10px 0 10px 0;
}
p.topic-title {
font-size: 1.1em;
font-weight: bold;
margin-top: 10px;
}
/* -- admonitions ----------------------------------------------------------- */
div.admonition {
margin-top: 10px;
margin-bottom: 10px;
padding: 7px;
}
div.admonition dt {
font-weight: bold;
}
p.admonition-title {
margin: 0px 10px 5px 0px;
font-weight: bold;
}
div.body p.centered {
text-align: center;
margin-top: 25px;
}
/* -- content of sidebars/topics/admonitions -------------------------------- */
div.sidebar > :last-child,
aside.sidebar > :last-child,
nav.contents > :last-child,
aside.topic > :last-child,
div.topic > :last-child,
div.admonition > :last-child {
margin-bottom: 0;
}
div.sidebar::after,
aside.sidebar::after,
nav.contents::after,
aside.topic::after,
div.topic::after,
div.admonition::after,
blockquote::after {
display: block;
content: '';
clear: both;
}
/* -- tables ---------------------------------------------------------------- */
table.docutils {
margin-top: 10px;
margin-bottom: 10px;
border: 0;
border-collapse: collapse;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
table.align-default {
margin-left: auto;
margin-right: auto;
}
table caption span.caption-number {
font-style: italic;
}
table caption span.caption-text {
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-bottom: 1px solid #aaa;
}
th {
text-align: left;
padding-right: 5px;
}
table.citation {
border-left: solid 1px gray;
margin-left: 1px;
}
table.citation td {
border-bottom: none;
}
th > :first-child,
td > :first-child {
margin-top: 0px;
}
th > :last-child,
td > :last-child {
margin-bottom: 0px;
}
/* -- figures --------------------------------------------------------------- */
div.figure, figure {
margin: 0.5em;
padding: 0.5em;
}
div.figure p.caption, figcaption {
padding: 0.3em;
}
div.figure p.caption span.caption-number,
figcaption span.caption-number {
font-style: italic;
}
div.figure p.caption span.caption-text,
figcaption span.caption-text {
}
/* -- field list styles ----------------------------------------------------- */
table.field-list td, table.field-list th {
border: 0 !important;
}
.field-list ul {
margin: 0;
padding-left: 1em;
}
.field-list p {
margin: 0;
}
.field-name {
-moz-hyphens: manual;
-ms-hyphens: manual;
-webkit-hyphens: manual;
hyphens: manual;
}
/* -- hlist styles ---------------------------------------------------------- */
table.hlist {
margin: 1em 0;
}
table.hlist td {
vertical-align: top;
}
/* -- object description styles --------------------------------------------- */
.sig {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
}
.sig-name, code.descname {
background-color: transparent;
font-weight: bold;
}
.sig-name {
font-size: 1.1em;
}
code.descname {
font-size: 1.2em;
}
.sig-prename, code.descclassname {
background-color: transparent;
}
.optional {
font-size: 1.3em;
}
.sig-paren {
font-size: larger;
}
.sig-param.n {
font-style: italic;
}
/* C++ specific styling */
.sig-inline.c-texpr,
.sig-inline.cpp-texpr {
font-family: unset;
}
.sig.c .k, .sig.c .kt,
.sig.cpp .k, .sig.cpp .kt {
color: #0033B3;
}
.sig.c .m,
.sig.cpp .m {
color: #1750EB;
}
.sig.c .s, .sig.c .sc,
.sig.cpp .s, .sig.cpp .sc {
color: #067D17;
}
/* -- other body styles ----------------------------------------------------- */
ol.arabic {
list-style: decimal;
}
ol.loweralpha {
list-style: lower-alpha;
}
ol.upperalpha {
list-style: upper-alpha;
}
ol.lowerroman {
list-style: lower-roman;
}
ol.upperroman {
list-style: upper-roman;
}
:not(li) > ol > li:first-child > :first-child,
:not(li) > ul > li:first-child > :first-child {
margin-top: 0px;
}
:not(li) > ol > li:last-child > :last-child,
:not(li) > ul > li:last-child > :last-child {
margin-bottom: 0px;
}
ol.simple ol p,
ol.simple ul p,
ul.simple ol p,
ul.simple ul p {
margin-top: 0;
}
ol.simple > li:not(:first-child) > p,
ul.simple > li:not(:first-child) > p {
margin-top: 0;
}
ol.simple p,
ul.simple p {
margin-bottom: 0;
}
aside.footnote > span,
div.citation > span {
float: left;
}
aside.footnote > span:last-of-type,
div.citation > span:last-of-type {
padding-right: 0.5em;
}
aside.footnote > p {
margin-left: 2em;
}
div.citation > p {
margin-left: 4em;
}
aside.footnote > p:last-of-type,
div.citation > p:last-of-type {
margin-bottom: 0em;
}
aside.footnote > p:last-of-type:after,
div.citation > p:last-of-type:after {
content: "";
clear: both;
}
dl.field-list {
display: grid;
grid-template-columns: fit-content(30%) auto;
}
dl.field-list > dt {
font-weight: bold;
word-break: break-word;
padding-left: 0.5em;
padding-right: 5px;
}
dl.field-list > dd {
padding-left: 0.5em;
margin-top: 0em;
margin-left: 0em;
margin-bottom: 0em;
}
dl {
margin-bottom: 15px;
}
dd > :first-child {
margin-top: 0px;
}
dd ul, dd table {
margin-bottom: 10px;
}
dd {
margin-top: 3px;
margin-bottom: 10px;
margin-left: 30px;
}
dl > dd:last-child,
dl > dd:last-child > :last-child {
margin-bottom: 0;
}
dt:target, span.highlighted {
background-color: #fbe54e;
}
rect.highlighted {
fill: #fbe54e;
}
dl.glossary dt {
font-weight: bold;
font-size: 1.1em;
}
.versionmodified {
font-style: italic;
}
.system-message {
background-color: #fda;
padding: 5px;
border: 3px solid red;
}
.footnote:target {
background-color: #ffa;
}
.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}
.line-block .line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em;
}
.guilabel, .menuselection {
font-family: sans-serif;
}
.accelerator {
text-decoration: underline;
}
.classifier {
font-style: oblique;
}
.classifier:before {
font-style: normal;
margin: 0 0.5em;
content: ":";
display: inline-block;
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
overflow: auto;
overflow-y: hidden; /* fixes display issues on Chrome browsers */
}
pre, div[class*="highlight-"] {
clear: both;
}
span.pre {
-moz-hyphens: none;
-ms-hyphens: none;
-webkit-hyphens: none;
hyphens: none;
white-space: nowrap;
}
div[class*="highlight-"] {
margin: 1em 0;
}
td.linenos pre {
border: 0;
background-color: transparent;
color: #aaa;
}
table.highlighttable {
display: block;
}
table.highlighttable tbody {
display: block;
}
table.highlighttable tr {
display: flex;
}
table.highlighttable td {
margin: 0;
padding: 0;
}
table.highlighttable td.linenos {
padding-right: 0.5em;
}
table.highlighttable td.code {
flex: 1;
overflow: hidden;
}
.highlight .hll {
display: block;
}
div.highlight pre,
table.highlighttable pre {
margin: 0;
}
div.code-block-caption + div {
margin-top: 0;
}
div.code-block-caption {
margin-top: 1em;
padding: 2px 5px;
font-size: small;
}
div.code-block-caption code {
background-color: transparent;
}
table.highlighttable td.linenos,
span.linenos,
div.highlight span.gp { /* gp: Generic.Prompt */
user-select: none;
-webkit-user-select: text; /* Safari fallback only */
-webkit-user-select: none; /* Chrome/Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+ */
}
div.code-block-caption span.caption-number {
padding: 0.1em 0.3em;
font-style: italic;
}
div.code-block-caption span.caption-text {
}
div.literal-block-wrapper {
margin: 1em 0;
}
code.xref, a code {
background-color: transparent;
font-weight: bold;
}
h1 code, h2 code, h3 code, h4 code, h5 code, h6 code {
background-color: transparent;
}
.viewcode-link {
float: right;
}
.viewcode-back {
float: right;
font-family: sans-serif;
}
div.viewcode-block:target {
margin: -1px -10px;
padding: 0 10px;
}
/* -- math display ---------------------------------------------------------- */
img.math {
vertical-align: middle;
}
div.body div.math p {
text-align: center;
}
span.eqno {
float: right;
}
span.eqno a.headerlink {
position: absolute;
z-index: 1;
}
div.math:hover a.headerlink {
visibility: visible;
}
/* -- printout stylesheet --------------------------------------------------- */
@media print {
div.document,
div.documentwrapper,
div.bodywrapper {
margin: 0 !important;
width: 100%;
}
div.sphinxsidebar,
div.related,
div.footer,
#top-link {
display: none;
}
}

1
docs/build/html/_static/custom.css vendored Normal file
View File

@ -0,0 +1 @@
/* This file intentionally left blank. */

69
docs/build/html/_static/debug.css vendored Normal file
View File

@ -0,0 +1,69 @@
/*
This CSS file should be overridden by the theme authors. It's
meant for debugging and developing the skeleton that this theme provides.
*/
body {
font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif,
"Apple Color Emoji", "Segoe UI Emoji";
background: lavender;
}
.sb-announcement {
background: rgb(131, 131, 131);
}
.sb-announcement__inner {
background: black;
color: white;
}
.sb-header {
background: lightskyblue;
}
.sb-header__inner {
background: royalblue;
color: white;
}
.sb-header-secondary {
background: lightcyan;
}
.sb-header-secondary__inner {
background: cornflowerblue;
color: white;
}
.sb-sidebar-primary {
background: lightgreen;
}
.sb-main {
background: blanchedalmond;
}
.sb-main__inner {
background: antiquewhite;
}
.sb-header-article {
background: lightsteelblue;
}
.sb-article-container {
background: snow;
}
.sb-article-main {
background: white;
}
.sb-footer-article {
background: lightpink;
}
.sb-sidebar-secondary {
background: lightgoldenrodyellow;
}
.sb-footer-content {
background: plum;
}
.sb-footer-content__inner {
background: palevioletred;
}
.sb-footer {
background: pink;
}
.sb-footer__inner {
background: salmon;
}
.sb-article {
background: white;
}

156
docs/build/html/_static/doctools.js vendored Normal file
View File

@ -0,0 +1,156 @@
/*
* doctools.js
* ~~~~~~~~~~~
*
* Base JavaScript utilities for all Sphinx HTML documentation.
*
* :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
"use strict";
const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([
"TEXTAREA",
"INPUT",
"SELECT",
"BUTTON",
]);
const _ready = (callback) => {
if (document.readyState !== "loading") {
callback();
} else {
document.addEventListener("DOMContentLoaded", callback);
}
};
/**
* Small JavaScript module for the documentation.
*/
const Documentation = {
init: () => {
Documentation.initDomainIndexTable();
Documentation.initOnKeyListeners();
},
/**
* i18n support
*/
TRANSLATIONS: {},
PLURAL_EXPR: (n) => (n === 1 ? 0 : 1),
LOCALE: "unknown",
// gettext and ngettext don't access this so that the functions
// can safely bound to a different name (_ = Documentation.gettext)
gettext: (string) => {
const translated = Documentation.TRANSLATIONS[string];
switch (typeof translated) {
case "undefined":
return string; // no translation
case "string":
return translated; // translation exists
default:
return translated[0]; // (singular, plural) translation tuple exists
}
},
ngettext: (singular, plural, n) => {
const translated = Documentation.TRANSLATIONS[singular];
if (typeof translated !== "undefined")
return translated[Documentation.PLURAL_EXPR(n)];
return n === 1 ? singular : plural;
},
addTranslations: (catalog) => {
Object.assign(Documentation.TRANSLATIONS, catalog.messages);
Documentation.PLURAL_EXPR = new Function(
"n",
`return (${catalog.plural_expr})`
);
Documentation.LOCALE = catalog.locale;
},
/**
* helper function to focus on search bar
*/
focusSearchBar: () => {
document.querySelectorAll("input[name=q]")[0]?.focus();
},
/**
* Initialise the domain index toggle buttons
*/
initDomainIndexTable: () => {
const toggler = (el) => {
const idNumber = el.id.substr(7);
const toggledRows = document.querySelectorAll(`tr.cg-${idNumber}`);
if (el.src.substr(-9) === "minus.png") {
el.src = `${el.src.substr(0, el.src.length - 9)}plus.png`;
toggledRows.forEach((el) => (el.style.display = "none"));
} else {
el.src = `${el.src.substr(0, el.src.length - 8)}minus.png`;
toggledRows.forEach((el) => (el.style.display = ""));
}
};
const togglerElements = document.querySelectorAll("img.toggler");
togglerElements.forEach((el) =>
el.addEventListener("click", (event) => toggler(event.currentTarget))
);
togglerElements.forEach((el) => (el.style.display = ""));
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) togglerElements.forEach(toggler);
},
initOnKeyListeners: () => {
// only install a listener if it is really needed
if (
!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS &&
!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS
)
return;
document.addEventListener("keydown", (event) => {
// bail for input elements
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
// bail with special keys
if (event.altKey || event.ctrlKey || event.metaKey) return;
if (!event.shiftKey) {
switch (event.key) {
case "ArrowLeft":
if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break;
const prevLink = document.querySelector('link[rel="prev"]');
if (prevLink && prevLink.href) {
window.location.href = prevLink.href;
event.preventDefault();
}
break;
case "ArrowRight":
if (!DOCUMENTATION_OPTIONS.NAVIGATION_WITH_KEYS) break;
const nextLink = document.querySelector('link[rel="next"]');
if (nextLink && nextLink.href) {
window.location.href = nextLink.href;
event.preventDefault();
}
break;
}
}
// some keyboard layouts may need Shift to get /
switch (event.key) {
case "/":
if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break;
Documentation.focusSearchBar();
event.preventDefault();
}
});
},
};
// quick alias for translations
const _ = Documentation.gettext;
_ready(Documentation.init);

View File

@ -0,0 +1,14 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '2.11.2',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
FILE_SUFFIX: '.html',
LINK_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt',
NAVIGATION_WITH_KEYS: false,
SHOW_SEARCH_SUMMARY: true,
ENABLE_SEARCH_SHORTCUTS: true,
};

BIN
docs/build/html/_static/file.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

199
docs/build/html/_static/language_data.js vendored Normal file
View File

@ -0,0 +1,199 @@
/*
* language_data.js
* ~~~~~~~~~~~~~~~~
*
* This script contains the language-specific data used by searchtools.js,
* namely the list of stopwords, stemmer, scorer and splitter.
*
* :copyright: Copyright 2007-2023 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
var stopwords = ["a", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "near", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"];
/* Non-minified version is copied as a separate JS file, is available */
/**
* Porter Stemmer
*/
var Stemmer = function() {
var step2list = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
bli: 'ble',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
iveness: 'ive',
fulness: 'ful',
ousness: 'ous',
aliti: 'al',
iviti: 'ive',
biliti: 'ble',
logi: 'log'
};
var step3list = {
icate: 'ic',
ative: '',
alize: 'al',
iciti: 'ic',
ical: 'ic',
ful: '',
ness: ''
};
var c = "[^aeiou]"; // consonant
var v = "[aeiouy]"; // vowel
var C = c + "[^aeiouy]*"; // consonant sequence
var V = v + "[aeiou]*"; // vowel sequence
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
var s_v = "^(" + C + ")?" + v; // vowel in stem
this.stemWord = function (w) {
var stem;
var suffix;
var firstch;
var origword = w;
if (w.length < 3)
return w;
var re;
var re2;
var re3;
var re4;
firstch = w.substr(0,1);
if (firstch == "y")
w = firstch.toUpperCase() + w.substr(1);
// Step 1a
re = /^(.+?)(ss|i)es$/;
re2 = /^(.+?)([^s])s$/;
if (re.test(w))
w = w.replace(re,"$1$2");
else if (re2.test(w))
w = w.replace(re2,"$1$2");
// Step 1b
re = /^(.+?)eed$/;
re2 = /^(.+?)(ed|ing)$/;
if (re.test(w)) {
var fp = re.exec(w);
re = new RegExp(mgr0);
if (re.test(fp[1])) {
re = /.$/;
w = w.replace(re,"");
}
}
else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1];
re2 = new RegExp(s_v);
if (re2.test(stem)) {
w = stem;
re2 = /(at|bl|iz)$/;
re3 = new RegExp("([^aeiouylsz])\\1$");
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re2.test(w))
w = w + "e";
else if (re3.test(w)) {
re = /.$/;
w = w.replace(re,"");
}
else if (re4.test(w))
w = w + "e";
}
}
// Step 1c
re = /^(.+?)y$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(s_v);
if (re.test(stem))
w = stem + "i";
}
// Step 2
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem))
w = stem + step2list[suffix];
}
// Step 3
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem))
w = stem + step3list[suffix];
}
// Step 4
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
re2 = /^(.+?)(s|t)(ion)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
if (re.test(stem))
w = stem;
}
else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1] + fp[2];
re2 = new RegExp(mgr1);
if (re2.test(stem))
w = stem;
}
// Step 5
re = /^(.+?)e$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
re2 = new RegExp(meq1);
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
w = stem;
}
re = /ll$/;
re2 = new RegExp(mgr1);
if (re.test(w) && re2.test(w)) {
re = /.$/;
w = w.replace(re,"");
}
// and turn initial Y back to y
if (firstch == "y")
w = firstch.toLowerCase() + w.substr(1);
return w;
}
}

Some files were not shown because too many files have changed in this diff Show More