Vanderson da Silva Quintino commited on
Commit
582fc15
·
1 Parent(s): 21f6e1b

fix: Pexels images + correct polling

Browse files
src/ClipForge.Api/wwwroot/index.html CHANGED
@@ -281,10 +281,11 @@
281
  if (pollingInterval) clearInterval(pollingInterval);
282
  pollingInterval = setInterval(async () => {
283
  try {
284
- const res = await fetch(`${API}/api/videos`);
285
  const videos = await res.json();
286
- if (videos.length > lastVideoCount) {
287
- lastVideoCount = videos.length;
 
288
  clearInterval(pollingInterval);
289
  clearInterval(progressInterval);
290
  pollingInterval = null;
@@ -303,14 +304,15 @@
303
  const res = await fetch(`${API}/api/videos`);
304
  const videos = await res.json();
305
  const list = document.getElementById('videosList');
306
- lastVideoCount = videos.length;
307
 
308
- if (videos.length === 0) {
 
309
  list.innerHTML = '<div class="empty">Nenhum vídeo gerado ainda</div>';
310
  return;
311
  }
312
 
313
- list.innerHTML = videos.map(v => `
314
  <div class="video-item">
315
  <div class="video-info">
316
  <div class="title">🎬 Vídeo ${v.id.substring(0, 8)}</div>
 
281
  if (pollingInterval) clearInterval(pollingInterval);
282
  pollingInterval = setInterval(async () => {
283
  try {
284
+ const res = await fetch(`${API}/api/videos/status/completed`);
285
  const videos = await res.json();
286
+ const completedCount = videos.filter(v => v.fileSizeBytes > 0).length;
287
+ if (completedCount > lastVideoCount) {
288
+ lastVideoCount = completedCount;
289
  clearInterval(pollingInterval);
290
  clearInterval(progressInterval);
291
  pollingInterval = null;
 
304
  const res = await fetch(`${API}/api/videos`);
305
  const videos = await res.json();
306
  const list = document.getElementById('videosList');
307
+ lastVideoCount = videos.filter(v => v.fileSizeBytes > 0 && v.status === 'completed').length;
308
 
309
+ const validVideos = videos.filter(v => v.fileSizeBytes > 0);
310
+ if (validVideos.length === 0) {
311
  list.innerHTML = '<div class="empty">Nenhum vídeo gerado ainda</div>';
312
  return;
313
  }
314
 
315
+ list.innerHTML = validVideos.map(v => `
316
  <div class="video-item">
317
  <div class="video-info">
318
  <div class="title">🎬 Vídeo ${v.id.substring(0, 8)}</div>
src/ClipForge.Infrastructure/DependencyInjection.cs CHANGED
@@ -31,9 +31,7 @@ public static class DependencyInjection
31
 
32
  // HTTP Clients
33
  services.AddHttpClient<IOpenAiClient, OpenAiClient>();
34
-
35
- // Media service (YouTube via yt-dlp)
36
- services.AddScoped<IStockMediaService, YouTubeMediaService>();
37
 
38
  // Services
39
  services.AddScoped<IFfmpegService, FfmpegService>();
 
31
 
32
  // HTTP Clients
33
  services.AddHttpClient<IOpenAiClient, OpenAiClient>();
34
+ services.AddHttpClient<IStockMediaService, GoogleImageSearchService>();
 
 
35
 
36
  // Services
37
  services.AddScoped<IFfmpegService, FfmpegService>();