Add playlists support and fix explore older videos
- New playlists router: fetch channel playlists from YouTube, index playlist videos, browse by playlist with pagination - Playlist model gets video_ids column to store ordered video list - Register playlists router in main.py with DB migration - Add Playlists tab to Channel page: grid of playlist cards, click to browse videos, index/re-index per playlist - Fix explore older videos skipping all entries without published_at; flat-playlist entries for older videos rarely include timestamp data Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ from fastapi.staticfiles import StaticFiles
|
||||
from .config import settings
|
||||
from .database import init_db, SessionLocal
|
||||
from .services import ytdlp as ytdlp_service
|
||||
from .routers import auth, channels, videos, search, downloads, discovery, settings as settings_router, stats as stats_router, export as export_router, collections as collections_router, admin as admin_router
|
||||
from .routers import auth, channels, videos, search, downloads, discovery, settings as settings_router, stats as stats_router, export as export_router, collections as collections_router, admin as admin_router, playlists as playlists_router
|
||||
|
||||
app = FastAPI(title="YouTube Hub", version="0.1.0")
|
||||
|
||||
@@ -29,6 +29,7 @@ app.include_router(stats_router.router, prefix="/api/stats", tags=["stats"])
|
||||
app.include_router(export_router.router, prefix="/api/export", tags=["export"])
|
||||
app.include_router(collections_router.router, prefix="/api/collections", tags=["collections"])
|
||||
app.include_router(admin_router.router, prefix="/api/admin", tags=["admin"])
|
||||
app.include_router(playlists_router.router, prefix="/api/playlists", tags=["playlists"])
|
||||
|
||||
|
||||
os.makedirs(settings.download_path, exist_ok=True)
|
||||
@@ -73,6 +74,19 @@ def on_startup():
|
||||
"ALTER TABLE user_settings ADD COLUMN use_oauth2 INTEGER DEFAULT 0",
|
||||
"ALTER TABLE user_settings ADD COLUMN sync_interval_hours INTEGER DEFAULT 0",
|
||||
"ALTER TABLE user_settings ADD COLUMN subtitle_langs TEXT DEFAULT ''",
|
||||
"""CREATE TABLE IF NOT EXISTS playlists (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
youtube_playlist_id TEXT NOT NULL UNIQUE,
|
||||
channel_id INTEGER REFERENCES channels(id) ON DELETE CASCADE,
|
||||
title TEXT NOT NULL,
|
||||
description TEXT,
|
||||
thumbnail_url TEXT,
|
||||
video_count INTEGER DEFAULT 0,
|
||||
video_ids TEXT,
|
||||
indexed_at DATETIME,
|
||||
crawled_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||
)""",
|
||||
"ALTER TABLE playlists ADD COLUMN video_ids TEXT",
|
||||
"""CREATE TABLE IF NOT EXISTS search_history (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
|
||||
Reference in New Issue
Block a user