fix: place manual video imports at queue top

This commit is contained in:
nstarikov 2026-08-11 11:56:47 +03:00
parent e553283df6
commit 22fd61a33c
2 changed files with 5 additions and 2 deletions

View file

@ -45,6 +45,7 @@ type Video = {
id: number id: number
title: string title: string
sourceUrl: string sourceUrl: string
manual?: boolean
status: string status: string
progressPercent: number progressPercent: number
progressStage: string progressStage: string
@ -1523,7 +1524,7 @@ export default function App() {
<h3 className="min-w-0 flex-1 truncate text-sm font-semibold">{video.title || `Ролик #${video.id}`}</h3> <h3 className="min-w-0 flex-1 truncate text-sm font-semibold">{video.title || `Ролик #${video.id}`}</h3>
</div> </div>
<div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground"> <div className="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground">
<span>Опубликовано: {formatVideoDate(video.publishedAt)}</span> <span>{video.manual ? "Добавлено" : "Опубликовано"}: {formatVideoDate(video.publishedAt)}</span>
<span>Длительность: {formatDuration(video.durationSeconds)}</span> <span>Длительность: {formatDuration(video.durationSeconds)}</span>
</div> </div>
{hasStarted && video.progressStage ? <p className="mt-2 line-clamp-2 text-sm text-muted-foreground">{video.progressStage}</p> : null} {hasStarted && video.progressStage ? <p className="mt-2 line-clamp-2 text-sm text-muted-foreground">{video.progressStage}</p> : null}

View file

@ -463,7 +463,8 @@ def import_video(payload: ManualVideoIn, session: Session = Depends(get_session)
if existing: if existing:
raise HTTPException(status_code=409, detail=f"Этот ролик уже добавлен: #{existing.id}") raise HTTPException(status_code=409, detail=f"Этот ролик уже добавлен: #{existing.id}")
published_at = parse_upload_date(metadata.get("upload_date")) # A manually imported video enters our queue now, regardless of its original age.
published_at = datetime.now(timezone.utc)
duration = metadata.get("duration") duration = metadata.get("duration")
try: try:
duration = round(float(duration)) if duration is not None else None duration = round(float(duration)) if duration is not None else None
@ -505,6 +506,7 @@ def list_videos(session: Session = Depends(get_session)) -> list[dict]:
"id": video.id, "id": video.id,
"title": video.title, "title": video.title,
"sourceUrl": video.source_url, "sourceUrl": video.source_url,
"manual": video.source_id is None,
"status": video.status, "status": video.status,
"progressPercent": video.progress_percent, "progressPercent": video.progress_percent,
"progressStage": video.progress_stage, "progressStage": video.progress_stage,