Fix audioscrobbler import bug

Issue was not having a user so we couldn't set a timezone. All fixed now
This commit is contained in:
2023-02-06 19:30:58 -05:00
parent 0c10e78d5e
commit 117157e3ae
5 changed files with 51 additions and 4 deletions

View File

@ -24,6 +24,7 @@ class AudioScrobblerTSVImport(TimeStampedModel):
uuid = instance.uuid
return f'audioscrobbler-uploads/{uuid}.{extension}'
user = models.ForeignKey(User, on_delete=models.DO_NOTHING, **BNULL)
uuid = models.UUIDField(editable=False, default=uuid4)
tsv_file = models.FileField(upload_to=get_path, **BNULL)
processed_on = models.DateTimeField(**BNULL)
@ -48,7 +49,10 @@ class AudioScrobblerTSVImport(TimeStampedModel):
logger.info(f"{self} already processed on {self.processed_on}")
return
scrobbles = process_audioscrobbler_tsv_file(self.tsv_file.path)
tz = None
if self.user:
tz = self.user.profile.tzinfo
scrobbles = process_audioscrobbler_tsv_file(self.tsv_file.path, tz=tz)
if scrobbles:
self.process_log = f"Created {len(scrobbles)} scrobbles"
for scrobble in scrobbles: