From 32a900cf3700f1aed86b0615b8f18fcf53ef7954 Mon Sep 17 00:00:00 2001 From: krateng Date: Tue, 19 Apr 2022 00:11:40 +0200 Subject: [PATCH] Fixed error for Lastfm import and added feedback, fix GH-118 --- maloja/proccontrol/tasks/import_scrobbles.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/maloja/proccontrol/tasks/import_scrobbles.py b/maloja/proccontrol/tasks/import_scrobbles.py index fec1f83..c9d98a6 100644 --- a/maloja/proccontrol/tasks/import_scrobbles.py +++ b/maloja/proccontrol/tasks/import_scrobbles.py @@ -268,11 +268,17 @@ def parse_lastfm(inputf): with open(inputf,'r',newline='') as inputfd: reader = csv.reader(inputfd) + line = 0 for row in reader: + line += 1 try: artist,album,title,time = row except ValueError: - yield ('FAIL',None,f"{row} does not look like a valid entry. Scrobble not imported.") + yield ('FAIL',None,f"{row} (Line {line}) does not look like a valid entry. Scrobble not imported.") + continue + + if time == '': + yield ('FAIL',None,f"{row} (Line {line}) is missing a timestamp.") continue try: @@ -287,7 +293,7 @@ def parse_lastfm(inputf): 'scrobble_duration':None },'') except Exception as e: - yield ('FAIL',None,f"{entry} could not be parsed. Scrobble not imported. ({repr(e)})") + yield ('FAIL',None,f"{row} (Line {line}) could not be parsed. Scrobble not imported. ({repr(e)})") continue