Make it more complete

This commit is contained in:
2026-04-28 03:21:01 -05:00
parent 74c6d1126e
commit 1052b94a54
34 changed files with 712 additions and 82 deletions
+61
View File
@@ -0,0 +1,61 @@
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<Artist> 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));
}
}