fix keyError

This commit is contained in:
cwilvx
2024-11-17 20:06:08 +01:00
parent dd2bb16a8c
commit 9de991dd98
+2 -46
View File
@@ -1,5 +1,4 @@
from datetime import datetime
from time import time
from app.lib.playlistlib import get_first_4_images
from app.models.playlist import Playlist
@@ -9,17 +8,12 @@ from app.store.tracks import TrackStore
from app.store.albums import AlbumStore
from app.store.artists import ArtistStore
from app.serializers.track import serialize_track
from app.serializers.album import album_serializer
from app.serializers.artist import serialize_for_card
from itertools import groupby
from app.utils import flatten
from app.utils.dates import (
create_new_date,
date_string_to_time_passed,
timestamp_to_time_passed,
)
older_albums = set()
@@ -65,14 +59,6 @@ def create_track(t: Track):
"timestamp": t.last_mod,
"help_text": "NEW TRACK",
}
# track = serialize_track(t, to_remove={"created_date"})
# track["help_text"] = "NEW TRACK"
# return {
# "type": "track",
# "item": track,
# }
# INFO: Keys: folder, tracks, time (timestamp)
# group_type = dict[str, str | list[Track] | float]
@@ -89,7 +75,7 @@ def check_folder_type(group_: dict):
if len(tracks) == 1:
entry = create_track(tracks[0])
entry["item"]["time"] = timestamp_to_time_passed(time)
entry["timestamp"] = time
return entry
is_album, albumhash, _ = check_is_album_folder(tracks)
@@ -100,18 +86,6 @@ def check_folder_type(group_: dict):
if entry is None:
return None
# album = album_serializer(
# entry.album,
# to_remove={
# "genres",
# "og_title",
# "date",
# "duration",
# "count",
# "albumartists_hashes",
# "base_title",
# },
# )
return {
"type": "album",
"hash": albumhash,
@@ -127,7 +101,7 @@ def check_folder_type(group_: dict):
if entry is None:
return None
return {
"type": "artist",
"hash": artisthash,
@@ -137,18 +111,6 @@ def check_folder_type(group_: dict):
),
}
# artist = serialize_for_card(entry.artist)
# artist["trackcount"] = trackcount
# artist["help_text"] = (
# "NEW ARTIST" if artisthash not in existing_artist_hashes else "NEW MUSIC"
# )
# artist["time"] = timestamp_to_time_passed(time)
# return {
# "type": "artist",
# "item": artist,
# }
is_track_folder = check_is_track_folder(tracks)
return (
@@ -159,12 +121,6 @@ def check_folder_type(group_: dict):
"hash": key,
"timestamp": time,
"help_text": "NEW MUSIC",
# "item": {
# "path": key,
# "count": len(tracks),
# "help_text": "NEW MUSIC",
# "time": timestamp_to_time_passed(time),
# },
}
)