Fix users not being added to tsv and lastfm imports
This commit is contained in:
@ -90,7 +90,7 @@ class LastFM:
|
||||
return created
|
||||
|
||||
@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"""
|
||||
from scrobbles.models import Scrobble
|
||||
|
||||
@ -155,6 +155,7 @@ class LastFM:
|
||||
logger.info(f"{artist},{scrobble.track.title},{timestamp}")
|
||||
scrobbles.append(
|
||||
{
|
||||
"user": self.vrobbler_user,
|
||||
"artist": artist,
|
||||
"album": scrobble.album,
|
||||
"title": scrobble.track.title,
|
||||
|
||||
@ -48,7 +48,7 @@ class AudioScrobblerTSVImport(TimeStampedModel):
|
||||
if self.user:
|
||||
tz = self.user.profile.tzinfo
|
||||
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 = ""
|
||||
if scrobbles:
|
||||
|
||||
@ -13,7 +13,7 @@ from music.utils import (
|
||||
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"""
|
||||
new_scrobbles = []
|
||||
if not user_tz:
|
||||
@ -55,6 +55,7 @@ def process_audioscrobbler_tsv_file(file_path, user_tz=None):
|
||||
)
|
||||
|
||||
new_scrobble = Scrobble(
|
||||
user_id=user_id,
|
||||
timestamp=timestamp,
|
||||
source=source,
|
||||
source_id=source_id,
|
||||
@ -79,7 +80,7 @@ def process_audioscrobbler_tsv_file(file_path, user_tz=None):
|
||||
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"""
|
||||
if not process_log:
|
||||
logger.warning("No lines in process log found to undo")
|
||||
|
||||
Reference in New Issue
Block a user