Synk virker
This commit is contained in:
@@ -419,13 +419,13 @@ def get_all_songs_with_files(limit: int = 5000) -> list:
|
||||
|
||||
# ── Playlister ────────────────────────────────────────────────────────────────
|
||||
|
||||
def create_playlist(name: str, description: str = "") -> str:
|
||||
def create_playlist(name: str, description: str = "", tags: str = "") -> str:
|
||||
import uuid as _uuid
|
||||
pl_id = str(_uuid.uuid4())
|
||||
with get_db() as conn:
|
||||
conn.execute(
|
||||
"INSERT INTO playlists (id, name, description) VALUES (?,?,?)",
|
||||
(pl_id, name, description)
|
||||
"INSERT INTO playlists (id, name, description, tags) VALUES (?,?,?,?)",
|
||||
(pl_id, name, description, tags)
|
||||
)
|
||||
return pl_id
|
||||
|
||||
@@ -434,7 +434,9 @@ def get_playlists(tag_filter: str | None = None) -> list:
|
||||
with get_db() as conn:
|
||||
if tag_filter:
|
||||
return conn.execute("""
|
||||
SELECT p.*, COUNT(ps.id) as song_count
|
||||
SELECT p.id, p.name, p.description, p.tags, p.api_project_id,
|
||||
p.is_linked, p.server_permission, p.is_deleted, p.created_at,
|
||||
COUNT(ps.position) as song_count
|
||||
FROM playlists p
|
||||
LEFT JOIN playlist_songs ps ON ps.playlist_id = p.id
|
||||
WHERE p.name != '__aktiv__' AND p.is_deleted = 0
|
||||
@@ -444,7 +446,9 @@ def get_playlists(tag_filter: str | None = None) -> list:
|
||||
f"%, {tag_filter}", tag_filter)).fetchall()
|
||||
else:
|
||||
return conn.execute("""
|
||||
SELECT p.*, COUNT(ps.id) as song_count
|
||||
SELECT p.id, p.name, p.description, p.tags, p.api_project_id,
|
||||
p.is_linked, p.server_permission, p.is_deleted, p.created_at,
|
||||
COUNT(ps.position) as song_count
|
||||
FROM playlists p
|
||||
LEFT JOIN playlist_songs ps ON ps.playlist_id = p.id
|
||||
WHERE p.name != '__aktiv__' AND p.is_deleted = 0
|
||||
@@ -506,6 +510,10 @@ def add_song_to_playlist(playlist_id: str, song_id: str,
|
||||
|
||||
# ── Dans-tags ─────────────────────────────────────────────────────────────────
|
||||
|
||||
def get_all_playlist_tags() -> list[str]:
|
||||
return get_playlist_tags()
|
||||
|
||||
|
||||
def get_playlist_tags() -> list[str]:
|
||||
with get_db() as conn:
|
||||
rows = conn.execute(
|
||||
|
||||
@@ -14,10 +14,12 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class SyncManager:
|
||||
|
||||
def __init__(self, api_url: str, db_path: str):
|
||||
self._api_url = api_url.rstrip("/")
|
||||
def __init__(self, api_url: str = "", db_path: str = "",
|
||||
server_url: str = "", token: str | None = None):
|
||||
# Støt både api_url og server_url som parameter-navn
|
||||
self._api_url = (api_url or server_url).rstrip("/")
|
||||
self._db_path = db_path
|
||||
self._token: str | None = None
|
||||
self._token: str | None = token
|
||||
|
||||
def set_token(self, token: str):
|
||||
self._token = token
|
||||
|
||||
Reference in New Issue
Block a user