Feat: Enhance library management features
- Adds strict HTTP/HTTPS validation when creating library websites. - Improves summary cleanup in video ingestion by removing thinking tags and prefixes. - Updates LibraryManager UI to display comprehensive metadata (ID, provider, upload date, character count, etc.) and improves video source handling.
This commit is contained in:
@@ -14,7 +14,7 @@ from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional
|
||||
from urllib.parse import quote
|
||||
from urllib.parse import quote, urlparse
|
||||
|
||||
import httpx
|
||||
from fastapi import APIRouter, HTTPException
|
||||
@@ -1599,6 +1599,9 @@ async def update_library_text(slug: str, item_id: str, req: UpdateTextRequest):
|
||||
@router.post("/libraries/{slug}/websites")
|
||||
async def create_library_website(slug: str, req: CreateWebsiteRequest):
|
||||
requested_url = str(req.url or "").strip()
|
||||
parsed_url = urlparse(requested_url)
|
||||
if parsed_url.scheme not in {"http", "https"} or not parsed_url.netloc:
|
||||
raise HTTPException(status_code=400, detail="Enter a valid HTTP or HTTPS URL.")
|
||||
try:
|
||||
video_metadata = await asyncio.to_thread(probe_video_url, requested_url)
|
||||
except UnsupportedVideoUrl:
|
||||
|
||||
@@ -351,7 +351,8 @@ async def _summarize(title: str, transcript: str, model_name: str) -> str:
|
||||
],
|
||||
options={"num_ctx": _choose_num_ctx(prompt)},
|
||||
)
|
||||
clean = str(summary or "").strip()
|
||||
clean = re.sub(r"<think>.*?</think>", "", str(summary or ""), flags=re.DOTALL | re.IGNORECASE).strip()
|
||||
clean = re.sub(r"^\s*Summary:\s*", "", clean, flags=re.IGNORECASE).strip()
|
||||
if not clean:
|
||||
raise RuntimeError("Ollama returned an empty video summary.")
|
||||
return clean
|
||||
|
||||
Reference in New Issue
Block a user