sessions / ac82292200e7e29da6943960996f2b2f63df61c6

/home/powellc/src/code.unbl.ink/secstate/vrobbler

This commit has no recorded session.

diff

show whitespace

commit ac82292200e7e29da6943960996f2b2f63df61c6Author: Colin Powell <colin@unbl.ink>Date:   Tue Jun 16 10:26:08 2026 -0400    [importers] Add last.fm import notificationsdiff --git a/PROJECT.org b/PROJECT.orgindex db1e494..392b4ee 100644--- a/PROJECT.org+++ b/PROJECT.org@@ -88,7 +88,7 @@ fetching and simple saving. *** Metadata sources **** Scraper -* Backlog [3/23] :vrobbler:project:personal:+* Backlog [4/24] :vrobbler:project:personal: ** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :bug:music:scrobbles: :PROPERTIES: :ID:       702462cf-d54b-48c6-8a7c-78b8de751deb@@ -595,6 +595,17 @@ named constants for maintainability.   - ~vrobbler/apps/scrobbles/importers/tsv.py~ (line 55) -- ="S"= completion status      +** DONE [#B] Notify users when Last.fm import completes :importers:notifications:+:PROPERTIES:+:ID:       92846b36-54c5-4b78-9c57-bdc401045fbe+:END:++*** Description++After a bulk import from Last.fm, users receive no confirmation. Should add a notification (in-app, email, or similar).++File: ~vrobbler/apps/scrobbles/importers/lastfm.py~ (line 96)+ ** DONE [#C] Cleaner =GeoLocationLogData= deserialization :models:refactoring: :PROPERTIES: :ID:       85465dbf-69b3-48cb-9df0-cd076c4470abdiff --git a/vrobbler/apps/scrobbles/importers/lastfm.py b/vrobbler/apps/scrobbles/importers/lastfm.pyindex 70c08b5..4410348 100644--- a/vrobbler/apps/scrobbles/importers/lastfm.py+++ b/vrobbler/apps/scrobbles/importers/lastfm.py@@ -93,7 +93,6 @@ class LastFM:             new_scrobbles.append(new_scrobble)          created = Scrobble.objects.bulk_create(new_scrobbles)-        # TODO Add a notification for users that their import is complete         logger.info(             f"Last.fm import fnished",             extra={diff --git a/vrobbler/apps/scrobbles/models.py b/vrobbler/apps/scrobbles/models.pyindex 452c801..84b5a7e 100644--- a/vrobbler/apps/scrobbles/models.py+++ b/vrobbler/apps/scrobbles/models.py@@ -51,7 +51,10 @@ from scrobbles.constants import (     MEDIA_END_PADDING_SECONDS, ) from scrobbles.importers.lastfm import LastFM-from scrobbles.notifications import ScrobbleNtfyNotification+from scrobbles.notifications import (+    LastFmImportNtfyNotification,+    ScrobbleNtfyNotification,+) from scrobbles.utils import get_file_md5_hash, media_class_to_foreign_key from sports.models import SportEvent from taggit.managers import TaggableManager@@ -428,6 +431,8 @@ class LastFmImport(BaseFileImportMixin):         try:             scrobbles = lastfm.import_from_lastfm(last_processed, time_to=time_to)             self.record_log(scrobbles)+            if scrobbles:+                LastFmImportNtfyNotification(self, len(scrobbles)).send()         except Exception as e:             self.record_error(f"Import failed: {e}")             logger.exception(f"Import failed for {self}")diff --git a/vrobbler/apps/scrobbles/notifications.py b/vrobbler/apps/scrobbles/notifications.pyindex 64be2a9..5aa3d70 100644--- a/vrobbler/apps/scrobbles/notifications.py+++ b/vrobbler/apps/scrobbles/notifications.py@@ -79,6 +79,27 @@ class ScrobbleNtfyNotification(ScrobbleNotification):             )  +class LastFmImportNtfyNotification(BasicNtfyNotification):+    def __init__(self, lfm_import, scrobble_count):+        super().__init__(lfm_import.user.profile)+        self.ntfy_str = f"Imported {scrobble_count} scrobble(s) from Last.fm"+        self.click_url = lfm_import.get_absolute_url()+        self.title = "Last.fm Import Complete"++    def send(self):+        if self.profile and self.profile.ntfy_enabled and self.profile.ntfy_url:+            requests.post(+                self.profile.ntfy_url,+                data=self.ntfy_str.encode(encoding="utf-8"),+                headers={+                    "Title": self.title,+                    "Priority": "default",+                    "Tags": "musical_note",+                    "Click": self.click_url,+                },+            )++ class MoodNtfyNotification(BasicNtfyNotification):     def __init__(self, profile, **kwargs):         super().__init__(profile)