- Remove projetos mortos: VideoStudy.Native (MAUI), Controllers/LicenseController - Remove serviços não usados: FFmpegService, HardwareIdService, LicenseManager, PdfGeneratorService, ScreenshotService, TranscriptionService do UI - Remove dependências pesadas do UI: Whisper.net, YoutubeExplode, QuestPDF - Remove PuppeteerSharp e SkiaSharp do API (150MB Chromium não é mais necessário) - Screenshots agora usam FFmpeg diretamente (mais simples, mais confiável) - YouTubeService reescrito para chamar /api/video-info em vez de YoutubeExplode - Adiciona campo UserContext em AnalysisRequest (contexto livre do usuário) - UI traduzida para português; aba de arquivo local removida (nunca funcionou) - YouTubeProcessor simplificado: sem modo Advanced/Whisper - GetYtDlpPath busca yt-dlp.exe subindo até 7 níveis de diretório - Cookies do yt-dlp configuráveis via YtDlp:CookiesBrowser no appsettings - Chave Groq agora lida de env var GROQ_API_KEY (appsettings.json sem segredos) - VideoStudy.Linux (Photino) adicionado à solução como host multiplataforma - yt-dlp atualizado de 2025.01.26 para 2026.03.17 (fix do nsig extraction) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
162 lines
5.3 KiB
C#
162 lines
5.3 KiB
C#
namespace VideoStudy.Shared;
|
|
|
|
/// <summary>
|
|
/// Request model for video analysis
|
|
/// </summary>
|
|
public class AnalysisRequest
|
|
{
|
|
public string VideoUrl { get; set; } = string.Empty;
|
|
public string Language { get; set; } = "en"; // Input language (subtitles)
|
|
public string? OutputLanguage { get; set; } // Output language (tutorial). null = same as Language
|
|
public string Mode { get; set; } = "fast";
|
|
public double DurationSeconds { get; set; }
|
|
// Contexto livre do usuário: "tutorial técnico de Python", "aula de física escolar", etc.
|
|
public string? UserContext { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Response model containing analysis results
|
|
/// </summary>
|
|
public class AnalysisResponse
|
|
{
|
|
public string VideoTitle { get; set; } = string.Empty;
|
|
public string DocumentTitle { get; set; } = string.Empty; // New
|
|
public string Summary { get; set; } = string.Empty; // Renamed from ExecutiveSummary
|
|
public string Category { get; set; } = "OTHER"; // New
|
|
public string Transcript { get; set; } = string.Empty;
|
|
public List<KeyMoment> KeyMoments { get; set; } = [];
|
|
public string Analysis { get; set; } = string.Empty;
|
|
public List<TutorialSection> TutorialSections { get; set; } = [];
|
|
public List<string> DebugSteps { get; set; } = [];
|
|
public string? RawLlmResponse { get; set; }
|
|
public byte[]? PdfData { get; set; }
|
|
public string Status { get; set; } = "success";
|
|
public string? ErrorMessage { get; set; }
|
|
}
|
|
|
|
public class TutorialSection
|
|
{
|
|
public string Title { get; set; } = string.Empty;
|
|
public string Content { get; set; } = string.Empty;
|
|
public string? ImageTimestamp { get; set; } // "HH:MM:SS"
|
|
public int? ImageTimeSeconds { get; set; }
|
|
public byte[]? ImageData { get; set; } // For internal use during PDF generation
|
|
}
|
|
|
|
/// <summary>
|
|
/// Represents a key moment in the video
|
|
/// </summary>
|
|
public class KeyMoment
|
|
{
|
|
public string Timestamp { get; set; } = string.Empty;
|
|
public string Description { get; set; } = string.Empty;
|
|
public int StartSeconds { get; set; }
|
|
public string Explanation { get; set; } = string.Empty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Progress update for long-running operations
|
|
/// </summary>
|
|
public class ProgressUpdate
|
|
{
|
|
public double PercentComplete { get; set; }
|
|
public string Message { get; set; } = string.Empty;
|
|
public string Stage { get; set; } = string.Empty;
|
|
}
|
|
|
|
public class VideoInfo
|
|
{
|
|
public string Title { get; set; } = string.Empty;
|
|
public string Description { get; set; } = string.Empty; // Added
|
|
public TimeSpan Duration { get; set; }
|
|
public string Url { get; set; } = string.Empty;
|
|
public string ThumbnailUrl { get; set; } = string.Empty;
|
|
public string Author { get; set; } = string.Empty;
|
|
}
|
|
|
|
public class Transcription
|
|
{
|
|
public string FullText { get; set; } = string.Empty;
|
|
public List<TranscriptionSegment> Segments { get; set; } = [];
|
|
public string Language { get; set; } = "en";
|
|
}
|
|
|
|
public class TranscriptionSegment
|
|
{
|
|
public string Timestamp { get; set; } = string.Empty;
|
|
public string Text { get; set; } = string.Empty;
|
|
public double StartSeconds { get; set; }
|
|
public double EndSeconds { get; set; }
|
|
}
|
|
|
|
public class ProcessingResult
|
|
{
|
|
public Transcription Transcription { get; set; } = new();
|
|
public List<KeyMoment> KeyMoments { get; set; } = [];
|
|
public List<string> ScreenshotPaths { get; set; } = [];
|
|
}
|
|
|
|
public class DownloadProgress
|
|
{
|
|
public double PercentComplete { get; set; }
|
|
public string Status { get; set; } = string.Empty;
|
|
}
|
|
|
|
public interface IPdfSaver
|
|
{
|
|
Task<string?> SavePdfAsync(byte[] pdfData, string suggestedFileName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// A single event in the analysis stream.
|
|
/// </summary>
|
|
public class AnalysisEvent
|
|
{
|
|
/// <summary>
|
|
/// A user-facing message describing the current step.
|
|
/// </summary>
|
|
public string Message { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Progress from 0 to 100.
|
|
/// </summary>
|
|
public int ProgressPercentage { get; set; }
|
|
|
|
/// <summary>
|
|
/// The final result of the analysis. Only present in the last event.
|
|
/// </summary>
|
|
public AnalysisResult? Result { get; set; }
|
|
|
|
/// <summary>
|
|
/// Set to true if this event represents a critical error that stopped the process.
|
|
/// </summary>
|
|
public bool IsError { get; set; } = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// The final, consolidated result of a successful analysis.
|
|
/// </summary>
|
|
public class AnalysisResult
|
|
{
|
|
public string VideoTitle { get; set; } = string.Empty;
|
|
public string DocumentTitle { get; set; } = string.Empty;
|
|
public string Summary { get; set; } = string.Empty; // Renamed from ExecutiveSummary
|
|
public string Category { get; set; } = "OTHER";
|
|
public string Transcript { get; set; } = string.Empty;
|
|
public List<TutorialSection> TutorialSections { get; set; } = [];
|
|
public byte[]? PdfData { get; set; }
|
|
public string? RawLlmResponse { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// Representa uma sessão de estudo gravada no banco de dados local.
|
|
/// </summary>
|
|
public class VideoStudySession
|
|
{
|
|
public int Id { get; set; }
|
|
public string YouTubeId { get; set; } = string.Empty;
|
|
public string Title { get; set; } = string.Empty;
|
|
public string FilePath { get; set; } = string.Empty;
|
|
public string FolderName { get; set; } = "Geral";
|
|
public DateTime CreatedAt { get; set; } = DateTime.Now;
|
|
} |