add files to library logging not happening question mark
This commit is contained in:
parent
d351f3515e
commit
9cefd00501
@ -19,7 +19,6 @@ from PyQt5.QtWidgets import (
|
|||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
QAbstractItemModel,
|
QAbstractItemModel,
|
||||||
QModelIndex,
|
QModelIndex,
|
||||||
QThread,
|
|
||||||
Qt,
|
Qt,
|
||||||
pyqtSignal,
|
pyqtSignal,
|
||||||
QTimer,
|
QTimer,
|
||||||
@ -30,7 +29,6 @@ from components.LyricsWindow import LyricsWindow
|
|||||||
from components.AddToPlaylistWindow import AddToPlaylistWindow
|
from components.AddToPlaylistWindow import AddToPlaylistWindow
|
||||||
from components.MetadataWindow import MetadataWindow
|
from components.MetadataWindow import MetadataWindow
|
||||||
|
|
||||||
# from main import WorkerThread
|
|
||||||
from main import Worker
|
from main import Worker
|
||||||
from utils.delete_song_id_from_database import delete_song_id_from_database
|
from utils.delete_song_id_from_database import delete_song_id_from_database
|
||||||
from utils.add_files_to_library import add_files_to_library
|
from utils.add_files_to_library import add_files_to_library
|
||||||
|
|||||||
18
main.py
18
main.py
@ -29,14 +29,12 @@ from PyQt5.QtCore import (
|
|||||||
Qt,
|
Qt,
|
||||||
pyqtSignal,
|
pyqtSignal,
|
||||||
QObject,
|
QObject,
|
||||||
QThread,
|
|
||||||
pyqtSlot,
|
pyqtSlot,
|
||||||
QThreadPool,
|
QThreadPool,
|
||||||
QRunnable,
|
QRunnable,
|
||||||
)
|
)
|
||||||
from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent, QAudioProbe
|
from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent, QAudioProbe
|
||||||
from PyQt5.QtGui import QCloseEvent, QPixmap
|
from PyQt5.QtGui import QCloseEvent, QPixmap
|
||||||
from uuid import uuid4, UUID
|
|
||||||
from utils import (
|
from utils import (
|
||||||
scan_for_music,
|
scan_for_music,
|
||||||
delete_and_create_library_database,
|
delete_and_create_library_database,
|
||||||
@ -199,11 +197,13 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
self.actionOpenFiles.triggered.connect(self.open_files) # Open files window
|
self.actionOpenFiles.triggered.connect(self.open_files) # Open files window
|
||||||
self.actionNewPlaylist.triggered.connect(self.create_playlist)
|
self.actionNewPlaylist.triggered.connect(self.create_playlist)
|
||||||
self.actionExportPlaylist.triggered.connect(self.export_playlist)
|
self.actionExportPlaylist.triggered.connect(self.export_playlist)
|
||||||
|
|
||||||
# EDIT MENU
|
# EDIT MENU
|
||||||
# VIEW MENU
|
# VIEW MENU
|
||||||
self.actionPreferences.triggered.connect(
|
self.actionPreferences.triggered.connect(
|
||||||
self.open_preferences
|
self.open_preferences
|
||||||
) # Open preferences menu
|
) # Open preferences menu
|
||||||
|
|
||||||
# QUICK ACTIONS MENU
|
# QUICK ACTIONS MENU
|
||||||
self.actionScanLibraries.triggered.connect(self.scan_libraries)
|
self.actionScanLibraries.triggered.connect(self.scan_libraries)
|
||||||
self.actionDeleteLibrary.triggered.connect(self.clear_database)
|
self.actionDeleteLibrary.triggered.connect(self.clear_database)
|
||||||
@ -396,7 +396,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
audio.save()
|
audio.save()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(
|
logging.error(
|
||||||
f"main.py delete_album_art_for_selected_songs() | Error processing {file}: {e}"
|
f"delete_album_art_for_selected_songs() | Error processing {file}: {e}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_audio_visualization(self) -> None:
|
def update_audio_visualization(self) -> None:
|
||||||
@ -482,7 +482,17 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
|||||||
# Adds files to the library in a new thread
|
# Adds files to the library in a new thread
|
||||||
worker = Worker(add_files_to_library, filenames)
|
worker = Worker(add_files_to_library, filenames)
|
||||||
worker.signals.signal_progress.connect(self.handle_progress)
|
worker.signals.signal_progress.connect(self.handle_progress)
|
||||||
|
worker.signals.signal_started.connect(
|
||||||
|
lambda: self.tableView.model.dataChanged.disconnect(
|
||||||
|
self.tableView.on_cell_data_changed
|
||||||
|
)
|
||||||
|
)
|
||||||
worker.signals.signal_finished.connect(self.tableView.load_music_table)
|
worker.signals.signal_finished.connect(self.tableView.load_music_table)
|
||||||
|
worker.signals.signal_finished.connect(
|
||||||
|
lambda: self.tableView.model.dataChanged.connect(
|
||||||
|
self.tableView.on_cell_data_changed
|
||||||
|
)
|
||||||
|
)
|
||||||
self.threadpool.start(worker)
|
self.threadpool.start(worker)
|
||||||
|
|
||||||
def handle_progress(self, data):
|
def handle_progress(self, data):
|
||||||
@ -601,7 +611,7 @@ if __name__ == "__main__":
|
|||||||
handlers = [file_handler, stdout_handler]
|
handlers = [file_handler, stdout_handler]
|
||||||
# logging.basicConfig(filename="log", encoding="utf-8", level=logging.DEBUG)
|
# logging.basicConfig(filename="log", encoding="utf-8", level=logging.DEBUG)
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.DEBUG,
|
level=logging.INFO,
|
||||||
format="[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s",
|
format="[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s",
|
||||||
handlers=handlers,
|
handlers=handlers,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -68,16 +68,22 @@ def add_files_to_library(files, progress_callback):
|
|||||||
bitrate,
|
bitrate,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
logging.info("insert data appended")
|
||||||
# Check if batch size is reached
|
# Check if batch size is reached
|
||||||
if len(insert_data) >= 1000:
|
if len(insert_data) >= 1000:
|
||||||
|
logging.info(f"inserting a LOT of songs: {len(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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
"INSERT OR IGNORE INTO song (filepath, title, album, artist, track_number, genre, codec, album_date, bitrate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
insert_data,
|
insert_data,
|
||||||
)
|
)
|
||||||
insert_data = [] # Reset the insert_data list
|
insert_data = [] # Reset the insert_data list
|
||||||
|
else:
|
||||||
|
# continue adding files if we havent reached big length
|
||||||
|
continue
|
||||||
# Insert any remaining data
|
# Insert any remaining data
|
||||||
if insert_data:
|
if insert_data:
|
||||||
|
logging.info(f"inserting some songs: {len(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) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
"INSERT OR IGNORE INTO song (filepath, title, album, artist, track_number, genre, codec, album_date, bitrate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user