using Tesses.WebServer; using Scriban; using System.Web; using YoutubeExplode.Search; using System.Collections.Concurrent; using System.Security.Cryptography; using Newtonsoft.Json; using System.Text; namespace Tesses.YouTubeDownloader2025Companion; public static partial class Pages { private static ReloadingScript fix_song_index = new ReloadingScript("wwwroot/components/fix-song-index.sbnhtml"); public static string FixSongIndex(string songId, string query) { return fix_song_index.Render(new { Songid = HttpUtility.HtmlAttributeEncode(songId), Searchurl = query == "" ? "" : HttpUtility.HtmlAttributeEncode($"/search_dialog?q={HttpUtility.UrlEncode(query)}"), Songname = query == "" ? "" : HttpUtility.HtmlEncode(query) }); } private static ReloadingScript index_page = new ReloadingScript("wwwroot/pages/index.sbnhtml"); public static string Index(ServerContext ctx, AuthConfig cfg, Song? song, List artists, string username) { string guid=""; StringBuilder builder=new(); if(song is not null) { guid = song.SongId; int i = 0; foreach (var artist in artists) { if (i == 0) builder.Append($"{artist.ArtistName} - {song.SongName}"); else if (i == 1) builder.Append($" feat {artist.ArtistName}"); else builder.Append($", {artist.ArtistName}"); i++; } } return Components.Shell("Home", index_page.Render(new { Videotitle = Program.VideoTitle, Channeltitle = Program.ChannelTitle, Tytdurl = cfg.TYTDUrl.TrimEnd('/'), Needsattention = song is not null, Songtitle = HttpUtility.HtmlEncode(builder.ToString()), Fixsong = HttpUtility.HtmlAttributeEncode($"/fix-song-index?id={HttpUtility.UrlEncode(guid)}"), Username = HttpUtility.HtmlEncode(username) }),Program.DefaultLinks(0)); } }