瀏覽代碼

Add sportsdb event id to scrobbles

Colin Powell 2 年之前
父節點
當前提交
40a126cf8b

+ 1 - 0
vrobbler/apps/scrobbles/thesportsdb.py

@@ -24,6 +24,7 @@ def lookup_event_from_thesportsdb(event_id: str) -> dict:
     )
 
     data_dict = {
+        "EventId": event_id,
         "ItemType": sport.default_event_type,
         "Name": event.get('strEvent'),
         "AltName": event.get('strEventAlternate'),

+ 18 - 0
vrobbler/apps/sports/migrations/0008_sportevent_thesportsdb_id.py

@@ -0,0 +1,18 @@
+# Generated by Django 4.1.5 on 2023-02-23 15:51
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('sports', '0007_sport_default_event_type'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='sportevent',
+            name='thesportsdb_id',
+            field=models.CharField(blank=True, max_length=255, null=True),
+        ),
+    ]

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

@@ -15,8 +15,9 @@ BNULL = {"blank": True, "null": True}
 
 
 class SportEventType(models.TextChoices):
-    UNKNOWN = 'UK', _('Unknown')
+    UNKNOWN = 'UK', _('Event')
     GAME = 'GA', _('Game')
+    RACE = 'RA', _('Race')
     MATCH = 'MA', _('Match')
 
 
@@ -221,6 +222,7 @@ class SportEvent(ScrobblableMixin):
             away_team, _created = Team.objects.get_or_create(**away_team_dict)
 
         event_dict = {
+            "thesportsdb_id": data_dict.get("EventId"),
             "title": data_dict.get("Name"),
             "event_type": sport.default_event_type,
             "home_team": home_team,