mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
38f1981283
- Move all backend files from swingmusic/ to root level - Backend files now display directly on GitHub repository page - Keep client applications as submodules (swingmusic-android, swingmusic-desktop, swingmusic-webclient) - Update README to reflect new structure (no cd swingmusic needed) - Cleaner, more professional GitHub repository layout Files moved to root: - src/ (main source code) - pyproject.toml, requirements.txt, run.py - swingmusic.spec, uv.lock, version.txt - services/ Result: GitHub shows backend files directly while maintaining organized structure
36 lines
969 B
Python
36 lines
969 B
Python
from datetime import datetime
|
|
|
|
from swingmusic.db.userdata import ScrobbleTable
|
|
from swingmusic.models.playlist import Playlist
|
|
from swingmusic.lib.playlistlib import get_first_4_images
|
|
from swingmusic.utils.dates import (
|
|
create_new_date,
|
|
date_string_to_time_passed,
|
|
)
|
|
|
|
from swingmusic.store.tracks import TrackStore
|
|
|
|
|
|
def get_recently_played_playlist(limit: int = 100):
|
|
playlist = Playlist(
|
|
id="recentlyplayed",
|
|
name="Recently Played",
|
|
image=None,
|
|
last_updated="Now",
|
|
settings={},
|
|
trackhashes=[],
|
|
)
|
|
|
|
scrobbles = ScrobbleTable.get_all(None, 100)
|
|
tracks = TrackStore.get_tracks_by_trackhashes(
|
|
[scrobble.trackhash for scrobble in scrobbles]
|
|
)
|
|
|
|
date = datetime.fromtimestamp(tracks[0].lastplayed)
|
|
playlist._last_updated = date_string_to_time_passed(create_new_date(date))
|
|
|
|
images = get_first_4_images(tracks=tracks)
|
|
playlist.images = images
|
|
|
|
return playlist, tracks
|