mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 22:57:48 +00:00
Added sources functionality + pre-commit
This commit is contained in:
@@ -33,3 +33,25 @@ class Playlist:
|
||||
@staticmethod
|
||||
async def random(redis: Redis, amount: Optional[int] = 1) -> List[str]:
|
||||
return await redis.srandmember(f"{redis_prefix}:playlist", amount)
|
||||
|
||||
@staticmethod
|
||||
async def add_bulk(redis: Redis, urls: list[str]):
|
||||
await redis.sadd(f"{redis_prefix}:playlist", *urls)
|
||||
|
||||
@staticmethod
|
||||
async def clear(redis: Redis):
|
||||
await redis.delete(f"{redis_prefix}:playlist")
|
||||
|
||||
|
||||
class PlaylistSource:
|
||||
@staticmethod
|
||||
async def get_all(redis: Redis) -> list[str]:
|
||||
return await redis.smembers(f"{redis_prefix}:sources")
|
||||
|
||||
@staticmethod
|
||||
async def add(redis: Redis, source_url: str):
|
||||
await redis.sadd(f"{redis_prefix}:sources", source_url)
|
||||
|
||||
@staticmethod
|
||||
async def remove(redis: Redis, source_url: str) -> bool:
|
||||
return await redis.srem(f"{redis_prefix}:sources", source_url)
|
||||
|
||||
Reference in New Issue
Block a user