瀏覽代碼

[scrobbles] Fix ntfy formatting

Colin Powell 8 月之前
父節點
當前提交
f3c0d20268

+ 3 - 3
vrobbler/apps/beers/models.py

@@ -7,7 +7,7 @@ from django_extensions.db.models import TimeStampedModel
 from imagekit.models import ImageSpecField
 from imagekit.processors import ResizeToFit
 from scrobbles.dataclasses import BeerLogData
-from scrobbles.mixins import ScrobblableMixin
+from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 from vrobbler.apps.beers.untappd import (
     get_beer_from_untappd_id,
     get_rating_from_soup,
@@ -75,8 +75,8 @@ class Beer(ScrobblableMixin):
         return self.producer.name
 
     @property
-    def verb(self) -> str:
-        return "Drinking"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Drinking", tags="beer")
 
     @property
     def beeradvocate_link(self) -> str:

+ 3 - 3
vrobbler/apps/boardgames/models.py

@@ -13,7 +13,7 @@ from django_extensions.db.models import TimeStampedModel
 from imagekit.models import ImageSpecField
 from imagekit.processors import ResizeToFit
 from scrobbles.dataclasses import BoardGameLogData
-from scrobbles.mixins import ScrobblableMixin
+from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 
 logger = logging.getLogger(__name__)
 BNULL = {"blank": True, "null": True}
@@ -101,8 +101,8 @@ class BoardGame(ScrobblableMixin):
         return BoardGameLogData
 
     @property
-    def verb(self) -> str:
-        return "Playing"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Playing", tags="game_die")
 
     def primary_image_url(self) -> str:
         url = ""

+ 3 - 2
vrobbler/apps/books/models.py

@@ -19,6 +19,7 @@ from imagekit.processors import ResizeToFit
 from scrobbles.mixins import (
     LongPlayScrobblableMixin,
     ObjectWithGenres,
+    ScrobblableConstants,
     ScrobblableMixin,
 )
 from scrobbles.utils import get_scrobbles_for_media
@@ -135,8 +136,8 @@ class Book(LongPlayScrobblableMixin):
         return f" by {self.author}"
 
     @property
-    def verb(self) -> str:
-        return "Reading"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Reading", tags="book")
 
     @property
     def logdata_cls(self):

+ 3 - 3
vrobbler/apps/lifeevents/models.py

@@ -2,7 +2,7 @@ from django.apps import apps
 from django.db import models
 from django.urls import reverse
 from scrobbles.dataclasses import LifeEventLogData
-from scrobbles.mixins import ScrobblableMixin
+from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 
 BNULL = {"blank": True, "null": True}
 
@@ -23,8 +23,8 @@ class LifeEvent(ScrobblableMixin):
         return LifeEventLogData
 
     @property
-    def verb(self) -> str:
-        return "Experiencing"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Experiencing", tags="camping")
 
     @classmethod
     def find_or_create(cls, title: str) -> "LifeEvent":

+ 5 - 3
vrobbler/apps/locations/models.py

@@ -8,7 +8,7 @@ from django.conf import settings
 from django.db import models
 from django.urls import reverse
 from django_extensions.db.models import TimeStampedModel
-from scrobbles.mixins import ScrobblableMixin
+from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 
 logger = logging.getLogger(__name__)
 BNULL = {"blank": True, "null": True}
@@ -91,8 +91,10 @@ class GeoLocation(ScrobblableMixin):
         return ""
 
     @property
-    def verb(self) -> str:
-        return "Going"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(
+            verb="Going", tags="world_map", priority="low"
+        )
 
     def loc_diff(self, old_lat_lon: tuple) -> tuple:
         return (

+ 3 - 3
vrobbler/apps/moods/models.py

@@ -5,7 +5,7 @@ from django.db import models
 from django.urls import reverse
 from imagekit.models import ImageSpecField
 from imagekit.processors import ResizeToFit
-from scrobbles.mixins import ScrobblableMixin
+from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 
 from vrobbler.apps.scrobbles.dataclasses import MoodLogData
 
@@ -46,8 +46,8 @@ class Mood(ScrobblableMixin):
         return ""
 
     @property
-    def verb(self) -> str:
-        return "Feeling"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Feeling", tags="thinking")
 
     @property
     def logdata_cls(self):

+ 3 - 3
vrobbler/apps/music/models.py

@@ -17,7 +17,7 @@ from imagekit.processors import ResizeToFit
 from music.allmusic import get_allmusic_slug, scrape_data_from_allmusic
 from music.bandcamp import get_bandcamp_slug
 from music.theaudiodb import lookup_album_from_tadb, lookup_artist_from_tadb
-from scrobbles.mixins import ScrobblableMixin
+from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 
 logger = logging.getLogger(__name__)
 BNULL = {"blank": True, "null": True}
@@ -429,8 +429,8 @@ class Track(ScrobblableMixin):
         return self.artist
 
     @property
-    def verb(self) -> str:
-        return "Listening"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Listening", tags="headphones")
 
     @property
     def mb_link(self):

+ 4 - 4
vrobbler/apps/scrobbles/dataclasses.py

@@ -172,10 +172,10 @@ class VideoLogData(JSONDataclass):
 
 @dataclass
 class VideoGameLogData(LongPlayLogData):
-    serial_scrobble_id: Optional[int]
-    long_play_complete: bool = False
-    console: str = ""
-    emulated: bool = False
+    serial_scrobble_id: Optional[int] = None
+    long_play_complete: Optional[bool] = False
+    console: Optional[str] = None
+    emulated: Optional[bool] = False
     emulator: Optional[str] = None
 
 

+ 20 - 2
vrobbler/apps/scrobbles/mixins.py

@@ -1,3 +1,4 @@
+from dataclasses import dataclass
 import logging
 from typing import Optional
 from uuid import uuid4
@@ -16,6 +17,23 @@ BNULL = {"blank": True, "null": True}
 logger = logging.getLogger(__name__)
 
 
+@dataclass
+class ScrobblableConstants:
+    verb: str
+    tags: str
+    priority: str
+
+    def __init__(
+        self,
+        verb: str = "Scrobbling",
+        tags: str = "green_square",
+        priority: str = "default",
+    ):
+        self.verb = verb
+        self.tags = tags
+        self.priority = priority
+
+
 class Genre(TagBase):
     source = models.CharField(max_length=255, **BNULL)
 
@@ -81,8 +99,8 @@ class ScrobblableMixin(TimeStampedModel):
         return reverse("scrobbles:start", kwargs={"uuid": self.uuid})
 
     @property
-    def verb(self) -> str:
-        return "Scrobbling"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants()
 
     @property
     def primary_image_url(self) -> str:

+ 2 - 2
vrobbler/apps/scrobbles/models.py

@@ -1192,9 +1192,9 @@ class Scrobble(TimeStampedModel):
                 profile.ntfy_url,
                 data=f"{scrobble.media_obj}".encode(encoding="utf-8"),
                 headers={
-                    "Title": scrobble.media_obj.verb,
+                    "Title": scrobble.media_obj.strings.verb,
                     "Priority": "default",
-                    "Tags": "loudspeaker",
+                    "Tags": scrobble.media_obj.strings.tags,
                 },
             )
 

+ 3 - 3
vrobbler/apps/sports/models.py

@@ -7,7 +7,7 @@ from django.db import models
 from django.urls import reverse
 from django.utils.translation import gettext_lazy as _
 from django_extensions.db.models import TimeStampedModel
-from scrobbles.mixins import ScrobblableMixin
+from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 from sports.utils import get_players_from_event, get_round_name_from_event
 
 logger = logging.getLogger(__name__)
@@ -134,8 +134,8 @@ class SportEvent(ScrobblableMixin):
         return self.round.season.league
 
     @property
-    def verb(self) -> str:
-        return "Watching"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Watching", tags="trophy")
 
     @property
     def sportsdb_link(self):

+ 3 - 3
vrobbler/apps/tasks/models.py

@@ -6,7 +6,7 @@ from django.apps import apps
 from django.db import models
 from django.urls import reverse
 from scrobbles.dataclasses import JSONDataclass
-from scrobbles.mixins import LongPlayScrobblableMixin
+from scrobbles.mixins import LongPlayScrobblableMixin, ScrobblableConstants
 
 BNULL = {"blank": True, "null": True}
 
@@ -39,8 +39,8 @@ class Task(LongPlayScrobblableMixin):
         return reverse("tasks:task_detail", kwargs={"slug": self.uuid})
 
     @property
-    def verb(self) -> str:
-        return "Doing"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Doing", tags="white_check_mark")
 
     # @property
     # def logdata_cls(self):

+ 3 - 3
vrobbler/apps/trails/models.py

@@ -3,7 +3,7 @@ from django.apps import apps
 from django.db import models
 from django.urls import reverse
 from scrobbles.dataclasses import TrailLogData
-from scrobbles.mixins import ScrobblableMixin
+from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 from locations.models import GeoLocation
 
 BNULL = {"blank": True, "null": True}
@@ -39,8 +39,8 @@ class Trail(ScrobblableMixin):
         return TrailLogData
 
     @property
-    def verb(self) -> str:
-        return "Moving"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Moving", tags="runner")
 
     @classmethod
     def find_or_create(cls, title: str) -> "Trail":

+ 3 - 3
vrobbler/apps/videogames/models.py

@@ -9,7 +9,7 @@ from django_extensions.db.models import TimeStampedModel
 from imagekit.models import ImageSpecField
 from imagekit.processors import ResizeToFit
 from scrobbles.dataclasses import VideoGameLogData
-from scrobbles.mixins import LongPlayScrobblableMixin
+from scrobbles.mixins import LongPlayScrobblableMixin, ScrobblableConstants
 from scrobbles.utils import get_scrobbles_for_media
 from videogames.igdb import lookup_game_id_from_gdb
 
@@ -145,8 +145,8 @@ class VideoGame(LongPlayScrobblableMixin):
         return f" On {self.platforms.first()}"
 
     @property
-    def verb(self) -> str:
-        return "Sessioning"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Sessioning", tags="joystick")
 
     @property
     def primary_image_url(self) -> str:

+ 7 - 3
vrobbler/apps/videos/models.py

@@ -12,7 +12,11 @@ from django_extensions.db.models import TimeStampedModel
 from imagekit.models import ImageSpecField
 from imagekit.processors import ResizeToFit
 from music.constants import JELLYFIN_POST_KEYS
-from scrobbles.mixins import ObjectWithGenres, ScrobblableMixin
+from scrobbles.mixins import (
+    ObjectWithGenres,
+    ScrobblableConstants,
+    ScrobblableMixin,
+)
 from taggit.managers import TaggableManager
 from videos.imdb import lookup_video_from_imdb
 
@@ -197,8 +201,8 @@ class Video(ScrobblableMixin):
         return url
 
     @property
-    def verb(self) -> str:
-        return "Watching"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Watching", tags="movie_camera")
 
     def fix_metadata(self, force_update=False):
         imdb_dict = lookup_video_from_imdb(self.imdb_id)

+ 3 - 3
vrobbler/apps/webpages/models.py

@@ -13,7 +13,7 @@ from django.contrib.auth import get_user_model
 from django.db import models
 from django.urls import reverse
 from htmldate import find_date
-from scrobbles.mixins import ScrobblableMixin
+from scrobbles.mixins import ScrobblableConstants, ScrobblableMixin
 
 logger = logging.getLogger(__name__)
 BNULL = {"blank": True, "null": True}
@@ -86,8 +86,8 @@ class WebPage(ScrobblableMixin):
         return int(self.estimated_time_to_read_in_seconds / 60)
 
     @property
-    def verb(self) -> str:
-        return "Browsing"
+    def strings(self) -> ScrobblableConstants:
+        return ScrobblableConstants(verb="Browsing", tags="earth_americas")
 
     @property
     def subtitle(self):