diff --git a/main.py b/main.py index a81dde8..7c3235f 100644 --- a/main.py +++ b/main.py @@ -25,6 +25,15 @@ LOG_PATTERN = re.compile( r'time="(?P[^"]+)".*msg="Changing starred" ids="\[`(?P[^`]+)`\]".*starred=(?Ptrue|false)' ) +async def alert_tanner(message): + try: + params = {'navidrome': message} + async with aiohttp.ClientSession() as session: + async with session.get('https://tbot.tannercollin.com/message', params=params, timeout=4) as response: + response.raise_for_status() + except BaseException as e: + logging.error('Problem alerting Tanner: ' + str(e)) + def parse_log_line(line): """ @@ -133,7 +142,10 @@ async def handle_star_unstar_event(song_id): title = details.get('title', 'Unknown Title') artist = details.get('artist', 'Unknown Artist') album = details.get('album', 'Unknown Album') - logging.info(f'Set song "{title}" - {artist} ({album}) rating to 1.') + + msg = f'Set song "{title}" - {artist} ({album}) rating to 1.' + logging.info(msg) + await alert_tanner(msg) async def main():