feat(playlists): make YouTube-mirrored playlists editable + syncable
Mirrors (source='youtube') were read-only; per the original two-way design they can now be edited locally (add/remove/reorder/rename) and pushed back. The read-sync skips a dirty mirror so it won't clobber unpushed edits; a successful push clears dirty and lets the mirror refresh. _mark_dirty now covers any YouTube-linked list (exported local or mirror), and rename marks dirty too. push/delete no longer reject mirrors. Push reconciles the title as well (cheap playlists.list compare, then playlists.update only if changed) so a local rename doesn't revert on the next pull. Frontend: editable = not-built-in (was also excluding mirrors); rows/reorder enabled for all owned lists; AddToPlaylist popover lists mirrors too (with a YT marker); the origin chip now reads 'edits sync back'. Trilingual.
This commit is contained in:
parent
7a7a373983
commit
2b072a10de
8 changed files with 58 additions and 26 deletions
|
|
@ -247,6 +247,27 @@ class YouTubeClient:
|
|||
raise YouTubeError(f"{method} {path} -> {resp.status_code}: {resp.text[:300]}")
|
||||
return resp.json() if resp.content else {}
|
||||
|
||||
def get_playlist_snippet(self, playlist_id: str) -> dict | None:
|
||||
"""The snippet (title/description) of one playlist, or None if it no longer
|
||||
exists. 1 unit (OAuth, so private playlists work)."""
|
||||
data = self._get(
|
||||
"playlists",
|
||||
{"part": "snippet", "id": playlist_id, "maxResults": 1},
|
||||
cost=1,
|
||||
allow_key=False,
|
||||
)
|
||||
items = data.get("items", [])
|
||||
return items[0].get("snippet") if items else None
|
||||
|
||||
def update_playlist_title(self, playlist_id: str, title: str) -> None:
|
||||
"""Rename a playlist on YouTube. 50 units."""
|
||||
self._write(
|
||||
"PUT",
|
||||
"playlists",
|
||||
params={"part": "snippet"},
|
||||
json={"id": playlist_id, "snippet": {"title": title[:150]}},
|
||||
)
|
||||
|
||||
def create_playlist(self, title: str, description: str = "", privacy: str = "private") -> str:
|
||||
"""Create a new YouTube playlist; returns its id. 50 units."""
|
||||
data = self._write(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue