[scrobbles] Remove source_id field

This commit is contained in:
2024-04-19 14:57:27 -04:00
parent 53657a9454
commit 20dd4d217a
7 changed files with 23 additions and 14 deletions

View File

@ -46,7 +46,6 @@ class LastFM:
new_scrobbles = [] new_scrobbles = []
source = "Last.fm" source = "Last.fm"
source_id = ""
lastfm_scrobbles = self.get_last_scrobbles(time_from=last_processed) lastfm_scrobbles = self.get_last_scrobbles(time_from=last_processed)
for lfm_scrobble in lastfm_scrobbles: for lfm_scrobble in lastfm_scrobbles:
@ -64,7 +63,6 @@ class LastFM:
user=self.vrobbler_user, user=self.vrobbler_user,
timestamp=timestamp, timestamp=timestamp,
source=source, source=source,
source_id=source_id,
track=track, track=track,
played_to_completion=True, played_to_completion=True,
in_progress=False, in_progress=False,

View File

@ -26,7 +26,7 @@ class ScrobbleInline(admin.TabularInline):
"web_page", "web_page",
"user", "user",
) )
exclude = ("source_id", "scrobble_log") exclude = ("scrobble_log",)
class ImportBaseAdmin(admin.ModelAdmin): class ImportBaseAdmin(admin.ModelAdmin):

View File

@ -0,0 +1,17 @@
# Generated by Django 4.2.9 on 2024-04-19 18:57
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("scrobbles", "0052_alter_scrobble_scroble_log"),
]
operations = [
migrations.RemoveField(
model_name="scrobble",
name="source_id",
),
]

View File

@ -522,7 +522,6 @@ class Scrobble(TimeStampedModel):
# Metadata # Metadata
source = models.CharField(max_length=255, **BNULL) source = models.CharField(max_length=255, **BNULL)
source_id = models.TextField(**BNULL)
scrobble_log = models.JSONField(**BNULL) scrobble_log = models.JSONField(**BNULL)
notes = models.TextField(**BNULL) notes = models.TextField(**BNULL)
timezone = models.CharField(max_length=50, **BNULL) timezone = models.CharField(max_length=50, **BNULL)
@ -864,7 +863,7 @@ class Scrobble(TimeStampedModel):
.order_by("-timestamp") .order_by("-timestamp")
.first() .first()
) )
source = scrobble_data["source"] source = scrobble_data.get("source")
mtype = media.__class__.__name__ mtype = media.__class__.__name__
mopidy_status = scrobble_data.get("mopidy_status", None) mopidy_status = scrobble_data.get("mopidy_status", None)

View File

@ -141,7 +141,7 @@ def build_scrobble_dict(data_dict: dict, user_id: int) -> dict:
"timestamp": parse(data_dict.get("UtcTimestamp")), "timestamp": parse(data_dict.get("UtcTimestamp")),
"playback_position_seconds": playback_seconds, "playback_position_seconds": playback_seconds,
"source": data_dict.get("ClientName", "Vrobbler"), "source": data_dict.get("ClientName", "Vrobbler"),
"source_id": data_dict.get("MediaSourceId"), "scrobble_log": {"media_source_id": data_dict.get("MediaSourceId")},
"jellyfin_status": jellyfin_status, "jellyfin_status": jellyfin_status,
} }
@ -218,7 +218,6 @@ def manual_scrobble_video(imdb_id: str, user_id: int):
"timestamp": timezone.now(), "timestamp": timezone.now(),
"playback_position_seconds": 0, "playback_position_seconds": 0,
"source": source, "source": source,
"source_id": "Manually scrobbled from Vrobbler and looked up via IMDB",
} }
logger.info( logger.info(
@ -253,7 +252,6 @@ def manual_scrobble_video_game(hltb_id: str, user_id: int):
"timestamp": timezone.now(), "timestamp": timezone.now(),
"playback_position_seconds": 0, "playback_position_seconds": 0,
"source": "Vrobbler", "source": "Vrobbler",
"source_id": "Manually scrobbled from Vrobbler and looked up via HLTB.com",
"long_play_complete": False, "long_play_complete": False,
} }
@ -306,7 +304,6 @@ def manual_scrobble_board_game(bggeek_id: str, user_id: int):
"timestamp": timezone.now(), "timestamp": timezone.now(),
"playback_position_seconds": 0, "playback_position_seconds": 0,
"source": "Vrobbler", "source": "Vrobbler",
"source_id": "Manually scrobbled from Vrobbler and looked up via boardgamegeek.com",
} }
logger.info( logger.info(
"[webhook] board game scrobble request received", "[webhook] board game scrobble request received",
@ -329,7 +326,6 @@ def manual_scrobble_webpage(url: str, user_id: int):
"timestamp": timezone.now(), "timestamp": timezone.now(),
"playback_position_seconds": 0, "playback_position_seconds": 0,
"source": "Vrobbler", "source": "Vrobbler",
"source_id": "Manually scrobbled from Vrobbler",
} }
logger.info( logger.info(
"[webhook] webpage scrobble request received", "[webhook] webpage scrobble request received",

View File

@ -35,12 +35,12 @@ def process_audioscrobbler_tsv_file(file_path, user_id, user_tz=None):
source = "Audioscrobbler File" source = "Audioscrobbler File"
rows = csv.reader(tsv_data, delimiter="\t") rows = csv.reader(tsv_data, delimiter="\t")
source_id = "" rockbox_info = ""
for row_num, row in enumerate(rows): for row_num, row in enumerate(rows):
if row_num in [0, 1, 2]: if row_num in [0, 1, 2]:
if "Rockbox" in row[0]: if "Rockbox" in row[0]:
source = "Rockbox" source = "Rockbox"
source_id += row[0] + "\n" rockbox_info += row[0] + "\n"
continue continue
if len(row) > 8: if len(row) > 8:
logger.warning( logger.warning(
@ -75,7 +75,7 @@ def process_audioscrobbler_tsv_file(file_path, user_id, user_tz=None):
user_id=user_id, user_id=user_id,
timestamp=timestamp, timestamp=timestamp,
source=source, source=source,
source_id=source_id, scrobble_log={"rockbox_info": rockbox_info}
track=track, track=track,
played_to_completion=True, played_to_completion=True,
in_progress=False, in_progress=False,

View File

@ -169,7 +169,6 @@ def import_retroarch_lrtl_files(playlog_path: str, user_id: int) -> List[dict]:
long_play_complete=long_play_complete, long_play_complete=long_play_complete,
user_id=user_id, user_id=user_id,
source="Retroarch", source="Retroarch",
source_id="Imported from Retroarch play log file",
media_type=Scrobble.MediaType.VIDEO_GAME, media_type=Scrobble.MediaType.VIDEO_GAME,
) )
) )