auto
This commit is contained in:
parent
98bce6458f
commit
6cca64702e
@ -256,6 +256,10 @@ class MusicTable(QTableView):
|
|||||||
edit_lyrics_action = QAction("Lyrics (View/Edit)", self)
|
edit_lyrics_action = QAction("Lyrics (View/Edit)", self)
|
||||||
_ = edit_lyrics_action.triggered.connect(self.show_lyrics_menu)
|
_ = edit_lyrics_action.triggered.connect(self.show_lyrics_menu)
|
||||||
menu.addAction(edit_lyrics_action)
|
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 in table
|
||||||
jump_to_current_song_action = QAction("Jump to current song", self)
|
jump_to_current_song_action = QAction("Jump to current song", self)
|
||||||
_ = jump_to_current_song_action.triggered.connect(self.jump_to_current_song)
|
_ = 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 = QAction("Open in system file manager", self)
|
||||||
_ = open_containing_folder_action.triggered.connect(self.open_directory)
|
_ = open_containing_folder_action.triggered.connect(self.open_directory)
|
||||||
menu.addAction(open_containing_folder_action)
|
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 song
|
||||||
delete_action = QAction("Delete", self)
|
delete_action = QAction("Delete", self)
|
||||||
_ = delete_action.triggered.connect(self.delete_songs)
|
_ = delete_action.triggered.connect(self.delete_songs)
|
||||||
@ -313,6 +313,7 @@ class MusicTable(QTableView):
|
|||||||
files.append(path)
|
files.append(path)
|
||||||
e.accept()
|
e.accept()
|
||||||
if directories:
|
if directories:
|
||||||
|
debug('Spawning worker thread for directories')
|
||||||
worker = Worker(self.get_audio_files_recursively, directories)
|
worker = Worker(self.get_audio_files_recursively, directories)
|
||||||
_ = worker.signals.signal_progress.connect(self.handle_progress)
|
_ = worker.signals.signal_progress.connect(self.handle_progress)
|
||||||
_ = worker.signals.signal_result.connect(
|
_ = worker.signals.signal_result.connect(
|
||||||
@ -323,6 +324,7 @@ class MusicTable(QTableView):
|
|||||||
threadpool = self.qapp.threadpool # type: ignore
|
threadpool = self.qapp.threadpool # type: ignore
|
||||||
threadpool.start(worker)
|
threadpool.start(worker)
|
||||||
if files:
|
if files:
|
||||||
|
debug('Spawning worker thread for files')
|
||||||
self.add_files_to_library(files)
|
self.add_files_to_library(files)
|
||||||
else:
|
else:
|
||||||
e.ignore()
|
e.ignore()
|
||||||
@ -642,7 +644,7 @@ class MusicTable(QTableView):
|
|||||||
- Drag & Drop song(s) on tableView
|
- Drag & Drop song(s) on tableView
|
||||||
- File > Open > List of song(s)
|
- 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 = Worker(add_files_to_database, files, None)
|
||||||
_ = worker.signals.signal_progress.connect(self.qapp.handle_progress) # type: ignore
|
_ = worker.signals.signal_progress.connect(self.qapp.handle_progress) # type: ignore
|
||||||
_ = worker.signals.signal_result.connect(self.on_add_files_to_database_finished)
|
_ = 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)"""
|
"""Asks to delete the currently selected songs from the db and music table (not the filesystem)"""
|
||||||
# NOTE: provide extra questionbox option?
|
# NOTE: provide extra questionbox option?
|
||||||
# | Delete from playlist & lib | Delete from playlist only | Cancel |
|
# | 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()
|
selected_filepaths = self.get_selected_songs_filepaths()
|
||||||
if self.selected_playlist_id:
|
if self.selected_playlist_id:
|
||||||
question_dialog = QuestionBoxDetails(
|
question_dialog = QuestionBoxDetails(
|
||||||
@ -1125,6 +1127,7 @@ class MusicTable(QTableView):
|
|||||||
audio_files.append(os.path.join(root, file))
|
audio_files.append(os.path.join(root, file))
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback.emit(f"Scanning {file}")
|
progress_callback.emit(f"Scanning {file}")
|
||||||
|
debug(f'get_audio_files_recursively() return: {audio_files}')
|
||||||
return audio_files
|
return audio_files
|
||||||
|
|
||||||
def get_selected_rows(self) -> list[int]:
|
def get_selected_rows(self) -> list[int]:
|
||||||
|
|||||||
@ -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"})
|
(True, {"filename.mp3":"failed because i said so"})
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
debug('add_files_to_database()')
|
||||||
# yea
|
# yea
|
||||||
if playlist_id:
|
if playlist_id:
|
||||||
pass
|
pass
|
||||||
@ -29,6 +30,9 @@ def add_files_to_database(files: list[str], playlist_id: int | None = None, prog
|
|||||||
)
|
)
|
||||||
_ = config.read(cfg_file)
|
_ = config.read(cfg_file)
|
||||||
if not files:
|
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()"}
|
return False, {"Failure": "All operations failed in add_files_to_database()"}
|
||||||
failed_dict: dict[str, str] = {}
|
failed_dict: dict[str, str] = {}
|
||||||
insert_data: list[tuple[
|
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_data = [] # Reset the insert_data list
|
||||||
# Insert any remaining data after reading every file
|
# Insert any remaining data after reading every file
|
||||||
if insert_data:
|
if insert_data:
|
||||||
|
debug(f'inserting the rest of the songs | insert_data={insert_data}')
|
||||||
with DBA.DBAccess() as db:
|
with DBA.DBAccess() as db:
|
||||||
db.executemany(
|
db.executemany(
|
||||||
"INSERT OR IGNORE INTO song (filepath, title, album, artist, track_number, genre, codec, album_date, bitrate, length_ms) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
"INSERT OR IGNORE INTO song (filepath, title, album, artist, track_number, genre, codec, album_date, bitrate, length_ms) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user