Explorar o código

[scrobbles] Fix when scrobble has not dict

Colin Powell hai 9 meses
pai
achega
ed917e16fc
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      vrobbler/apps/scrobbles/models.py

+ 5 - 0
vrobbler/apps/scrobbles/models.py

@@ -542,6 +542,7 @@ class Scrobble(TimeStampedModel):
     source = models.CharField(max_length=255, **BNULL)
     log = models.JSONField(
         **BNULL,
+        default=dict,
         encoder=logdata.ScrobbleLogDataEncoder,
         decoder=logdata.ScrobbleLogDataDecoder,
     )
@@ -626,6 +627,10 @@ class Scrobble(TimeStampedModel):
                 extra={"log": self.log},
             )
             log_dict = json.loads(self.log)
+
+        if not log_dict:
+            log_dict = {}
+
         return self.media_obj.logdata_cls.from_dict(log_dict)
 
     def redirect_url(self, user_id) -> str: