Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a4ef678a8 | |||
| 5ca22efeaa | |||
| 912ea8bfac | |||
| b541e1084d | |||
| c9b9da4abc | |||
| 8236f43026 | |||
| ea1b43d1b8 | |||
| 4bf22c96e9 | |||
| dec7a79509 | |||
| 371e1d654c | |||
| bef7e683c5 | |||
| ec219ef3ea | |||
| dcc7229e90 |
130
PROJECT.org
130
PROJECT.org
@ -2,6 +2,7 @@
|
||||
|
||||
We should convert this PROJECT file to put tickets in a subdirectory, tickets, with each ticket having it's own shortid_title.org
|
||||
* Overview
|
||||
|
||||
Vrobbler began humbly enough as a way to use Jellyfin's webhook to keep track of
|
||||
the shows and movies I was watching. More specifically, I broke my ankle a few
|
||||
days after Christmas in 2022 and spent the next four months very slowly
|
||||
@ -85,19 +86,7 @@ fetching and simple saving.
|
||||
**** Bookmarklet
|
||||
*** Metadata sources
|
||||
**** Scraper
|
||||
* Chores
|
||||
** DONE Document various vrobbler features :chore:personal:project:vrobbler:documentation:
|
||||
:PROPERTIES:
|
||||
:ID: 514e9285-96f1-265f-56df-118c12f60918
|
||||
:END:
|
||||
:LOGBOOK:
|
||||
CLOCK: [2025-07-09 Wed 09:55]--[2025-07-09 Wed 10:15] => 0:20
|
||||
:END:
|
||||
* Backlog [-1/13] :vrobbler:project:personal:
|
||||
** TODO [#C] Add sentiment parsing for Scrobbles with notes :vrobbler:project:scrobbles:sentiment:
|
||||
:PROPERTIES:
|
||||
:ID: 37781d6a-f3b0-48b2-bf98-33c2c791cf85
|
||||
:END:
|
||||
* Backlog [0/12] :vrobbler:project:personal:
|
||||
** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :vrobbler:personal:bug:music:scrobbles:
|
||||
:PROPERTIES:
|
||||
:ID: 702462cf-d54b-48c6-8a7c-78b8de751deb
|
||||
@ -486,7 +475,7 @@ whatever time KoReader reports, we need to know, given the date and the user
|
||||
profile's historic timezone, how many hours to adjust the KoReader time to get
|
||||
to GMT to save it in the database.
|
||||
|
||||
** TODO [#A] Make IMAP and WebDAV configurable :webdav:feature:imap:importers:
|
||||
** TODO [#B] Make IMAP and WebDAV configurable :webdav:feature:imap:importers:
|
||||
:PROPERTIES:
|
||||
:ID: b1426d92-2feb-4d15-9738-d5b7b0594f96
|
||||
:END:
|
||||
@ -509,6 +498,119 @@ needed import celery task. This is how the WebDAV celery task currently works.
|
||||
This would also be an opporunity to clean up the code around WebDAV imports
|
||||
and make them more re-usable for other import services.
|
||||
|
||||
* Version 47.2 [1/1]
|
||||
** DONE [#B] Add OMDB source as backup when TMDB returns nothing :videos:metadata:imdb:
|
||||
:PROPERTIES:
|
||||
:ID: 20195445-7fdd-49be-9767-103b12da0bfb
|
||||
:END:
|
||||
|
||||
*** Description
|
||||
|
||||
TMDb works great for most cases. There are some edge cases, though where it does
|
||||
not import videos, when TV shows are split up differently in TMDb than in IMDB.
|
||||
One example I stumbled on is the 2020 reboot of Animaniacs. TMDb splits the
|
||||
epiodes up in three parts, while they were always broadcast three-in-one, and
|
||||
that's how IMDB lists them. Thus, the IMDB ID means nothing, and the videos end
|
||||
up unenriched.
|
||||
|
||||
|
||||
* Version 47.1 [1/1]
|
||||
** DONE [#A] Untangle the sports migrations errors :sports:bug:migrations:
|
||||
:PROPERTIES:
|
||||
:ID: 4d50ca2e-f45b-dde8-e3c9-cd84f353b349
|
||||
:END:
|
||||
|
||||
* Version 47.0 [1/1]
|
||||
** DONE [#B] Change sports scrobbling a bit :feature:sports:scrobbles:
|
||||
:PROPERTIES:
|
||||
:ID: cd27d683-c847-4251-b3d1-8243f45c01ca
|
||||
:END:
|
||||
|
||||
*** Description
|
||||
|
||||
Currently, the way we scrobble sports means that basically the same event will
|
||||
never be scrobbled again. I will likely never watch the 2025 Monaco Grand Prix
|
||||
again, but I will watch the Monaco Grand Prix again. But I also wont watch one
|
||||
specific game between Arsenal and Man City twice, but I may watch those two
|
||||
teams play multiple times.
|
||||
|
||||
What if instead of scrobbling a specific sports event on a specific date, we
|
||||
make the unique Scrobblable item the players or teams in the event?
|
||||
|
||||
That would not work for races where the unique item would have to be the name of
|
||||
the event.
|
||||
|
||||
Maybe that means SportEvent is too generic, and we'd need the event type to be
|
||||
scrobble items.
|
||||
|
||||
A race, the Indy 500 or Coke 600, or Boston Marathon would be scrobblable, while
|
||||
for games, the teams would be unique, so a game between Arsenal and Man City
|
||||
would be unique (with extra logdata context for who's home and who's away, and
|
||||
the location, could even have the weather per scrobble).
|
||||
|
||||
And finally, for Tennis, the title would be the round of the event, Roland
|
||||
Garros Women's Semifinal, US Open Men's Final, Miami Invitational Round of 32,
|
||||
with two players, or two teams and a start datetime, which is similar to what we
|
||||
have now. The round becomes not a foreign key, but just a string, and we'd need
|
||||
a FK to an organizer field which would replace league, and would be like "ATP
|
||||
Tour" or "PGA Tour". Season would also need to be a string, and would be
|
||||
something like: 2026 or 2024-2025.
|
||||
|
||||
Examples:
|
||||
- Super Bowl
|
||||
- Sochaux v Concarneau
|
||||
- French Open Final
|
||||
- Carlos Alcaraz v Jannik Sinner
|
||||
|
||||
We'd also want a script to reorganize existing sports events and move scrobbles
|
||||
to the right place as best as we're able, and to flag sportsevents and scrobbles
|
||||
that could not automatically be migrated with a unique tag like
|
||||
"migration-failed"
|
||||
|
||||
Ultimately I think what we need is to greatly simplify the SportEvent to be just a placeholder
|
||||
for a sport event type for a given league, then each scrobble holds the details of teams, players
|
||||
start, thesportsdb_id, round and season.
|
||||
|
||||
Thus, I've already simplified that model, but what we need is a migration script that will move
|
||||
existing complex SportEvent instances into very basic ones, and updating any scrobbles for those
|
||||
events with a new SportEventLogData structure with all the specific details in it. We also need to
|
||||
move the obj.round.season.league into the FK for the given event.
|
||||
|
||||
|
||||
|
||||
* Version 46.0 [1/1]
|
||||
** DONE [#C] Add sentiment parsing for Scrobbles with notes :scrobbles:sentiment:
|
||||
:PROPERTIES:
|
||||
:ID: 37781d6a-f3b0-48b2-bf98-33c2c791cf85
|
||||
:END:
|
||||
|
||||
*** Description
|
||||
|
||||
Not sure how useful this would be, but I wonder if we can add a `sentiment` JSONField
|
||||
on each scrobble that can store the output of VADER over the notes in a scrobble with notes.
|
||||
|
||||
I'm not sure that the value prop here is worth the storage and processing time.
|
||||
|
||||
But if we do add it, it should be a process that scans for scrobbles with both notes and no
|
||||
sentiment field value (unless --overwrite is used) and just run periodically.
|
||||
|
||||
|
||||
* Version 45.1 [1/1]
|
||||
** DONE [#B] Mopidy favorites or monthly playlist adds should look at all scrobbles :bug:mopidy:favorites:tracks:
|
||||
:PROPERTIES:
|
||||
:ID: 0be7d11e-e268-2fd5-836a-e5b4d210e0fa
|
||||
:END:
|
||||
|
||||
*** Description
|
||||
|
||||
When favoriting a track and trying to add it to the Moidy favorite playlist, it
|
||||
sometimes happens that one scrobble did not come from Mopidy, but an earlier or
|
||||
later one did.
|
||||
|
||||
Can we scan all the scrobbles of the track for a given user to see if any have
|
||||
`mopidy_uri` in the log and if so, use that to send along to Mopidy?
|
||||
|
||||
|
||||
* Version 45.0 [1/1]
|
||||
** DONE [#B] Add ability to add mopidy tracks to Monthly playlists :feature:favorites:tracks:
|
||||
:PROPERTIES:
|
||||
|
||||
8
justfile
8
justfile
@ -15,9 +15,11 @@ celery:
|
||||
celery-beat:
|
||||
poetry run celery -A vrobbler beat -l info
|
||||
|
||||
release kind="minor":
|
||||
poetry run python scripts/release.py {{kind}}
|
||||
|
||||
push:
|
||||
git push && git push gitea
|
||||
git push --tags && git push --tags gitea
|
||||
|
||||
release kind="minor":
|
||||
poetry run python scripts/release.py {{kind}}
|
||||
just push
|
||||
|
||||
|
||||
17
poetry.lock
generated
17
poetry.lock
generated
@ -5439,6 +5439,21 @@ brotli = ["brotli (==1.0.9) ; os_name != \"nt\" and python_version < \"3\" and p
|
||||
secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress ; python_version == \"2.7\"", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"]
|
||||
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "vadersentiment"
|
||||
version = "3.3.2"
|
||||
description = "VADER Sentiment Analysis. VADER (Valence Aware Dictionary and sEntiment Reasoner) is a lexicon and rule-based sentiment analysis tool that is specifically attuned to sentiments expressed in social media, and works well on texts from other domains."
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "vaderSentiment-3.3.2-py2.py3-none-any.whl", hash = "sha256:3bf1d243b98b1afad575b9f22bc2cb1e212b94ff89ca74f8a23a588d024ea311"},
|
||||
{file = "vaderSentiment-3.3.2.tar.gz", hash = "sha256:5d7c06e027fc8b99238edb0d53d970cf97066ef97654009890b83703849632f9"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
requests = "*"
|
||||
|
||||
[[package]]
|
||||
name = "vine"
|
||||
version = "5.1.0"
|
||||
@ -6005,4 +6020,4 @@ cffi = ["cffi (>=1.17,<2.0) ; platform_python_implementation != \"PyPy\" and pyt
|
||||
[metadata]
|
||||
lock-version = "2.1"
|
||||
python-versions = ">=3.11,<3.15"
|
||||
content-hash = "bd3f14a9cfce403db426af98774f1e3c41b97283aa43f4bd80f84594ee0dd726"
|
||||
content-hash = "78ba52d0e6ea492efceb14fcd42ace25abfb66d42c3aff28f2fe1a31a9aa03b5"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "vrobbler"
|
||||
version = "45.0"
|
||||
version = "47.2"
|
||||
description = ""
|
||||
authors = ["Colin Powell <colin@unbl.ink>"]
|
||||
|
||||
@ -62,6 +62,7 @@ recipe-scrapers = "^15.11.0"
|
||||
gpxpy = "^1.6.2"
|
||||
fitparse = "^1.2.0"
|
||||
lxml = ">=5.5.0"
|
||||
vaderSentiment = "^3.3.2"
|
||||
|
||||
[tool.poetry.group.test]
|
||||
optional = true
|
||||
|
||||
@ -124,7 +124,7 @@ def main():
|
||||
|
||||
if not done_items:
|
||||
print("No DONE items found in Backlog — nothing to release.")
|
||||
sys.exit(0)
|
||||
sys.exit(1)
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# 4. Build the new Version section text
|
||||
|
||||
@ -112,9 +112,7 @@ class BaseLogData(JSONDataclass):
|
||||
continue
|
||||
|
||||
if dt is None:
|
||||
m = re.match(
|
||||
r"(\d{4}-\d{2}-\d{2})\s+\w{3}\s+(\d{2}:\d{2})", cleaned
|
||||
)
|
||||
m = re.match(r"(\d{4}-\d{2}-\d{2})\s+\w{3}\s+(\d{2}:\d{2})", cleaned)
|
||||
if m:
|
||||
try:
|
||||
dt = datetime.strptime(
|
||||
@ -143,9 +141,25 @@ class BaseLogData(JSONDataclass):
|
||||
|
||||
md = markdown.Markdown(extensions=["extra"])
|
||||
allowed_tags = [
|
||||
"p", "br", "strong", "em", "a", "ul", "ol", "li",
|
||||
"code", "pre", "blockquote", "h1", "h2", "h3", "h4", "h5", "h6",
|
||||
"hr", "img",
|
||||
"p",
|
||||
"br",
|
||||
"strong",
|
||||
"em",
|
||||
"a",
|
||||
"ul",
|
||||
"ol",
|
||||
"li",
|
||||
"code",
|
||||
"pre",
|
||||
"blockquote",
|
||||
"h1",
|
||||
"h2",
|
||||
"h3",
|
||||
"h4",
|
||||
"h5",
|
||||
"h6",
|
||||
"hr",
|
||||
"img",
|
||||
]
|
||||
|
||||
note_items = []
|
||||
@ -174,7 +188,9 @@ class BaseLogData(JSONDataclass):
|
||||
|
||||
ts_html = ""
|
||||
if ts:
|
||||
ts_html = f'<h5 class="note-timestamp">{self._format_timestamp(ts)}</h5>'
|
||||
ts_html = (
|
||||
f'<h5 class="note-timestamp">{self._format_timestamp(ts)}</h5>'
|
||||
)
|
||||
|
||||
content_html = bleach.clean(
|
||||
md.convert(text),
|
||||
@ -194,6 +210,14 @@ class LongPlayLogData(JSONDataclass):
|
||||
long_play_complete: bool = False
|
||||
|
||||
|
||||
@dataclass
|
||||
class SportEventLogData(BaseLogData):
|
||||
thesportsdb_id: Optional[str] = None
|
||||
start: Optional[str] = None
|
||||
round_name: Optional[str] = None
|
||||
season_name: Optional[str] = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class WithPeopleLogData(JSONDataclass):
|
||||
with_people_ids: Optional[list[int]] = None
|
||||
|
||||
@ -0,0 +1,68 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import models
|
||||
|
||||
from scrobbles.models import Scrobble
|
||||
from scrobbles.utils import analyze_scrobble_sentiment
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Backfill VADER sentiment analysis for scrobbles with notes"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"--commit",
|
||||
action="store_true",
|
||||
help="Actually update scrobble logs with sentiment data",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--overwrite",
|
||||
action="store_true",
|
||||
help="Re-analyze scrobbles that already have sentiment data",
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
commit = options["commit"]
|
||||
overwrite = options["overwrite"]
|
||||
|
||||
qs = Scrobble.objects.filter(
|
||||
~models.Q(log__notes__isnull=True)
|
||||
& ~models.Q(log__notes=[])
|
||||
& ~models.Q(log__notes={})
|
||||
)
|
||||
if not overwrite:
|
||||
qs = qs.filter(log__sentiment__isnull=True)
|
||||
|
||||
total = qs.count()
|
||||
analyzed_count = 0
|
||||
skipped_count = 0
|
||||
|
||||
self.stdout.write(f"Found {total} scrobbles to process")
|
||||
|
||||
for scrobble in qs.iterator():
|
||||
if commit:
|
||||
analyzed = analyze_scrobble_sentiment(scrobble, overwrite=overwrite)
|
||||
else:
|
||||
notes_str = ""
|
||||
if scrobble.logdata:
|
||||
notes_str = scrobble.logdata.notes_as_str()
|
||||
analyzed = bool(notes_str)
|
||||
|
||||
if analyzed:
|
||||
analyzed_count += 1
|
||||
if commit:
|
||||
scores = (scrobble.log or {}).get("sentiment", {})
|
||||
self.stdout.write(
|
||||
f" Updated scrobble {scrobble.id}: compound={scores.get('compound', 'N/A')}"
|
||||
)
|
||||
else:
|
||||
self.stdout.write(
|
||||
f" [DRY RUN] Would analyze scrobble {scrobble.id}"
|
||||
)
|
||||
else:
|
||||
skipped_count += 1
|
||||
|
||||
self.stdout.write(
|
||||
f"\nAnalyzed {analyzed_count} scrobbles, skipped {skipped_count}"
|
||||
)
|
||||
if not commit:
|
||||
self.stdout.write("Run with --commit to persist changes")
|
||||
@ -882,8 +882,13 @@ class Scrobble(TimeStampedModel):
|
||||
logger.warning("Log data could not be loaded", e)
|
||||
return logdata_cls()
|
||||
|
||||
# Strip log-only keys (stored in JSONField but not part of LogData dataclass)
|
||||
logdata_kwargs = {
|
||||
k: v for k, v in log_dict.items() if k in logdata_cls().__dataclass_fields__
|
||||
}
|
||||
|
||||
try:
|
||||
return logdata_cls(**log_dict)
|
||||
return logdata_cls(**logdata_kwargs)
|
||||
except ParseError as e:
|
||||
logger.warning(
|
||||
"Could not parse log data",
|
||||
|
||||
@ -242,12 +242,13 @@ def manual_scrobble_event(
|
||||
):
|
||||
data_dict = lookup_event_from_thesportsdb(thesportsdb_id)
|
||||
|
||||
event = SportEvent.find_or_create(data_dict)
|
||||
event, logdata = SportEvent.find_or_create(data_dict)
|
||||
scrobble_dict = {
|
||||
"user_id": user_id,
|
||||
"timestamp": timezone.now(),
|
||||
"playback_position_seconds": 0,
|
||||
"source": "TheSportsDB",
|
||||
"log": logdata,
|
||||
}
|
||||
return Scrobble.create_or_update(event, user_id, scrobble_dict)
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ from charts.utils import (
|
||||
from django.apps import apps
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -544,6 +545,30 @@ def send_mood_checkin():
|
||||
send_mood_checkin_reminders()
|
||||
|
||||
|
||||
@shared_task
|
||||
def backfill_scrobble_sentiment():
|
||||
"""Backfill VADER sentiment for scrobbles with notes (replaces @hourly cron)."""
|
||||
from scrobbles.models import Scrobble
|
||||
from scrobbles.utils import analyze_scrobble_sentiment
|
||||
|
||||
qs = Scrobble.objects.filter(
|
||||
models.Q(log__notes__isnull=False)
|
||||
& ~models.Q(log__notes=[])
|
||||
& ~models.Q(log__notes={})
|
||||
& models.Q(log__sentiment__isnull=True)
|
||||
)
|
||||
|
||||
count = 0
|
||||
for scrobble in qs.iterator():
|
||||
if analyze_scrobble_sentiment(scrobble):
|
||||
count += 1
|
||||
|
||||
logger.info(
|
||||
"Backfilled sentiment for %d scrobbles",
|
||||
count,
|
||||
)
|
||||
|
||||
|
||||
@shared_task
|
||||
def add_favorite_to_mopidy_playlist(favorite_id):
|
||||
from scrobbles.models import FavoriteMedia
|
||||
@ -576,3 +601,91 @@ def remove_favorite_from_mopidy_playlist(user_id, track_id):
|
||||
track=track,
|
||||
)
|
||||
remove_track_from_mopidy_favorites_playlist(proxy)
|
||||
|
||||
|
||||
@shared_task
|
||||
def add_scrobble_to_mopidy_queue(scrobble_id):
|
||||
from scrobbles.models import Scrobble
|
||||
|
||||
scrobble = Scrobble.objects.filter(id=scrobble_id).first()
|
||||
if not scrobble:
|
||||
return
|
||||
|
||||
profile = scrobble.user.profile
|
||||
mopidy_url = profile.mopidy_api_url
|
||||
if not mopidy_url:
|
||||
return
|
||||
|
||||
mopidy_uri = (scrobble.log or {}).get("raw_data", {}).get("mopidy_uri")
|
||||
track = scrobble.track if scrobble.media_type == "Track" else None
|
||||
if not mopidy_uri and track:
|
||||
sibling = (
|
||||
Scrobble.objects.filter(track=track, user=scrobble.user)
|
||||
.order_by("-timestamp")
|
||||
.iterator()
|
||||
)
|
||||
for s in sibling:
|
||||
uri = (s.log or {}).get("raw_data", {}).get("mopidy_uri")
|
||||
if uri:
|
||||
mopidy_uri = uri
|
||||
break
|
||||
|
||||
if not mopidy_uri:
|
||||
logger.warning(
|
||||
"No Mopidy URI found for scrobble",
|
||||
extra={"scrobble_id": scrobble_id, "user_id": scrobble.user_id},
|
||||
)
|
||||
return
|
||||
|
||||
import requests
|
||||
|
||||
rpc_url = mopidy_url.rstrip("/") + "/rpc"
|
||||
payload = {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "core.tracklist.add",
|
||||
"params": {"uris": [mopidy_uri]},
|
||||
}
|
||||
try:
|
||||
resp = requests.post(rpc_url, json=payload, timeout=10)
|
||||
resp.raise_for_status()
|
||||
rpc_result = resp.json()
|
||||
if rpc_result.get("error"):
|
||||
logger.error(
|
||||
"Mopidy error adding to queue",
|
||||
extra={"error": rpc_result["error"], "scrobble_id": scrobble_id},
|
||||
)
|
||||
else:
|
||||
logger.info(
|
||||
"Added track to Mopidy queue",
|
||||
extra={"scrobble_id": scrobble_id, "mopidy_uri": mopidy_uri},
|
||||
)
|
||||
except requests.RequestException as e:
|
||||
logger.error(
|
||||
"Failed to add track to Mopidy queue",
|
||||
extra={"scrobble_id": scrobble_id, "error": str(e)},
|
||||
)
|
||||
|
||||
|
||||
@shared_task
|
||||
def add_scrobble_to_mopidy_monthly_playlist(scrobble_id):
|
||||
from scrobbles.models import Scrobble
|
||||
from scrobbles.utils import add_track_to_mopidy_monthly_playlist
|
||||
|
||||
scrobble = Scrobble.objects.filter(id=scrobble_id).first()
|
||||
if not scrobble:
|
||||
return
|
||||
|
||||
track = scrobble.track if scrobble.media_type == "Track" else None
|
||||
if track:
|
||||
sibling = (
|
||||
Scrobble.objects.filter(track=track, user=scrobble.user)
|
||||
.order_by("-timestamp")
|
||||
.iterator()
|
||||
)
|
||||
for s in sibling:
|
||||
if (s.log or {}).get("raw_data", {}).get("mopidy_uri"):
|
||||
scrobble = s
|
||||
break
|
||||
|
||||
add_track_to_mopidy_monthly_playlist(scrobble)
|
||||
|
||||
@ -468,9 +468,22 @@ def _ensure_mopidy_playlist(profile):
|
||||
return result
|
||||
|
||||
|
||||
def add_track_to_mopidy_favorites_playlist(favorite):
|
||||
def _scrobble_with_mopidy_uri(track, user):
|
||||
"""Find a scrobble for this track+user that has a mopidy_uri in its log."""
|
||||
from scrobbles.models import Scrobble
|
||||
|
||||
for scrobble in (
|
||||
Scrobble.objects.filter(track=track, user=user)
|
||||
.order_by("-timestamp")
|
||||
.iterator()
|
||||
):
|
||||
raw_data = scrobble.log.get("raw_data") or {}
|
||||
if raw_data.get("mopidy_uri"):
|
||||
return scrobble
|
||||
return None
|
||||
|
||||
|
||||
def add_track_to_mopidy_favorites_playlist(favorite):
|
||||
if favorite.media_type != "Track" or not favorite.track:
|
||||
return
|
||||
|
||||
@ -479,15 +492,7 @@ def add_track_to_mopidy_favorites_playlist(favorite):
|
||||
return
|
||||
|
||||
track = favorite.track
|
||||
scrobble = (
|
||||
Scrobble.objects.filter(
|
||||
track=track,
|
||||
user=favorite.user,
|
||||
log__raw_data__mopidy_uri__isnull=False,
|
||||
)
|
||||
.order_by("-timestamp")
|
||||
.first()
|
||||
)
|
||||
scrobble = _scrobble_with_mopidy_uri(track, favorite.user)
|
||||
|
||||
if not scrobble:
|
||||
logger.warning(
|
||||
@ -496,7 +501,7 @@ def add_track_to_mopidy_favorites_playlist(favorite):
|
||||
)
|
||||
return
|
||||
|
||||
mopidy_uri = scrobble.log["raw_data"]["mopidy_uri"]
|
||||
mopidy_uri = (scrobble.log or {}).get("raw_data", {}).get("mopidy_uri")
|
||||
|
||||
try:
|
||||
playlist = _ensure_mopidy_playlist(profile)
|
||||
@ -557,8 +562,6 @@ def resubmit_favorites_to_mopidy(user):
|
||||
|
||||
|
||||
def remove_track_from_mopidy_favorites_playlist(favorite):
|
||||
from scrobbles.models import Scrobble
|
||||
|
||||
if favorite.media_type != "Track" or not favorite.track:
|
||||
return
|
||||
|
||||
@ -567,15 +570,7 @@ def remove_track_from_mopidy_favorites_playlist(favorite):
|
||||
return
|
||||
|
||||
track = favorite.track
|
||||
scrobble = (
|
||||
Scrobble.objects.filter(
|
||||
track=track,
|
||||
user=favorite.user,
|
||||
log__raw_data__mopidy_uri__isnull=False,
|
||||
)
|
||||
.order_by("-timestamp")
|
||||
.first()
|
||||
)
|
||||
scrobble = _scrobble_with_mopidy_uri(track, favorite.user)
|
||||
|
||||
if not scrobble:
|
||||
logger.warning(
|
||||
@ -584,7 +579,7 @@ def remove_track_from_mopidy_favorites_playlist(favorite):
|
||||
)
|
||||
return
|
||||
|
||||
mopidy_uri = scrobble.log["raw_data"]["mopidy_uri"]
|
||||
mopidy_uri = (scrobble.log or {}).get("raw_data", {}).get("mopidy_uri")
|
||||
|
||||
try:
|
||||
playlist = _ensure_mopidy_playlist(profile)
|
||||
@ -655,7 +650,7 @@ def add_track_to_mopidy_monthly_playlist(scrobble):
|
||||
if not pattern or not profile.mopidy_api_url:
|
||||
return
|
||||
|
||||
mopidy_uri = scrobble.log.get("raw_data", {}).get("mopidy_uri")
|
||||
mopidy_uri = (scrobble.log or {}).get("raw_data", {}).get("mopidy_uri")
|
||||
if not mopidy_uri:
|
||||
return
|
||||
|
||||
@ -807,3 +802,32 @@ def tokenize_title_to_tags(title: str) -> list[str]:
|
||||
w.lower() for w in cleaned.split() if w.lower() not in STOPWORDS and len(w) > 2
|
||||
]
|
||||
return words
|
||||
|
||||
|
||||
def analyze_scrobble_sentiment(scrobble, overwrite=False) -> bool:
|
||||
"""Run VADER sentiment analysis on a scrobble's notes.
|
||||
|
||||
Stores result in log["sentiment"] as a dict with keys:
|
||||
neg, neu, pos, compound.
|
||||
|
||||
Returns True if analyzed, False if skipped (no notes or already done).
|
||||
"""
|
||||
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
|
||||
|
||||
log = scrobble.log or {}
|
||||
if not overwrite and log.get("sentiment") is not None:
|
||||
return False
|
||||
|
||||
notes_str = ""
|
||||
if scrobble.logdata:
|
||||
notes_str = scrobble.logdata.notes_as_str()
|
||||
if not notes_str:
|
||||
return False
|
||||
|
||||
analyzer = SentimentIntensityAnalyzer()
|
||||
scores = analyzer.polarity_scores(notes_str)
|
||||
|
||||
log["sentiment"] = scores
|
||||
scrobble.log = log
|
||||
scrobble.save(update_fields=["log"])
|
||||
return True
|
||||
|
||||
@ -992,46 +992,11 @@ def add_to_mopidy_queue(request, uuid):
|
||||
)
|
||||
return redirect("scrobbles:detail", uuid=uuid)
|
||||
|
||||
raw_data = scrobble.log.get("raw_data", {})
|
||||
mopidy_uri = raw_data.get("mopidy_uri")
|
||||
logger.debug(mopidy_uri)
|
||||
|
||||
if not mopidy_uri:
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.ERROR,
|
||||
"No Mopidy URI found for this scrobble.",
|
||||
)
|
||||
return redirect("scrobbles:detail", uuid=uuid)
|
||||
|
||||
rpc_url = mopidy_url.rstrip("/") + "/rpc"
|
||||
payload = {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"method": "core.tracklist.add",
|
||||
"params": {"uris": [mopidy_uri]},
|
||||
}
|
||||
|
||||
try:
|
||||
resp = requests.post(rpc_url, json=payload, timeout=10)
|
||||
resp.raise_for_status()
|
||||
rpc_result = resp.json()
|
||||
if rpc_result.get("error"):
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.ERROR,
|
||||
f'Mopidy error: {rpc_result["error"]}',
|
||||
)
|
||||
else:
|
||||
msg = f'Added "{scrobble.media_obj}" to Mopidy queue.'
|
||||
messages.add_message(request, messages.SUCCESS, msg)
|
||||
except requests.RequestException as e:
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.ERROR,
|
||||
f"Failed to contact Mopidy: {e}",
|
||||
)
|
||||
from scrobbles.tasks import add_scrobble_to_mopidy_queue as task
|
||||
|
||||
task.delay(scrobble.id)
|
||||
msg = f'Adding "{scrobble.media_obj}" to Mopidy queue.'
|
||||
messages.add_message(request, messages.SUCCESS, msg)
|
||||
return redirect("scrobbles:detail", uuid=uuid)
|
||||
|
||||
|
||||
@ -1055,13 +1020,13 @@ def add_to_mopidy_monthly_playlist(request, uuid):
|
||||
now = now_user_timezone(profile)
|
||||
playlist_name = DateFormat(now).format(pattern)
|
||||
|
||||
from scrobbles.utils import add_track_to_mopidy_monthly_playlist
|
||||
from scrobbles.tasks import add_scrobble_to_mopidy_monthly_playlist as task
|
||||
|
||||
add_track_to_mopidy_monthly_playlist(scrobble)
|
||||
task.delay(scrobble.id)
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.SUCCESS,
|
||||
f'Added "{scrobble.media_obj}" to monthly playlist "{playlist_name}".',
|
||||
f'Adding "{scrobble.media_obj}" to monthly playlist "{playlist_name}".',
|
||||
)
|
||||
return redirect("scrobbles:detail", uuid=uuid)
|
||||
|
||||
@ -1275,6 +1240,17 @@ class ScrobbleDetailView(DetailView):
|
||||
user=self.request.user, **{fk_field: media_obj}
|
||||
).exists()
|
||||
|
||||
if media_type == "Track" and media_obj:
|
||||
scrobbles = Scrobble.objects.filter(
|
||||
track=media_obj, user=self.object.user
|
||||
).order_by("-timestamp")[:20]
|
||||
context["has_mopidy_uri"] = any(
|
||||
(s.log or {}).get("raw_data", {}).get("mopidy_uri")
|
||||
for s in scrobbles
|
||||
)
|
||||
else:
|
||||
context["has_mopidy_uri"] = False
|
||||
|
||||
return context
|
||||
|
||||
|
||||
|
||||
@ -59,19 +59,27 @@ class SportEventAdmin(admin.ModelAdmin):
|
||||
date_hierarchy = "created"
|
||||
list_display = (
|
||||
"title",
|
||||
"league",
|
||||
"event_type",
|
||||
"start",
|
||||
"comp_str",
|
||||
"round",
|
||||
)
|
||||
list_filter = ("round__season", "home_team", "away_team")
|
||||
list_filter = ("league", "event_type")
|
||||
ordering = ("-created",)
|
||||
inlines = [
|
||||
ScrobbleInline,
|
||||
]
|
||||
|
||||
def comp_str(self, obj):
|
||||
if obj.home_team:
|
||||
return f"{obj.away_team} @ {obj.home_team}"
|
||||
if obj.player_one:
|
||||
return f"{obj.player_one} v {obj.player_two}"
|
||||
teams = list(obj.teams.all())
|
||||
if len(teams) >= 2:
|
||||
return f"{teams[1]} v {teams[0]}"
|
||||
|
||||
players = list(obj.players.all())
|
||||
if len(players) >= 2:
|
||||
return f"{players[0]} v {players[1]}"
|
||||
|
||||
if len(players) == 1:
|
||||
return str(players[0])
|
||||
|
||||
if len(teams) == 1:
|
||||
return str(teams[0])
|
||||
|
||||
0
vrobbler/apps/sports/management/__init__.py
Normal file
0
vrobbler/apps/sports/management/__init__.py
Normal file
@ -0,0 +1,36 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from sports.models import League, Team
|
||||
from sports.thesportsdb import enrich_league_logo, enrich_team_logo, has_logo
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Fetch missing league and team logos from TheSportsDB"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
"--dry-run",
|
||||
action="store_true",
|
||||
help="Show what would be done without making changes",
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
dry_run = options["dry_run"]
|
||||
|
||||
leagues = League.objects.filter(thesportsdb_id__isnull=False)
|
||||
for league in leagues:
|
||||
if has_logo(league):
|
||||
continue
|
||||
if dry_run:
|
||||
self.stdout.write(f"Would enrich logo for league: {league.name} ({league.thesportsdb_id})")
|
||||
else:
|
||||
enrich_league_logo(league)
|
||||
|
||||
teams = Team.objects.filter(thesportsdb_id__isnull=False)
|
||||
for team in teams:
|
||||
if has_logo(team):
|
||||
continue
|
||||
if dry_run:
|
||||
self.stdout.write(f"Would enrich logo for team: {team.name} ({team.thesportsdb_id})")
|
||||
else:
|
||||
enrich_team_logo(team)
|
||||
@ -0,0 +1,24 @@
|
||||
# Generated by Django 4.2.30 on 2026-06-06 15:29
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("sports", "0018_alter_sportevent_genre"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="sportevent",
|
||||
name="league",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.DO_NOTHING,
|
||||
to="sports.league",
|
||||
),
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,111 @@
|
||||
import json
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
def canonical_key(event):
|
||||
if event.home_team_id and event.away_team_id:
|
||||
return ("teams", event.league_id, event.home_team_id, event.away_team_id)
|
||||
if event.player_one_id and event.player_two_id:
|
||||
return ("players", event.league_id, event.player_one_id, event.player_two_id)
|
||||
return ("title", event.league_id, event.event_type, (event.title or "").strip())
|
||||
|
||||
|
||||
def build_logdata(event):
|
||||
logdata = {}
|
||||
if event.thesportsdb_id:
|
||||
logdata["thesportsdb_id"] = event.thesportsdb_id
|
||||
if event.start:
|
||||
logdata["start"] = (
|
||||
event.start.isoformat()
|
||||
if hasattr(event.start, "isoformat")
|
||||
else str(event.start)
|
||||
)
|
||||
if event.round:
|
||||
logdata["round_name"] = event.round.name or str(event.round)
|
||||
if event.round.season:
|
||||
logdata["season_name"] = event.round.season.name or str(event.round.season)
|
||||
return logdata
|
||||
|
||||
|
||||
def merge_scrobble_logs(scrobble, logdata):
|
||||
existing_log = scrobble.log or {}
|
||||
if isinstance(existing_log, str):
|
||||
existing_log = json.loads(existing_log)
|
||||
existing_log.update(logdata)
|
||||
scrobble.log = existing_log
|
||||
scrobble.save(update_fields=["log"])
|
||||
|
||||
|
||||
def populate_league(event):
|
||||
if event.league:
|
||||
return
|
||||
if event.round and event.round.season and event.round.season.league:
|
||||
event.league = event.round.season.league
|
||||
event.save(update_fields=["league"])
|
||||
|
||||
|
||||
def populate_m2m(event):
|
||||
if event.home_team_id:
|
||||
event.teams.add(event.home_team_id)
|
||||
if event.away_team_id:
|
||||
event.teams.add(event.away_team_id)
|
||||
if event.player_one_id:
|
||||
event.players.add(event.player_one_id)
|
||||
if event.player_two_id:
|
||||
event.players.add(event.player_two_id)
|
||||
|
||||
|
||||
def migrate_sport_event_data(apps, schema_editor):
|
||||
SportEvent = apps.get_model("sports", "SportEvent")
|
||||
Scrobble = apps.get_model("scrobbles", "Scrobble")
|
||||
db_alias = schema_editor.connection.alias
|
||||
|
||||
canonical_events = {}
|
||||
|
||||
for event in SportEvent.objects.using(db_alias).iterator():
|
||||
populate_league(event)
|
||||
key = canonical_key(event)
|
||||
|
||||
canonical = canonical_events.get(key)
|
||||
if not canonical:
|
||||
canonical_events[key] = event
|
||||
populate_m2m(event)
|
||||
logdata = build_logdata(event)
|
||||
for scrobble in (
|
||||
Scrobble.objects.using(db_alias).filter(sport_event=event).iterator()
|
||||
):
|
||||
merge_scrobble_logs(scrobble, logdata)
|
||||
else:
|
||||
logdata = build_logdata(event)
|
||||
for scrobble in (
|
||||
Scrobble.objects.using(db_alias).filter(sport_event=event).iterator()
|
||||
):
|
||||
scrobble.sport_event = canonical
|
||||
merge_scrobble_logs(scrobble, logdata)
|
||||
scrobble.save(update_fields=["sport_event", "log"])
|
||||
event.delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("sports", "0019_sportevent_league_alter_sportevent_away_team_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="sportevent",
|
||||
name="teams",
|
||||
field=models.ManyToManyField(blank=True, to="sports.team"),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="sportevent",
|
||||
name="players",
|
||||
field=models.ManyToManyField(blank=True, to="sports.player"),
|
||||
),
|
||||
migrations.RunPython(
|
||||
migrate_sport_event_data, reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
||||
20
vrobbler/apps/sports/migrations/0021_team_logo.py
Normal file
20
vrobbler/apps/sports/migrations/0021_team_logo.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Generated by Django 4.2.29 on 2026-06-07 03:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("sports", "0020_migrate_sport_event_data_to_logdata"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="team",
|
||||
name="logo",
|
||||
field=models.ImageField(
|
||||
blank=True, null=True, upload_to="sports/team-logos/"
|
||||
),
|
||||
),
|
||||
]
|
||||
@ -0,0 +1,27 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("sports", "0021_team_logo"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="sportevent",
|
||||
name="home_team",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="sportevent",
|
||||
name="away_team",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="sportevent",
|
||||
name="player_one",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="sportevent",
|
||||
name="player_two",
|
||||
),
|
||||
]
|
||||
@ -68,6 +68,7 @@ class Season(TheSportsDbMixin):
|
||||
|
||||
class Team(TheSportsDbMixin):
|
||||
league = models.ForeignKey(League, on_delete=models.DO_NOTHING, **BNULL)
|
||||
logo = models.ImageField(upload_to="sports/team-logos/", **BNULL)
|
||||
|
||||
|
||||
class Player(TheSportsDbMixin):
|
||||
@ -88,50 +89,61 @@ 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,
|
||||
default=SportEventType.UNKNOWN,
|
||||
)
|
||||
round = models.ForeignKey(Round, on_delete=models.DO_NOTHING, **BNULL)
|
||||
start = models.DateTimeField(**BNULL)
|
||||
home_team = models.ForeignKey(
|
||||
Team,
|
||||
on_delete=models.DO_NOTHING,
|
||||
related_name="home_event_set",
|
||||
**BNULL,
|
||||
)
|
||||
away_team = models.ForeignKey(
|
||||
Team,
|
||||
on_delete=models.DO_NOTHING,
|
||||
related_name="away_event_set",
|
||||
**BNULL,
|
||||
)
|
||||
player_one = models.ForeignKey(
|
||||
Player,
|
||||
on_delete=models.DO_NOTHING,
|
||||
related_name="player_one_set",
|
||||
**BNULL,
|
||||
)
|
||||
player_two = models.ForeignKey(
|
||||
Player,
|
||||
on_delete=models.DO_NOTHING,
|
||||
related_name="player_two_set",
|
||||
**BNULL,
|
||||
)
|
||||
league = models.ForeignKey(League, on_delete=models.DO_NOTHING, **BNULL)
|
||||
|
||||
def __str__(self):
|
||||
return (
|
||||
f"{self.start.date()} - {self.round} - {self.home_team} v {self.away_team}"
|
||||
)
|
||||
@property
|
||||
def logdata_cls(self):
|
||||
from scrobbles.dataclasses import SportEventLogData
|
||||
|
||||
return SportEventLogData
|
||||
|
||||
teams = models.ManyToManyField(Team, blank=True)
|
||||
players = models.ManyToManyField(Player, blank=True)
|
||||
|
||||
# Deprecated - data migrated to scrobble.log via SportEventLogData
|
||||
thesportsdb_id = models.CharField(max_length=255, **BNULL)
|
||||
start = models.DateTimeField(**BNULL)
|
||||
round = models.ForeignKey(Round, on_delete=models.DO_NOTHING, **BNULL)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
old_instance = None
|
||||
try:
|
||||
old_instance = UserProfile.objects.get(pk=self.pk)
|
||||
except:
|
||||
pass
|
||||
|
||||
if not self.title or (old_instance and old_instance.title != self.title):
|
||||
self.title = self.comp_str
|
||||
|
||||
super(SportEvent, self).save(*args, **kwargs)
|
||||
|
||||
def __str__(self) -> str:
|
||||
league = self.league
|
||||
if self.league and self.league.abbreviation_str:
|
||||
league = self.league.abbreviation_str
|
||||
return f"{self.title} - {league}"
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("sports:event_detail", kwargs={"slug": self.uuid})
|
||||
|
||||
@property
|
||||
def subtitle(self):
|
||||
return self.round.season.league
|
||||
def subtitle(self) -> str:
|
||||
return self.comp_str
|
||||
|
||||
@property
|
||||
def comp_str(self) -> str:
|
||||
if self.players.exists():
|
||||
return " v ".join(str(p) for p in self.players.all())
|
||||
|
||||
if self.teams.exists():
|
||||
return " v ".join(str(t) for t in self.teams.all())
|
||||
|
||||
return ""
|
||||
|
||||
@property
|
||||
def strings(self) -> ScrobblableConstants:
|
||||
@ -147,16 +159,17 @@ class SportEvent(ScrobblableMixin):
|
||||
|
||||
@property
|
||||
def primary_image_url(self) -> str:
|
||||
url = ""
|
||||
if self.round.season.league.logo:
|
||||
url = self.round.season.league.logo.url
|
||||
return url
|
||||
if self.league and self.league.logo:
|
||||
return self.league.logo.url
|
||||
return ""
|
||||
|
||||
@classmethod
|
||||
def find_or_create(cls, data_dict: Dict) -> "Event":
|
||||
"""Given a data dict from Jellyfin, does the heavy lifting of looking up
|
||||
the video and, if need, TV Series, creating both if they don't yet
|
||||
exist.
|
||||
def find_or_create(cls, data_dict: Dict) -> tuple["Event", dict]:
|
||||
"""Given a data dict from TheSportsDB, finds or creates a canonical
|
||||
SportEvent by teams, players or title, and returns (event, logdata).
|
||||
|
||||
The logdata dict contains per-scrobble details (thesportsdb_id, start,
|
||||
round/season names) that should be stored in the scrobble's log field.
|
||||
|
||||
"""
|
||||
# Find or create our Sport
|
||||
@ -187,32 +200,29 @@ class SportEvent(ScrobblableMixin):
|
||||
|
||||
# Find or create our Round
|
||||
rid = data_dict.get("RoundId")
|
||||
round, r_created = Round.objects.get_or_create(
|
||||
round_obj, r_created = Round.objects.get_or_create(
|
||||
thesportsdb_id=rid,
|
||||
season=season,
|
||||
name=rid,
|
||||
)
|
||||
if r_created:
|
||||
round.season = season
|
||||
round.save(update_fields=["season"])
|
||||
round_obj.season = season
|
||||
round_obj.save(update_fields=["season"])
|
||||
|
||||
# Set some special data for Tennis
|
||||
player_one = None
|
||||
player_two = None
|
||||
if data_dict.get("Sport") == "Tennis":
|
||||
event_name = data_dict.get("Name", "")
|
||||
if not round.name:
|
||||
round.name = get_round_name_from_event(event_name)
|
||||
round.save(update_fields=["name"])
|
||||
|
||||
players_list = get_players_from_event(event_name)
|
||||
player_one = Player.objects.filter(name__icontains=players_list[0]).first()
|
||||
if not player_one:
|
||||
player_one = Player.objects.create(name=players_list[0])
|
||||
player_two = Player.objects.filter(name__icontains=players_list[1]).first()
|
||||
if not player_two:
|
||||
player_two = Player.objects.create(name=players_list[1])
|
||||
# Build logdata with per-scrobble details
|
||||
logdata = {}
|
||||
logdata["thesportsdb_id"] = data_dict.get("EventId")
|
||||
start = data_dict.get("Start")
|
||||
if start:
|
||||
logdata["start"] = (
|
||||
start.isoformat() if hasattr(start, "isoformat") else str(start)
|
||||
)
|
||||
if round_obj:
|
||||
logdata["round_name"] = round_obj.name or str(round_obj)
|
||||
if round_obj.season:
|
||||
logdata["season_name"] = round_obj.season.name or str(round_obj.season)
|
||||
|
||||
# Look up or create teams/players
|
||||
home_team = None
|
||||
away_team = None
|
||||
if data_dict.get("HomeTeamName"):
|
||||
@ -221,27 +231,73 @@ class SportEvent(ScrobblableMixin):
|
||||
"thesportsdb_id": data_dict.get("HomeTeamId", ""),
|
||||
"league": league,
|
||||
}
|
||||
home_team, _created = Team.objects.get_or_create(**home_team_dict)
|
||||
home_team, ht_created = Team.objects.get_or_create(**home_team_dict)
|
||||
if ht_created:
|
||||
from sports.thesportsdb import enrich_team_logo
|
||||
|
||||
enrich_team_logo(home_team)
|
||||
|
||||
away_team_dict = {
|
||||
"name": data_dict.get("AwayTeamName", ""),
|
||||
"thesportsdb_id": data_dict.get("AwayTeamId", ""),
|
||||
"league": league,
|
||||
}
|
||||
away_team, _created = Team.objects.get_or_create(**away_team_dict)
|
||||
away_team, at_created = Team.objects.get_or_create(**away_team_dict)
|
||||
if at_created:
|
||||
from sports.thesportsdb import enrich_team_logo
|
||||
|
||||
event_dict = {
|
||||
"thesportsdb_id": data_dict.get("EventId"),
|
||||
"title": data_dict.get("Name"),
|
||||
"event_type": sport.default_event_type,
|
||||
"home_team": home_team,
|
||||
"away_team": away_team,
|
||||
"player_one": player_one,
|
||||
"player_two": player_two,
|
||||
"start": data_dict.get("Start"),
|
||||
"round": round,
|
||||
"base_run_time_seconds": data_dict.get("RunTime"),
|
||||
}
|
||||
event, _created = cls.objects.get_or_create(**event_dict)
|
||||
enrich_team_logo(away_team)
|
||||
|
||||
return event
|
||||
players_list = []
|
||||
if data_dict.get("Sport") == "Tennis":
|
||||
event_name = data_dict.get("Name", "")
|
||||
if not round_obj.name:
|
||||
round_obj.name = get_round_name_from_event(event_name)
|
||||
round_obj.save(update_fields=["name"])
|
||||
|
||||
players_list = get_players_from_event(event_name)
|
||||
|
||||
# Find existing canonical event by teams, players, or title
|
||||
event = None
|
||||
if home_team and away_team:
|
||||
event = (
|
||||
cls.objects.filter(league=league, teams=home_team)
|
||||
.filter(teams=away_team)
|
||||
.first()
|
||||
)
|
||||
if not event and players_list:
|
||||
player_objs = []
|
||||
for player_name in players_list:
|
||||
player = Player.objects.filter(name__icontains=player_name).first()
|
||||
if not player:
|
||||
player = Player.objects.create(name=player_name)
|
||||
player_objs.append(player)
|
||||
qs = cls.objects.filter(league=league, players=player_objs[0])
|
||||
for player in player_objs[1:]:
|
||||
qs = qs.filter(players=player)
|
||||
event = qs.first()
|
||||
|
||||
if not event:
|
||||
title = data_dict.get("Name", "").strip()
|
||||
if title:
|
||||
event = cls.objects.filter(league=league, title=title).first()
|
||||
|
||||
if not event:
|
||||
event = cls.objects.create(
|
||||
title=data_dict.get("Name"),
|
||||
event_type=sport.default_event_type,
|
||||
league=league,
|
||||
base_run_time_seconds=data_dict.get("RunTime"),
|
||||
)
|
||||
|
||||
# Ensure M2M is populated on the canonical event
|
||||
if home_team and not event.teams.filter(id=home_team.id).exists():
|
||||
event.teams.add(home_team)
|
||||
if away_team and not event.teams.filter(id=away_team.id).exists():
|
||||
event.teams.add(away_team)
|
||||
for player_name in players_list:
|
||||
player = Player.objects.filter(name__icontains=player_name).first()
|
||||
if player and not event.players.filter(id=player.id).exists():
|
||||
event.players.add(player)
|
||||
|
||||
return event, logdata
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import logging
|
||||
|
||||
import requests
|
||||
from dateutil.parser import parse
|
||||
from django.conf import settings
|
||||
from django.core.files.base import ContentFile
|
||||
from django.utils import timezone
|
||||
from pysportsdb import TheSportsDbClient
|
||||
from sports.models import Sport
|
||||
from sports.models import League, Sport, Team
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -12,6 +14,84 @@ API_KEY = getattr(settings, "THESPORTSDB_API_KEY", "2")
|
||||
client = TheSportsDbClient(api_key=API_KEY)
|
||||
|
||||
|
||||
def has_logo(league_or_team) -> bool:
|
||||
"""Check if a model instance has a logo (handles both NULL and empty string)."""
|
||||
return bool(league_or_team.logo and league_or_team.logo.name)
|
||||
|
||||
|
||||
def enrich_league_logo(league: League) -> None:
|
||||
"""Fetch the league badge from TheSportsDB and save it as the league logo."""
|
||||
if not league.thesportsdb_id or has_logo(league):
|
||||
return
|
||||
|
||||
url = (
|
||||
f"https://www.thesportsdb.com/api/v1/json/{API_KEY}"
|
||||
f"/lookupleague.php?id={league.thesportsdb_id}"
|
||||
)
|
||||
try:
|
||||
resp = requests.get(url, timeout=10)
|
||||
data = resp.json()
|
||||
leagues = data.get("leagues", [])
|
||||
if not leagues:
|
||||
return
|
||||
badge_url = leagues[0].get("strBadge")
|
||||
if badge_url:
|
||||
r = requests.get(badge_url, timeout=10)
|
||||
if r.status_code == 200:
|
||||
fname = f"{league.uuid or league.thesportsdb_id}.png"
|
||||
league.logo.save(fname, ContentFile(r.content), save=True)
|
||||
logger.info(
|
||||
"Saved league logo from TheSportsDB",
|
||||
extra={"league_id": league.id, "league_name": league.name},
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
"Failed to fetch league logo from TheSportsDB",
|
||||
extra={"league_id": league.id, "error": str(e)},
|
||||
)
|
||||
|
||||
|
||||
def enrich_team_logo(team: Team) -> None:
|
||||
"""Fetch the team badge from TheSportsDB and save it as the team logo."""
|
||||
if not team.thesportsdb_id or has_logo(team):
|
||||
return
|
||||
|
||||
try:
|
||||
badge_url = None
|
||||
|
||||
# Try direct lookup by thesportsdb_id first (more reliable)
|
||||
url = (
|
||||
f"https://www.thesportsdb.com/api/v1/json/{API_KEY}"
|
||||
f"/lookupteam.php?id={team.thesportsdb_id}"
|
||||
)
|
||||
resp = requests.get(url, timeout=10)
|
||||
data = resp.json()
|
||||
api_teams = data.get("teams", [])
|
||||
if api_teams:
|
||||
badge_url = api_teams[0].get("strBadge")
|
||||
else:
|
||||
# Fall back to name search
|
||||
result = client.search_teams(team.name) or {}
|
||||
api_teams = result.get("teams", [])
|
||||
if api_teams:
|
||||
badge_url = api_teams[0].get("strBadge")
|
||||
|
||||
if badge_url:
|
||||
r = requests.get(badge_url, timeout=10)
|
||||
if r.status_code == 200:
|
||||
fname = f"{team.uuid or team.thesportsdb_id}.png"
|
||||
team.logo.save(fname, ContentFile(r.content), save=True)
|
||||
logger.info(
|
||||
"Saved team logo from TheSportsDB",
|
||||
extra={"team_id": team.id, "team_name": team.name},
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
"Failed to fetch team logo from TheSportsDB",
|
||||
extra={"team_id": team.id, "error": str(e)},
|
||||
)
|
||||
|
||||
|
||||
def lookup_event_from_thesportsdb(event_id: str) -> dict:
|
||||
|
||||
try:
|
||||
@ -23,6 +103,18 @@ def lookup_event_from_thesportsdb(event_id: str) -> dict:
|
||||
return {}
|
||||
sport, _created = Sport.objects.get_or_create(thesportsdb_id=event.get("strSport"))
|
||||
|
||||
# Find or create the league and optionally enrich its logo
|
||||
lid = event.get("idLeague")
|
||||
league, l_created = League.objects.get_or_create(
|
||||
thesportsdb_id=lid,
|
||||
defaults={"name": event.get("strLeague", "")},
|
||||
)
|
||||
if l_created:
|
||||
league.name = event.get("strLeague", "")
|
||||
league.sport = sport
|
||||
league.save(update_fields=["name", "sport"])
|
||||
enrich_league_logo(league)
|
||||
|
||||
try:
|
||||
start = parse(event.get("strTimestamp"))
|
||||
except:
|
||||
@ -38,7 +130,7 @@ def lookup_event_from_thesportsdb(event_id: str) -> dict:
|
||||
"RunTime": sport.default_event_run_time_seconds,
|
||||
"Sport": event.get("strSport"),
|
||||
"Season": event.get("strSeason"),
|
||||
"LeagueId": event.get("idLeague"),
|
||||
"LeagueId": lid,
|
||||
"LeagueName": event.get("strLeague"),
|
||||
"HomeTeamId": event.get("idHomeTeam"),
|
||||
"HomeTeamName": event.get("strHomeTeam"),
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
from django.views import generic
|
||||
from sports.models import SportEvent
|
||||
from vrobbler.apps.scrobbles.views import ScrobbleableDetailView, ScrobbleableListView
|
||||
|
||||
|
||||
class SportEventListView(generic.ListView):
|
||||
class SportEventListView(ScrobbleableListView):
|
||||
model = SportEvent
|
||||
paginate_by = 50
|
||||
|
||||
|
||||
class SportEventDetailView(generic.DetailView):
|
||||
class SportEventDetailView(ScrobbleableDetailView):
|
||||
model = SportEvent
|
||||
slug_field = "uuid"
|
||||
|
||||
@ -71,6 +71,7 @@ class VideoMetadata:
|
||||
twitch_id: Optional[str] = "",
|
||||
base_run_time_seconds: int = 900,
|
||||
):
|
||||
self.title = ""
|
||||
self.imdb_id = imdb_id
|
||||
self.youtube_id = youtube_id
|
||||
self.twitch_id = twitch_id
|
||||
|
||||
@ -20,6 +20,7 @@ from scrobbles.mixins import (
|
||||
)
|
||||
from taggit.managers import TaggableManager
|
||||
from videos.metadata import VideoMetadata
|
||||
from videos.sources.omdb import lookup_video_from_omdb
|
||||
from videos.sources.tmdb import lookup_video_from_tmdb
|
||||
from videos.sources.youtube import lookup_video_from_youtube
|
||||
|
||||
@ -255,9 +256,22 @@ class Series(TimeStampedModel):
|
||||
logger.info("Series not created and overwrite=False, returning")
|
||||
return series
|
||||
|
||||
vdict, _, cover, genres = lookup_video_from_tmdb(
|
||||
imdb_id
|
||||
).as_dict_with_cover_and_genres()
|
||||
try:
|
||||
metadata = lookup_video_from_tmdb(imdb_id)
|
||||
except Exception as e:
|
||||
logger.warning(f"TMDB lookup failed for series {imdb_id}: {e}")
|
||||
metadata = None
|
||||
|
||||
if not metadata or not metadata.title:
|
||||
metadata = lookup_video_from_omdb(imdb_id)
|
||||
|
||||
if not metadata or not metadata.title:
|
||||
logger.warning(
|
||||
f"No metadata found for series {imdb_id} from TMDB or OMDB"
|
||||
)
|
||||
return series
|
||||
|
||||
vdict, _, cover, genres = metadata.as_dict_with_cover_and_genres()
|
||||
vdict.pop("video_type")
|
||||
|
||||
vdict["name"] = vdict.pop("title")
|
||||
@ -432,9 +446,22 @@ class Video(ScrobblableMixin):
|
||||
if not created and not overwrite:
|
||||
return video
|
||||
|
||||
vdict, series_id, cover, genres = lookup_video_from_tmdb(
|
||||
imdb_id
|
||||
).as_dict_with_cover_and_genres()
|
||||
try:
|
||||
metadata = lookup_video_from_tmdb(imdb_id)
|
||||
except Exception as e:
|
||||
logger.warning(f"TMDB lookup failed for {imdb_id}: {e}")
|
||||
metadata = None
|
||||
|
||||
if not metadata or not metadata.title:
|
||||
metadata = lookup_video_from_omdb(imdb_id)
|
||||
|
||||
if not metadata or not metadata.title:
|
||||
logger.warning(
|
||||
f"No metadata found for {imdb_id} from TMDB or OMDB"
|
||||
)
|
||||
return video
|
||||
|
||||
vdict, series_id, cover, genres = metadata.as_dict_with_cover_and_genres()
|
||||
|
||||
if created or overwrite:
|
||||
for k, v in vdict.items():
|
||||
|
||||
83
vrobbler/apps/videos/sources/omdb.py
Normal file
83
vrobbler/apps/videos/sources/omdb.py
Normal file
@ -0,0 +1,83 @@
|
||||
import logging
|
||||
import re
|
||||
from typing import Optional
|
||||
|
||||
import requests
|
||||
from django.conf import settings
|
||||
from videos.metadata import VideoMetadata, VideoType
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
OMDB_API_KEY = getattr(settings, "OMDB_API_KEY", "")
|
||||
|
||||
OMDB_URL = "https://www.omdbapi.com/"
|
||||
RUNTIME_RE = re.compile(r"(\d+)\s*min")
|
||||
|
||||
|
||||
def lookup_video_from_omdb(imdb_id: str) -> Optional[VideoMetadata]:
|
||||
if not imdb_id.startswith("tt"):
|
||||
imdb_id = f"tt{imdb_id}"
|
||||
|
||||
if not OMDB_API_KEY:
|
||||
logger.warning("No OMDB API key configured")
|
||||
return None
|
||||
|
||||
params = {"apikey": OMDB_API_KEY, "i": imdb_id, "plot": "full"}
|
||||
|
||||
try:
|
||||
response = requests.get(OMDB_URL, params=params)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error(f"OMDB API error for {imdb_id}: {e}")
|
||||
return None
|
||||
|
||||
if data.get("Response") == "False":
|
||||
logger.info(f"OMDB no result for {imdb_id}: {data.get('Error')}")
|
||||
return None
|
||||
|
||||
metadata = VideoMetadata(imdb_id=imdb_id)
|
||||
metadata.title = data.get("Title")
|
||||
metadata.plot = data.get("Plot")
|
||||
metadata.overview = data.get("Plot")
|
||||
|
||||
raw_year = data.get("Year")
|
||||
if raw_year and raw_year.isdigit():
|
||||
metadata.year = int(raw_year)
|
||||
|
||||
raw_rating = data.get("imdbRating")
|
||||
if raw_rating and raw_rating != "N/A":
|
||||
metadata.imdb_rating = raw_rating
|
||||
|
||||
raw_cover = data.get("Poster")
|
||||
if raw_cover and raw_cover != "N/A":
|
||||
metadata.cover_url = raw_cover
|
||||
|
||||
raw_runtime = data.get("Runtime")
|
||||
if raw_runtime:
|
||||
match = RUNTIME_RE.match(raw_runtime)
|
||||
if match:
|
||||
metadata.base_run_time_seconds = int(match.group(1)) * 60
|
||||
|
||||
media_type = data.get("Type")
|
||||
if media_type == "movie":
|
||||
metadata.video_type = VideoType.MOVIE.value
|
||||
elif media_type in ("series", "episode"):
|
||||
metadata.video_type = VideoType.TV_EPISODE.value
|
||||
|
||||
if media_type == "episode":
|
||||
raw_season = data.get("Season")
|
||||
if raw_season and raw_season != "N/A":
|
||||
metadata.season_number = int(raw_season)
|
||||
raw_episode = data.get("Episode")
|
||||
if raw_episode and raw_episode != "N/A":
|
||||
metadata.episode_number = int(raw_episode)
|
||||
series_imdb_id = data.get("seriesID")
|
||||
if series_imdb_id and series_imdb_id != "N/A":
|
||||
metadata.tv_series_imdb_id = series_imdb_id
|
||||
|
||||
raw_genres = data.get("Genre")
|
||||
if raw_genres:
|
||||
metadata.genres = [g.strip() for g in raw_genres.split(",") if g.strip()]
|
||||
|
||||
return metadata
|
||||
@ -3,14 +3,11 @@ import logging
|
||||
import pendulum
|
||||
from django.conf import settings
|
||||
from themoviedb import TMDb
|
||||
from tmdbv3api import TV, Movie, TMDb as TMDb_direct
|
||||
from tmdbv3api import TV, Movie
|
||||
from videos.metadata import VideoMetadata, VideoType
|
||||
|
||||
TMDB_KEY = getattr(settings, "TMDB_API_KEY", "")
|
||||
|
||||
tmdb_direct = TMDb_direct()
|
||||
tmdb_direct.api_key = TMDB_KEY
|
||||
|
||||
tmdb = TMDb(key=TMDB_KEY, language="en-US", region="US")
|
||||
|
||||
TMDB_IMAGE_URL = "https://image.tmdb.org/t/p/original"
|
||||
@ -36,7 +33,7 @@ def lookup_video_from_tmdb(name_or_id: str, kind: str = "movie") -> VideoMetadat
|
||||
video_metadata = VideoMetadata(imdb_id=imdb_id)
|
||||
|
||||
media = None
|
||||
show = None
|
||||
show_data = None
|
||||
if len(tmdb_result.movie_results) > 0:
|
||||
media = Movie().details(tmdb_result.movie_results[0].id)
|
||||
video_metadata.video_type = VideoType.MOVIE.value
|
||||
|
||||
@ -60,6 +60,7 @@ THEAUDIODB_API_KEY = os.getenv("VROBBLER_THEAUDIODB_API_KEY", "2")
|
||||
PODCASTINDEX_API_KEY = os.getenv("VROBBLER_PODCASTINDEX_API_KEY", "")
|
||||
PODCASTINDEX_API_SECRET = os.getenv("VROBBLER_PODCASTINDEX_API_SECRET", "")
|
||||
TMDB_API_KEY = os.getenv("VROBBLER_TMDB_API_KEY", "")
|
||||
OMDB_API_KEY = os.getenv("VROBBLER_OMDB_API_KEY", "")
|
||||
LASTFM_API_KEY = os.getenv("VROBBLER_LASTFM_API_KEY")
|
||||
LASTFM_SECRET_KEY = os.getenv("VROBBLER_LASTFM_SECRET_KEY")
|
||||
IGDB_CLIENT_ID = os.getenv("VROBBLER_IGDB_CLIENT_ID")
|
||||
@ -163,6 +164,10 @@ CELERY_BEAT_SCHEDULE = {
|
||||
"task": "scrobbles.tasks.send_mood_checkin",
|
||||
"schedule": crontab(hour="*/4", minute=0),
|
||||
},
|
||||
"backfill-scrobble-sentiment": {
|
||||
"task": "scrobbles.tasks.backfill_scrobble_sentiment",
|
||||
"schedule": crontab(minute="0"),
|
||||
},
|
||||
}
|
||||
|
||||
INSTALLED_APPS = [
|
||||
|
||||
@ -315,8 +315,7 @@
|
||||
{% for scrobble in now_playing_list %}
|
||||
<div class="now-playing">
|
||||
{% if scrobble.media_obj.primary_image_url %}<div style="float:left;padding-right:10px;padding-bottom:10px;"><img src="{{scrobble.media_obj.primary_image_url}}" /></div>{% endif %}
|
||||
<p><a href="{{scrobble.media_obj.get_absolute_url}}">{{scrobble.media_obj.title}}</a></p>
|
||||
{% if scrobble.media_obj.subtitle %}<p><em><a href="{{scrobble.media_obj.subtitle.get_absolute_url}}">{{scrobble.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
<p><a href="{{scrobble.get_absolute_url}}">{{scrobble.media_obj}}</a></p>
|
||||
{% if scrobble.logdata %}{% if scrobble.logdata.title%}<p><em>{{scrobble.logdata.title}}</em></p>{% endif %}{% endif %}
|
||||
<p><small>{{scrobble.local_timestamp|naturaltime}} from {{scrobble.source}}</small></p>
|
||||
<div class="progress-bar" style="margin-right:5px;">
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
<h2>{{ object.logdata.title }}</h2>
|
||||
{% endif %}
|
||||
<h3 class="text-muted">{{ object.local_timestamp }}</h3>
|
||||
{% if object.media_type == "Track" and object.log.raw_data.mopidy_uri and user.profile.mopidy_api_url %}
|
||||
{% if object.media_type == "Track" and has_mopidy_uri and user.profile.mopidy_api_url %}
|
||||
<form method="post" action="{% url 'scrobbles:add-to-mopidy-queue' object.uuid %}" class="mb-1">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-sm btn-outline-secondary">add to mopidy queue</button>
|
||||
@ -154,6 +154,20 @@
|
||||
{% if notes_html %}
|
||||
<div class="mb-3">
|
||||
<h4>Notes</h4>
|
||||
<span class="badge fs-8
|
||||
{% if sentiment.compound >= 0.5 %}bg-success
|
||||
{% elif sentiment.compound >= 0.05 %}bg-info text-dark
|
||||
{% elif sentiment.compound > -0.05 %}bg-secondary
|
||||
{% elif sentiment.compound > -0.5 %}bg-warning text-dark
|
||||
{% else %}bg-danger
|
||||
{% endif %}">
|
||||
{% if sentiment.compound >= 0.5 %}Positive
|
||||
{% elif sentiment.compound >= 0.05 %}Slightly positive
|
||||
{% elif sentiment.compound > -0.05 %}Neutral
|
||||
{% elif sentiment.compound > -0.5 %}Slightly negative
|
||||
{% else %}Negative
|
||||
{% endif %}
|
||||
</span>
|
||||
<div class="notes-list">
|
||||
{{ notes_html|safe }}
|
||||
</div>
|
||||
@ -161,6 +175,13 @@
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% with sentiment=object.log.sentiment %}
|
||||
{% if sentiment %}
|
||||
<div class="mb-3">
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
{% if object.logdata.avg_seconds_per_page %}
|
||||
<p>Rate: {{object.logdata.avg_seconds_per_page}}s per page</p>
|
||||
{% endif %}
|
||||
|
||||
@ -110,7 +110,7 @@
|
||||
{% if sporting %}
|
||||
<div class="titles">
|
||||
<p><a href="{{sporting.media_obj.get_absolute_url}}">{{sporting.media_obj}}</a></p>
|
||||
{% if sporting.media_obj.subtitle %}<p><em><a href="{{sporting.media_obj.subtitle.get_absolute_url}}">{{sporting.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
{% if sporting.media_obj.subtitle %}<p><em><a href="{{sporting.get_absolute_url}}">{{sporting.media_obj.subtitle}}</a></em></p>{% endif %}
|
||||
</div>
|
||||
<p><small>{{sporting.timestamp|naturaltime}} from {{sporting.source}}</small></p>
|
||||
{% else %}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
{% extends "base_detail.html" %}
|
||||
|
||||
{% block title %}{{object.title}} - {{object.round.season.league}}{% endblock %}
|
||||
{% block title %}{{object}}{% endblock %}
|
||||
|
||||
{% block details %}
|
||||
<h2>{{object.subtitle}}</h2>
|
||||
|
||||
<div class="row">
|
||||
<h2>{{object.tv_series}}</h2>
|
||||
|
||||
Reference in New Issue
Block a user