From 0f44df2b9b73454604cb428f12d98da867150325 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Thu, 23 Feb 2023 10:56:21 -0500 Subject: [PATCH] Add subtitle field to media objects --- vrobbler/apps/music/models.py | 8 ++++++++ vrobbler/apps/podcasts/models.py | 8 ++++++++ vrobbler/apps/sports/models.py | 13 +++++++++++++ vrobbler/apps/videos/models.py | 14 ++++++++++++++ vrobbler/templates/base.html | 5 +---- 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/vrobbler/apps/music/models.py b/vrobbler/apps/music/models.py index d1dbb54..44c7173 100644 --- a/vrobbler/apps/music/models.py +++ b/vrobbler/apps/music/models.py @@ -181,10 +181,18 @@ class Track(ScrobblableMixin): def get_absolute_url(self): return reverse('music:track_detail', kwargs={'slug': self.uuid}) + @property + def subtitle(self): + return self.artist + @property def mb_link(self): return f"https://musicbrainz.org/recording/{self.musicbrainz_id}" + @property + def info_link(self): + return self.mb_link + @classmethod def find_or_create( cls, artist_dict: Dict, album_dict: Dict, track_dict: Dict diff --git a/vrobbler/apps/podcasts/models.py b/vrobbler/apps/podcasts/models.py index 9d84d5e..31999a8 100644 --- a/vrobbler/apps/podcasts/models.py +++ b/vrobbler/apps/podcasts/models.py @@ -45,6 +45,14 @@ class Episode(ScrobblableMixin): def __str__(self): return f"{self.title}" + @property + def subtitle(self): + return self.podcast + + @property + def info_link(self): + return "" + @classmethod def find_or_create( cls, podcast_dict: Dict, producer_dict: Dict, episode_dict: Dict diff --git a/vrobbler/apps/sports/models.py b/vrobbler/apps/sports/models.py index 8490ed7..c6f17c3 100644 --- a/vrobbler/apps/sports/models.py +++ b/vrobbler/apps/sports/models.py @@ -89,6 +89,7 @@ class Round(TheSportsDbMixin): class SportEvent(ScrobblableMixin): COMPLETION_PERCENT = getattr(settings, 'SPORT_COMPLETION_PERCENT', 90) + thesportsdb_id = models.CharField(max_length=255, **BNULL) event_type = models.CharField( max_length=2, choices=SportEventType.choices, @@ -127,6 +128,18 @@ class SportEvent(ScrobblableMixin): def get_absolute_url(self): return reverse("sports:event_detail", kwargs={'slug': self.uuid}) + @property + def subtitle(self): + return self.round.season.league + + @property + def sportsdb_link(self): + return f"https://thesportsdb.com/event/{self.thesportsdb_id}" + + @property + def info_link(self): + return self.sportsdb_link + @classmethod def find_or_create(cls, data_dict: Dict) -> "Event": """Given a data dict from Jellyfin, does the heavy lifting of looking up diff --git a/vrobbler/apps/videos/models.py b/vrobbler/apps/videos/models.py index a99e4f2..7c8b762 100644 --- a/vrobbler/apps/videos/models.py +++ b/vrobbler/apps/videos/models.py @@ -69,10 +69,24 @@ class Video(ScrobblableMixin): def get_absolute_url(self): return reverse("videos:video_detail", kwargs={'slug': self.uuid}) + @property + def subtitle(self): + if self.tv_series: + return self.tv_series + return "" + @property def imdb_link(self): return f"https://www.imdb.com/title/{self.imdb_id}" + @property + def info_link(self): + return self.imdb_link + + @property + def link(self): + return self.imdb_link + @classmethod def find_or_create(cls, data_dict: Dict) -> "Video": """Given a data dict from Jellyfin, does the heavy lifting of looking up diff --git a/vrobbler/templates/base.html b/vrobbler/templates/base.html index d05abc6..0ff5364 100644 --- a/vrobbler/templates/base.html +++ b/vrobbler/templates/base.html @@ -210,10 +210,7 @@ {% for scrobble in now_playing_list %}
{{scrobble.media_obj.title}}
- {% if scrobble.track %}{{scrobble.track.artist}}
{% endif %} - {% if scrobble.podcast_episode%}{{scrobble.podcast_episode.podcast}}
{% endif %} - {% if scrobble.video.tv_series %}{{scrobble.video.tv_series }}
{% endif %} - {% if scrobble.sport_event %}{{scrobble.sport_event.round.season.league}}
{% endif %} + {% if scrobble.media_obj.subtitle %}{{scrobble.media_obj.subtitle}}
{% endif %} {{scrobble.timestamp|naturaltime}}
from {{scrobble.source}}