Compare commits
No commits in common. "965197cd6a7186b558b677d3f298f1ceb3d21263" and "eca3ba4a64f46101fd6fab6e396fd267224463c6" have entirely different histories.
965197cd6a
...
eca3ba4a64
|
@ -1,7 +1,6 @@
|
|||
DEBUG=0
|
||||
INFO=5
|
||||
WARNING=10
|
||||
ERROR=20
|
||||
INFO=0
|
||||
WARNING=5
|
||||
ERROR=10
|
||||
|
||||
from .log import Log
|
||||
from .logcat import LogCat
|
||||
|
|
|
@ -2,11 +2,11 @@ from datetime import datetime
|
|||
from multiprocessing import Lock
|
||||
from threading import Thread
|
||||
from queue import Queue, Empty
|
||||
from . import DEBUG, INFO, WARNING, ERROR
|
||||
from . import INFO, WARNING, ERROR
|
||||
|
||||
|
||||
class Log(object):
|
||||
def __init__(self, path, queue=None, print_output=True, timeout=1, level=DEBUG):
|
||||
def __init__(self, path, queue=None, print_output=True, timeout=1, level=WARNING):
|
||||
self.__terminated = False
|
||||
self.level = level
|
||||
self.file_lock = Lock()
|
||||
|
@ -78,9 +78,4 @@ class Log(object):
|
|||
self.set_log_file()
|
||||
with self.file_lock:
|
||||
with open(self.log_file, mode='a') as log_file:
|
||||
for line in log_msg_list:
|
||||
try:
|
||||
log_file.write(line)
|
||||
except Exception as e:
|
||||
print(f"Error writing line{line}")
|
||||
print(e)
|
||||
log_file.writelines(log_msg_list)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from datetime import datetime
|
||||
from multiprocessing import Queue
|
||||
from . import DEBUG, INFO, WARNING, ERROR
|
||||
from . import INFO, WARNING, ERROR
|
||||
|
||||
|
||||
class LogCat(object):
|
||||
|
@ -13,9 +13,6 @@ class LogCat(object):
|
|||
time = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
|
||||
self.queue.put((level, f"{self.level_string(level)} | {time} - {self.category.upper()}.{function.upper()}: {message}"))
|
||||
|
||||
def debug(self, function: str, message: str) -> None:
|
||||
self._write(DEBUG, function, message)
|
||||
|
||||
def info(self, function: str, message: str) -> None:
|
||||
self._write(INFO, function, message)
|
||||
|
||||
|
@ -27,9 +24,7 @@ class LogCat(object):
|
|||
|
||||
@staticmethod
|
||||
def level_string(level: int) -> str:
|
||||
if level == DEBUG:
|
||||
return "DEBG"
|
||||
elif level == INFO:
|
||||
if level == INFO:
|
||||
return "INFO"
|
||||
elif level == WARNING:
|
||||
return "WARN"
|
||||
|
|
|
@ -27,37 +27,29 @@ class Worker:
|
|||
shutil.copy(file.path, output_path)
|
||||
log.info("ART", f"Successfully copied {output_path}")
|
||||
except FileExistsError:
|
||||
log.warning("ART", f"File exists: {output_path}")
|
||||
pass
|
||||
except Exception:
|
||||
log.error("ART", f"{file.path} failed to copy")
|
||||
|
||||
def transcode_audio(self, track, encoder, log):
|
||||
enc_filename = encoder.parts[-1]
|
||||
track_output = track.output_file(self.output_root, self.extension)
|
||||
if track_output.exists():
|
||||
log.info("AUD", f"Skipped {track_output}")
|
||||
return
|
||||
self.create_directories(track)
|
||||
encoder_args = self.encoder_args(encoder, track, log)
|
||||
if enc_filename == "opusenc.exe":
|
||||
additional_args = ('--bitrate', '128', '--music')
|
||||
subprocess_args = (str(encoder),) + additional_args + (str(track.path), str(track_output))
|
||||
elif enc_filename == "qaac64.exe":
|
||||
additional_args = (str(track), '-o', str(track_output), '--threading')
|
||||
subprocess_args = (str(encoder),) + additional_args
|
||||
try:
|
||||
subprocess.run(encoder_args, capture_output=True, text=True, check=True)
|
||||
subprocess.run(subprocess_args, capture_output=True, text=True, check=True)
|
||||
log.info("AUD", f"Transcoded '{track}' successfully.")
|
||||
except Exception:
|
||||
log.error("AUD", f"ERROR: Transcoding of '{track}' failed.")
|
||||
|
||||
def encoder_args(self, encoder, track, log):
|
||||
track_output = track.output_file(self.output_root, self.extension)
|
||||
enc_filename = encoder.parts[-1]
|
||||
encoder_args = ""
|
||||
if enc_filename == "opusenc.exe":
|
||||
additional_args = ('--bitrate', '128', '--music')
|
||||
encoder_args = (str(encoder),) + additional_args + (str(track.path), str(track_output))
|
||||
elif enc_filename == "qaac64.exe":
|
||||
additional_args = (str(track), '-o', str(track_output), '--threading')
|
||||
encoder_args = (str(encoder),) + additional_args
|
||||
else:
|
||||
log.error("AUD", f"Encoder {encoder} not recognised.")
|
||||
return encoder_args
|
||||
|
||||
def create_directories(self, track: File):
|
||||
if not track.artist_out(self.output_root).exists():
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue
Block a user