Fix users not being added to tsv and lastfm imports

This commit is contained in:
2023-02-17 14:05:06 -05:00
parent 69b6364f88
commit 0db5bbe36c
3 changed files with 6 additions and 4 deletions

View File

@ -90,7 +90,7 @@ class LastFM:
return created return created
@staticmethod @staticmethod
def undo_lastfm_import(process_log, dryrun=True): def undo_lastfm_import(process_log, dryrun=False):
"""Given a newline separated list of scrobbles, delete them""" """Given a newline separated list of scrobbles, delete them"""
from scrobbles.models import Scrobble from scrobbles.models import Scrobble
@ -155,6 +155,7 @@ class LastFM:
logger.info(f"{artist},{scrobble.track.title},{timestamp}") logger.info(f"{artist},{scrobble.track.title},{timestamp}")
scrobbles.append( scrobbles.append(
{ {
"user": self.vrobbler_user,
"artist": artist, "artist": artist,
"album": scrobble.album, "album": scrobble.album,
"title": scrobble.track.title, "title": scrobble.track.title,

View File

@ -48,7 +48,7 @@ class AudioScrobblerTSVImport(TimeStampedModel):
if self.user: if self.user:
tz = self.user.profile.tzinfo tz = self.user.profile.tzinfo
scrobbles = process_audioscrobbler_tsv_file( scrobbles = process_audioscrobbler_tsv_file(
self.tsv_file.path, user_tz=tz self.tsv_file.path, self.user.id, user_tz=tz
) )
self.process_log = "" self.process_log = ""
if scrobbles: if scrobbles:

View File

@ -13,7 +13,7 @@ from music.utils import (
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def process_audioscrobbler_tsv_file(file_path, user_tz=None): def process_audioscrobbler_tsv_file(file_path, user_id, user_tz=None):
"""Takes a path to a file of TSV data and imports it as past scrobbles""" """Takes a path to a file of TSV data and imports it as past scrobbles"""
new_scrobbles = [] new_scrobbles = []
if not user_tz: if not user_tz:
@ -55,6 +55,7 @@ def process_audioscrobbler_tsv_file(file_path, user_tz=None):
) )
new_scrobble = Scrobble( new_scrobble = Scrobble(
user_id=user_id,
timestamp=timestamp, timestamp=timestamp,
source=source, source=source,
source_id=source_id, source_id=source_id,
@ -79,7 +80,7 @@ def process_audioscrobbler_tsv_file(file_path, user_tz=None):
return created return created
def undo_audioscrobbler_tsv_import(process_log, dryrun=True): def undo_audioscrobbler_tsv_import(process_log, dryrun=False):
"""Accepts the log from a TSV import and removes the scrobbles""" """Accepts the log from a TSV import and removes the scrobbles"""
if not process_log: if not process_log:
logger.warning("No lines in process log found to undo") logger.warning("No lines in process log found to undo")