move recently added to routines

This commit is contained in:
cwilvx
2024-11-17 20:08:04 +03:00
parent 498d0688b0
commit 333fd6603f
14 changed files with 554 additions and 213 deletions
+54 -37
View File
@@ -59,13 +59,19 @@ def create_track(t: Track):
"""
Creates a recently added track entry.
"""
track = serialize_track(t, to_remove={"created_date"})
track["help_text"] = "NEW TRACK"
return {
"type": "track",
"item": track,
"hash": t.trackhash,
"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)
@@ -94,26 +100,25 @@ 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",
},
)
album["help_text"] = (
"NEW ALBUM" if albumhash in existing_album_hashes else "NEW TRACKS"
)
album["time"] = timestamp_to_time_passed(time)
# album = album_serializer(
# entry.album,
# to_remove={
# "genres",
# "og_title",
# "date",
# "duration",
# "count",
# "albumartists_hashes",
# "base_title",
# },
# )
return {
"type": "album",
"item": album,
"hash": albumhash,
"timestamp": time,
"help_text": (
"NEW ALBUM" if albumhash in existing_album_hashes else "NEW TRACKS"
),
}
is_artist, artisthash, trackcount = check_is_artist_folder(tracks)
@@ -122,19 +127,28 @@ def check_folder_type(group_: dict):
if entry is None:
return None
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,
"hash": artisthash,
"timestamp": time,
"help_text": (
"NEW ARTIST" if artisthash not in existing_artist_hashes else "NEW MUSIC"
),
}
# 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 (
@@ -142,12 +156,15 @@ def check_folder_type(group_: dict):
if is_track_folder
else {
"type": "folder",
"item": {
"path": key,
"count": len(tracks),
"help_text": "NEW MUSIC",
"time": timestamp_to_time_passed(time),
},
"hash": key,
"timestamp": time,
"help_text": "NEW MUSIC",
# "item": {
# "path": key,
# "count": len(tracks),
# "help_text": "NEW MUSIC",
# "time": timestamp_to_time_passed(time),
# },
}
)