All the things

This commit is contained in:
2022-05-26 14:20:13 +02:00
parent ec7cb4ca57
commit e0445f621e
6 changed files with 336 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ from UserNotifications import (
)
from Foundation import NSURL
from radiotrack import RadioTrack
from top2000 import Top200Song
class UserNotification:
@@ -52,10 +53,9 @@ class SongNotification(UserNotification):
def __init__(self):
super().__init__()
def notify_song(self, song: RadioTrack):
def notify_song(self, song: RadioTrack, top2000: Top200Song = None):
url = NSURL.URLWithString_(f"file://{song.cover_path}")
err = None
atachement = (
UNNotificationAttachment.attachmentWithIdentifier_URL_options_error_(
@@ -70,8 +70,13 @@ class SongNotification(UserNotification):
print(err)
atachement = None
if top2000:
title = f"{top2000.position}: {song.title}"
else:
title = song.title
self.create_notification(
song.title,
title,
song.artist,
attachments=[atachement],
)