feat: the videos panel in the Site tab, captions optional (front 8.4)
Dropstar uploads the six videos themselves, so the panel moves from Integrações to the Site tab, next to products and prices. A video can be published without a VTT: the Site plays it without a captions track. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -92,8 +92,8 @@ def manage_videos(user=Depends(operator)):
|
||||
def update_video(video_id: str, body: VideoUpdate, user=Depends(can('manage'))):
|
||||
if video_id not in CATALOG:
|
||||
raise HTTPException(404, 'Vídeo não encontrado.')
|
||||
if body.enabled and (not body.upload_id or not body.captions_id):
|
||||
raise HTTPException(422, 'Envie o vídeo e sua legenda VTT antes de publicar.')
|
||||
if body.enabled and not body.upload_id:
|
||||
raise HTTPException(422, 'Envie o vídeo antes de publicar.')
|
||||
with db.connect() as c:
|
||||
previous = c.execute('SELECT upload_id,captions_id,video_key,captions_key FROM dtf_local.site_videos WHERE id=%s FOR UPDATE',
|
||||
(video_id,)).fetchone() or {}
|
||||
@@ -137,10 +137,11 @@ def published_videos():
|
||||
rows = c.execute('''SELECT v.id,v.product,v.video_key,v.captions_key,u.name AS video_name
|
||||
FROM dtf_local.site_videos v
|
||||
JOIN dtf_local.uploads u ON u.id=v.upload_id
|
||||
WHERE v.enabled AND v.video_key IS NOT NULL AND v.captions_key IS NOT NULL''').fetchall()
|
||||
WHERE v.enabled AND v.video_key IS NOT NULL''').fetchall()
|
||||
return {'videos': [dict(id=row['id'], product=row['product'],
|
||||
src=storage.view(row['video_key'], _kind({'name':row['video_name'],'size':0})[0]),
|
||||
captions=f"/api/site/videos/{row['id']}/captions") for row in rows]}
|
||||
captions=f"/api/site/videos/{row['id']}/captions" if row['captions_key'] else None)
|
||||
for row in rows]}
|
||||
|
||||
|
||||
@router.get('/api/site/videos/{video_id}/captions')
|
||||
|
||||
Reference in New Issue
Block a user