This commit is contained in:
billy@pom 2026-05-01 18:41:59 -04:00
parent 98bce6458f
commit 6cca64702e
2 changed files with 14 additions and 6 deletions

View File

@ -256,6 +256,10 @@ class MusicTable(QTableView):
edit_lyrics_action = QAction("Lyrics (View/Edit)", self)
_ = edit_lyrics_action.triggered.connect(self.show_lyrics_menu)
menu.addAction(edit_lyrics_action)
# view id3 tags (debug)
view_id3_tags_debug = QAction("View ID3 tags (debug)", self)
_ = view_id3_tags_debug.triggered.connect(self.view_id3_tags_debug_menu)
menu.addAction(view_id3_tags_debug)
# jump to current song in table
jump_to_current_song_action = QAction("Jump to current song", self)
_ = jump_to_current_song_action.triggered.connect(self.jump_to_current_song)
@ -264,10 +268,6 @@ class MusicTable(QTableView):
open_containing_folder_action = QAction("Open in system file manager", self)
_ = open_containing_folder_action.triggered.connect(self.open_directory)
menu.addAction(open_containing_folder_action)
# view id3 tags (debug)
view_id3_tags_debug = QAction("View ID3 tags (debug)", self)
_ = view_id3_tags_debug.triggered.connect(self.view_id3_tags_debug_menu)
menu.addAction(view_id3_tags_debug)
# delete song
delete_action = QAction("Delete", self)
_ = delete_action.triggered.connect(self.delete_songs)
@ -313,6 +313,7 @@ class MusicTable(QTableView):
files.append(path)
e.accept()
if directories:
debug('Spawning worker thread for directories')
worker = Worker(self.get_audio_files_recursively, directories)
_ = worker.signals.signal_progress.connect(self.handle_progress)
_ = worker.signals.signal_result.connect(
@ -323,6 +324,7 @@ class MusicTable(QTableView):
threadpool = self.qapp.threadpool # type: ignore
threadpool.start(worker)
if files:
debug('Spawning worker thread for files')
self.add_files_to_library(files)
else:
e.ignore()
@ -642,7 +644,7 @@ class MusicTable(QTableView):
- Drag & Drop song(s) on tableView
- File > Open > List of song(s)
"""
# debug('add_files_to_library()')
debug(f'add_files_to_library() files={files}')
worker = Worker(add_files_to_database, files, None)
_ = worker.signals.signal_progress.connect(self.qapp.handle_progress) # type: ignore
_ = worker.signals.signal_result.connect(self.on_add_files_to_database_finished)
@ -675,7 +677,7 @@ class MusicTable(QTableView):
"""Asks to delete the currently selected songs from the db and music table (not the filesystem)"""
# NOTE: provide extra questionbox option?
# | Delete from playlist & lib | Delete from playlist only | Cancel |
# Currently, this just deletes from the playlist, or the main lib & any playlists
# Currently, this just has 2 options [the playlist], or [the main lib & all playlists]
selected_filepaths = self.get_selected_songs_filepaths()
if self.selected_playlist_id:
question_dialog = QuestionBoxDetails(
@ -1125,6 +1127,7 @@ class MusicTable(QTableView):
audio_files.append(os.path.join(root, file))
if progress_callback:
progress_callback.emit(f"Scanning {file}")
debug(f'get_audio_files_recursively() return: {audio_files}')
return audio_files
def get_selected_rows(self) -> list[int]:

View File

@ -19,6 +19,7 @@ def add_files_to_database(files: list[str], playlist_id: int | None = None, prog
(True, {"filename.mp3":"failed because i said so"})
```
"""
debug('add_files_to_database()')
# yea
if playlist_id:
pass
@ -29,6 +30,9 @@ def add_files_to_database(files: list[str], playlist_id: int | None = None, prog
)
_ = config.read(cfg_file)
if not files:
debug('add_files_to_database() - no files to add')
if progress_callback:
progress_callback('failed')
return False, {"Failure": "All operations failed in add_files_to_database()"}
failed_dict: dict[str, str] = {}
insert_data: list[tuple[
@ -79,6 +83,7 @@ def add_files_to_database(files: list[str], playlist_id: int | None = None, prog
insert_data = [] # Reset the insert_data list
# Insert any remaining data after reading every file
if insert_data:
debug(f'inserting the rest of the songs | insert_data={insert_data}')
with DBA.DBAccess() as db:
db.executemany(
"INSERT OR IGNORE INTO song (filepath, title, album, artist, track_number, genre, codec, album_date, bitrate, length_ms) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",