Преглед на файлове

Fix users not being added to tsv and lastfm imports

Colin Powell преди 2 години
родител
ревизия
0db5bbe36c
променени са 3 файла, в които са добавени 6 реда и са изтрити 4 реда
  1. 2 1
      vrobbler/apps/scrobbles/lastfm.py
  2. 1 1
      vrobbler/apps/scrobbles/models.py
  3. 3 2
      vrobbler/apps/scrobbles/tsv.py

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

@@ -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,

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

@@ -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:

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

@@ -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")