Skip to content

Add playlists and collections feature (Issue #223)#428

Merged
filthyrake merged 3 commits intodevfrom
feature/223-playlists-collections
Dec 28, 2025
Merged

Add playlists and collections feature (Issue #223)#428
filthyrake merged 3 commits intodevfrom
feature/223-playlists-collections

Conversation

@filthyrake
Copy link
Copy Markdown
Owner

Summary

Implements comprehensive playlist/collection functionality for organizing videos into ordered groups.

  • Database: New playlists and playlist_items tables with support for visibility (public/private/unlisted), types (playlist/collection/series/course), featured flag, and soft delete
  • Admin API: Full CRUD endpoints for playlists plus video management (add, remove, reorder)
  • Public API: Endpoints to list and view public/unlisted playlists with videos
  • Admin UI: New Playlists tab with list view, create form, and full editor with drag-to-reorder videos

API Endpoints Added

Admin (authenticated)

Method Endpoint Description
GET /api/playlists List all playlists
POST /api/playlists Create playlist
GET /api/playlists/{id} Get playlist with videos
PUT /api/playlists/{id} Update playlist
DELETE /api/playlists/{id} Soft delete
POST /api/playlists/{id}/videos Add video
DELETE /api/playlists/{id}/videos/{vid} Remove video
POST /api/playlists/{id}/reorder Reorder videos

Public

Method Endpoint Description
GET /api/playlists List public playlists
GET /api/playlists/{slug} Get playlist detail
GET /api/playlists/{slug}/videos Get playlist videos

Test Plan

  • Run database migration successfully
  • Create playlists of each type (playlist, collection, series, course)
  • Test visibility options (public, private, unlisted)
  • Add videos to playlist and verify ordering
  • Remove videos and verify position renumbering
  • Drag-to-reorder videos in admin UI
  • Verify featured playlists appear first in listings
  • Test public API only returns public/unlisted playlists
  • Soft delete and verify playlist no longer appears

Closes #223

🤖 Generated with Claude Code

filthyrake and others added 3 commits December 28, 2025 06:57
Implements comprehensive playlist/collection functionality for organizing
videos into ordered groups.

## Backend Changes
- Add database migration (020_add_playlists.py) for playlists and playlist_items tables
- Add table definitions to database.py with support for:
  - Visibility: public, private, unlisted
  - Types: playlist, collection, series, course
  - Featured flag for homepage display
  - Soft delete support
- Add Pydantic schemas for playlist CRUD operations
- Add playlist audit actions for activity logging

## Admin API Endpoints
- GET /api/playlists - List all playlists with video counts
- POST /api/playlists - Create new playlist
- GET /api/playlists/{id} - Get playlist with videos
- PUT /api/playlists/{id} - Update playlist metadata
- DELETE /api/playlists/{id} - Soft delete playlist
- GET /api/playlists/{id}/videos - Get videos in playlist
- POST /api/playlists/{id}/videos - Add video to playlist
- DELETE /api/playlists/{id}/videos/{video_id} - Remove video
- POST /api/playlists/{id}/reorder - Reorder videos

## Public API Endpoints
- GET /api/playlists - List public playlists with filtering
- GET /api/playlists/{slug} - Get playlist detail with videos
- GET /api/playlists/{slug}/videos - Get playlist videos

## Admin UI
- Add Playlists tab with list and edit views
- TypeScript types for playlist models
- Playlist store with full CRUD operations
- Create playlist form with type/visibility selectors
- Playlist editor with metadata editing
- Drag-to-reorder video functionality
- Add video modal with search

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fixes identified issues from comprehensive code review:

## Critical
- Add playlist_type validation in public API to prevent invalid values

## Important
- Fix race condition in add_video_to_playlist with FOR UPDATE locking
- Use transaction for atomic position shift + insert operations
- Replace N+1 query in reorder with batch UPDATE using PostgreSQL unnest
- Add composite index (playlist_id, position) for efficient ordered retrieval

## Improvements
- Add pagination to admin list_playlists endpoint (limit/offset params)
- Remove unused RemoveVideoFromPlaylistRequest schema
- Fix TypeScript any type with proper CombinedStoreContext interface
- Optimize drag-drop to skip API call when order unchanged
- Make created_at NOT NULL in migration (always has default value)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Sort imports in api/admin.py (ruff I001)
- Remove unused response variable in worker/remote_transcoder.py (ruff F841)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@filthyrake filthyrake merged commit 74d6e76 into dev Dec 28, 2025
10 checks passed
@filthyrake filthyrake deleted the feature/223-playlists-collections branch December 28, 2025 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playlists and collections

1 participant