Skip to content

Commit

Permalink
chore(smc-output): improve logging (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
hairmare authored Dec 12, 2023
1 parent ce6964c commit 586ab9c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions nowplaying/track/observers/smc_ftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,20 @@ def __init__(self, options: Options):
self._options = options

def track_started(self, track: Track):
logger.info(f"Updating DAB+ DLS for track: {track.artist} - {track.title}")
logger.info(f"Updating DAB+ DLS for track {track.artist=} {track.title=}")

if track.get_duration() < timedelta(seconds=5):
logger.info("Track is less than 5 seconds, not sending to SMC")
logger.info(
"Track is less than 5 seconds, not sending to SMC"
f"{track.artist=} {track.title=}"
)
return

dls, dlplus = _dls_from_track(track)

# check for too long meta and shorten to just artist
if dls.getbuffer().nbytes > 128: # pragma: no cover
logger.warning(f"SMC DLS to long {dls=}")
logger.warning(f"SMC DLS to long {dls.getvalue().decode('latin1')=}")
dls, dlplus = _dls_from_track(track, title=False)

ftp = FTP_TLS()
Expand All @@ -72,7 +75,9 @@ def track_started(self, track: Track):
ftp.close()

logger.info(
f"SMC FTP Server: {self._options.hostname} DLS: {dls} DL+: {dlplus}"
f"SMC FTP {self._options.hostname=} "
f"{dls.getvalue().decode('latin1')=} "
f"{dlplus.getvalue().decode('latin1')=}"
)

def track_finished(self, track):
Expand Down

0 comments on commit 586ab9c

Please sign in to comment.