Selaa lähdekoodia

[scrobbles] Add a check for Garmin emails

Colin Powell 1 päivä sitten
vanhempi
commit
4924ef316f
1 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 7 0
      vrobbler/apps/scrobbles/imap.py

+ 7 - 0
vrobbler/apps/scrobbles/imap.py

@@ -46,6 +46,13 @@ def process_scrobbles_from_imap() -> list[Scrobble]:
                 logger.info("No email message data found")
                 return
 
+            # Decode subject safely
+            subject, encoding = decode_header(message["Subject"])[0]
+            if isinstance(subject, bytes):
+                subject = subject.decode(encoding or "utf-8")
+            if "live activity now!" in subject:
+                print("Found a Garmin email")
+
             for part in message.walk():
                 if part.get_content_disposition() == "attachment":
                     filename = part.get_filename()