from server.artist.soundcloud.repositories import SoundCloudRepo as ArtistSoundCloudRepo from server.core.repositories import ESRepo from server.db.constants import TRACK_SEARCH_INDEX class SoundCloudRepo: artist_repo = ArtistSoundCloudRepo @classmethod async def get_tracks(cls, _id: str, limit: int = 6) -> list: artist = await ESRepo.get(id=_id, index=TRACK_SEARCH_INDEX) if not artist: return [] results: list = await cls.artist_repo.get_tracks(_id=artist["cm_artist_id"], limit=limit + 1) for i, obj in enumerate(results): if obj.get("cm_track_id") == _id: del results[i] break return results[:limit]