using Tesses.YouTubeDownloader; using tytdemail.Model; using YoutubeExplode.Videos; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorPages(); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. //app.UseHsts(); //dont use HSTS here } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.MapGet("/api/AddItem/{id}",async(string id)=>{ var config=SMTPConfig.Create(app.Configuration); if(config != null) { await config.AddItemAsync(id); } return Results.Ok(); }); app.MapGet("/api/AddVideo/{id}",async(string id)=>{ var config=SMTPConfig.Create(app.Configuration); VideoId? vid=VideoId.TryParse(id); if(config != null && vid.HasValue) { await config.AddVideoAsync(vid.Value); } return Results.Ok(); }); app.MapGet("/api/AddItemRes/{res}/{id}",async(int res,string id)=>{ var config=SMTPConfig.Create(app.Configuration); if(config != null) { await config.AddItemAsync(id,(Resolution)res); } return Results.Ok(); }); app.MapGet("/api/AddVideoRes/{res}/{id}",async(int res,string id)=>{ var config=SMTPConfig.Create(app.Configuration); VideoId? vid=VideoId.TryParse(id); if(config != null && vid.HasValue) { await config.AddVideoAsync(vid.Value,(Resolution)res); } return Results.Ok(); }); app.MapRazorPages(); try{ var res=app.Configuration.GetValue("SMTP"); if(res.IgnoreCertError) { System.Net.ServicePointManager.ServerCertificateValidationCallback += (a,b,c,d) => true; } }catch(Exception ex) { _=ex; } app.Run();