Bladeren bron

[scrobbles] Remove source_id field

Colin Powell 1 jaar geleden
bovenliggende
commit
20dd4d217a

+ 0 - 2
vrobbler/apps/music/lastfm.py

@@ -46,7 +46,6 @@ class LastFM:
 
         new_scrobbles = []
         source = "Last.fm"
-        source_id = ""
         lastfm_scrobbles = self.get_last_scrobbles(time_from=last_processed)
 
         for lfm_scrobble in lastfm_scrobbles:
@@ -64,7 +63,6 @@ class LastFM:
                 user=self.vrobbler_user,
                 timestamp=timestamp,
                 source=source,
-                source_id=source_id,
                 track=track,
                 played_to_completion=True,
                 in_progress=False,

+ 1 - 1
vrobbler/apps/scrobbles/admin.py

@@ -26,7 +26,7 @@ class ScrobbleInline(admin.TabularInline):
         "web_page",
         "user",
     )
-    exclude = ("source_id", "scrobble_log")
+    exclude = ("scrobble_log",)
 
 
 class ImportBaseAdmin(admin.ModelAdmin):

+ 17 - 0
vrobbler/apps/scrobbles/migrations/0053_remove_scrobble_source_id.py

@@ -0,0 +1,17 @@
+# Generated by Django 4.2.9 on 2024-04-19 18:57
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("scrobbles", "0052_alter_scrobble_scroble_log"),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name="scrobble",
+            name="source_id",
+        ),
+    ]

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

@@ -522,7 +522,6 @@ class Scrobble(TimeStampedModel):
 
     # Metadata
     source = models.CharField(max_length=255, **BNULL)
-    source_id = models.TextField(**BNULL)
     scrobble_log = models.JSONField(**BNULL)
     notes = models.TextField(**BNULL)
     timezone = models.CharField(max_length=50, **BNULL)
@@ -864,7 +863,7 @@ class Scrobble(TimeStampedModel):
             .order_by("-timestamp")
             .first()
         )
-        source = scrobble_data["source"]
+        source = scrobble_data.get("source")
         mtype = media.__class__.__name__
         mopidy_status = scrobble_data.get("mopidy_status", None)
 

+ 1 - 5
vrobbler/apps/scrobbles/scrobblers.py

@@ -141,7 +141,7 @@ def build_scrobble_dict(data_dict: dict, user_id: int) -> dict:
         "timestamp": parse(data_dict.get("UtcTimestamp")),
         "playback_position_seconds": playback_seconds,
         "source": data_dict.get("ClientName", "Vrobbler"),
-        "source_id": data_dict.get("MediaSourceId"),
+        "scrobble_log": {"media_source_id": data_dict.get("MediaSourceId")},
         "jellyfin_status": jellyfin_status,
     }
 
@@ -218,7 +218,6 @@ def manual_scrobble_video(imdb_id: str, user_id: int):
         "timestamp": timezone.now(),
         "playback_position_seconds": 0,
         "source": source,
-        "source_id": "Manually scrobbled from Vrobbler and looked up via IMDB",
     }
 
     logger.info(
@@ -253,7 +252,6 @@ def manual_scrobble_video_game(hltb_id: str, user_id: int):
         "timestamp": timezone.now(),
         "playback_position_seconds": 0,
         "source": "Vrobbler",
-        "source_id": "Manually scrobbled from Vrobbler and looked up via HLTB.com",
         "long_play_complete": False,
     }
 
@@ -306,7 +304,6 @@ def manual_scrobble_board_game(bggeek_id: str, user_id: int):
         "timestamp": timezone.now(),
         "playback_position_seconds": 0,
         "source": "Vrobbler",
-        "source_id": "Manually scrobbled from Vrobbler and looked up via boardgamegeek.com",
     }
     logger.info(
         "[webhook] board game scrobble request received",
@@ -329,7 +326,6 @@ def manual_scrobble_webpage(url: str, user_id: int):
         "timestamp": timezone.now(),
         "playback_position_seconds": 0,
         "source": "Vrobbler",
-        "source_id": "Manually scrobbled from Vrobbler",
     }
     logger.info(
         "[webhook] webpage scrobble request received",

+ 3 - 3
vrobbler/apps/scrobbles/tsv.py

@@ -35,12 +35,12 @@ def process_audioscrobbler_tsv_file(file_path, user_id, user_tz=None):
     source = "Audioscrobbler File"
     rows = csv.reader(tsv_data, delimiter="\t")
 
-    source_id = ""
+    rockbox_info = ""
     for row_num, row in enumerate(rows):
         if row_num in [0, 1, 2]:
             if "Rockbox" in row[0]:
                 source = "Rockbox"
-            source_id += row[0] + "\n"
+            rockbox_info += row[0] + "\n"
             continue
         if len(row) > 8:
             logger.warning(
@@ -75,7 +75,7 @@ def process_audioscrobbler_tsv_file(file_path, user_id, user_tz=None):
             user_id=user_id,
             timestamp=timestamp,
             source=source,
-            source_id=source_id,
+            scrobble_log={"rockbox_info": rockbox_info}
             track=track,
             played_to_completion=True,
             in_progress=False,

+ 0 - 1
vrobbler/apps/videogames/retroarch.py

@@ -169,7 +169,6 @@ def import_retroarch_lrtl_files(playlog_path: str, user_id: int) -> List[dict]:
                 long_play_complete=long_play_complete,
                 user_id=user_id,
                 source="Retroarch",
-                source_id="Imported from Retroarch play log file",
                 media_type=Scrobble.MediaType.VIDEO_GAME,
             )
         )