auto
This commit is contained in:
parent
6cca64702e
commit
84221f92ae
@ -441,12 +441,13 @@ class MusicTable(QTableView):
|
||||
|
||||
Args:
|
||||
- args: ((return_data),)
|
||||
- data returned from the original worker process function are returned here
|
||||
as the first item in a tuple
|
||||
data returned from the original worker process function are returned here
|
||||
as the first item in a tuple
|
||||
"""
|
||||
try:
|
||||
|
||||
_, details = args[0][:2]
|
||||
details = dict(tuple(details)[0])
|
||||
# details =(tuple(details)[0],)
|
||||
if details:
|
||||
window = DebugWindow(details)
|
||||
window.exec_()
|
||||
|
||||
2
main.py
2
main.py
@ -259,7 +259,7 @@ class ApplicationWindow(QMainWindow, Ui_MainWindow):
|
||||
for id in ids:
|
||||
worker = Worker(export_playlist_by_id, id)
|
||||
# worker.signals.signal_finished.connect(None)
|
||||
# worker.signals.signal_progress.connect()
|
||||
worker.signals.signal_progress.connect(self.handle_progress)
|
||||
threadpool.start(worker)
|
||||
# export_playlist_by_id(id)
|
||||
except Exception:
|
||||
|
||||
@ -32,7 +32,7 @@ def add_files_to_database(files: list[str], playlist_id: int | None = None, prog
|
||||
if not files:
|
||||
debug('add_files_to_database() - no files to add')
|
||||
if progress_callback:
|
||||
progress_callback('failed')
|
||||
progress_callback.emit('failed')
|
||||
return False, {"Failure": "All operations failed in add_files_to_database()"}
|
||||
failed_dict: dict[str, str] = {}
|
||||
insert_data: list[tuple[
|
||||
@ -49,6 +49,8 @@ def add_files_to_database(files: list[str], playlist_id: int | None = None, prog
|
||||
for filepath in files:
|
||||
if progress_callback:
|
||||
progress_callback.emit(filepath)
|
||||
# FIXME: can this be improved?
|
||||
# filename.basename or something like that
|
||||
filename = filepath.split("/")[-1]
|
||||
tags, fail_reason = get_tags(filepath)
|
||||
if fail_reason:
|
||||
|
||||
@ -8,12 +8,13 @@ from pathlib import Path
|
||||
from time import time
|
||||
|
||||
|
||||
def export_playlist_by_id(playlist_db_id: int) -> bool:
|
||||
def export_playlist_by_id(playlist_db_id: int, progress_callback=None) -> bool:
|
||||
"""
|
||||
Exports a playlist to its defined auto_export_path, by database ID
|
||||
"""
|
||||
logging.debug(f"Exporting playlist id: {playlist_db_id}")
|
||||
threadpool = QThreadPool()
|
||||
if progress_callback:
|
||||
progress_callback.emit(f"Exporting playlist id: {playlist_db_id}")
|
||||
try:
|
||||
with DBA.DBAccess() as db:
|
||||
result = db.query(
|
||||
@ -56,22 +57,21 @@ def export_playlist_by_id(playlist_db_id: int) -> bool:
|
||||
write_paths = []
|
||||
# Relative paths
|
||||
logging.debug("Creating relative paths...")
|
||||
threadpool = QThreadPool()
|
||||
for song in db_paths:
|
||||
artist, album = parse_artist_album(song)
|
||||
write_path = Path(path_prefix) / artist / album / song.name
|
||||
write_paths.append(str(write_path) + "\n")
|
||||
write_to_playlist_file(write_paths, auto_export_path)
|
||||
# write_to_playlist_file(write_paths, auto_export_path)
|
||||
|
||||
# worker = Worker(write_to_playlist_file, write_paths, auto_export_path)
|
||||
# worker.signals.signal_finished.connect(None)
|
||||
# worker.signals.signal_progress.connect()
|
||||
# threadpool.start(worker)
|
||||
worker = Worker(write_to_playlist_file, write_paths, auto_export_path)
|
||||
# worker.signals.signal_finished.connect(None)
|
||||
# worker.signals.signal_progress.connect()
|
||||
threadpool.start(worker)
|
||||
return True
|
||||
|
||||
|
||||
def write_to_playlist_file(
|
||||
paths: list[str], outfile: str, progress_callback=None
|
||||
) -> None:
|
||||
def write_to_playlist_file(paths: list[str], outfile: str, progress_callback=None) -> None:
|
||||
"""
|
||||
Writes a list of strings to a m3u file
|
||||
"""
|
||||
|
||||
@ -39,6 +39,7 @@ def id3_remap(audio: MP3 | ID3 | FLAC) -> dict[str, str | int | None]:
|
||||
Turns the ID3 dict of an audio file into a normal dict that I, the human, can use.
|
||||
Add extra fields too :D yahooo
|
||||
"""
|
||||
# FIXME: implement other filetypes here too
|
||||
remap = {}
|
||||
if isinstance(audio, MP3):
|
||||
# so ugly
|
||||
@ -85,7 +86,8 @@ def get_tags(filename: str) -> tuple[MP3 | ID3 | FLAC, str]:
|
||||
...
|
||||
}
|
||||
"""
|
||||
if filename.endswith(".mp3"):
|
||||
# FIXME: this is where i implement other filetypes
|
||||
if filename.lower().endswith(".mp3"):
|
||||
tags, details = get_mp3_tags(filename)
|
||||
else:
|
||||
tags, details = ID3(), "non mp3 file"
|
||||
|
||||
@ -28,4 +28,6 @@ def scan_for_music(progress_callback=None):
|
||||
filename = os.path.join(dirpath, file)
|
||||
if any(filename.lower().endswith(ext) for ext in extensions):
|
||||
files_to_add.append(filename)
|
||||
add_files_to_database(files_to_add, progress_callback)
|
||||
if progress_callback:
|
||||
progress_callback.emit(f'Scanning {filename}')
|
||||
add_files_to_database(files=files_to_add, playlist_id=None, progress_callback=progress_callback)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user