Make it more complete
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -56,7 +56,7 @@ public static partial class Pages {
|
||||
Prev = HttpUtility.HtmlAttributeEncode($"/log?page={(page == 1 ? 1 : page - 1)}"),
|
||||
Current = page,
|
||||
Next = HttpUtility.HtmlAttributeEncode($"/log?page={page + 1}")
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(4));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Name = HttpUtility.HtmlEncode(name),
|
||||
Songs = songLinks,
|
||||
Addvals = HttpUtility.HtmlAttributeEncode(JsonConvert.SerializeObject(new{id}))
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,10 @@ using Scriban;
|
||||
using System.Web;
|
||||
namespace Tesses.YouTubeDownloader2025Companion
|
||||
{
|
||||
public class AlbumLink(string name, string id, string thumbnail) {
|
||||
public class AlbumLink(string name, string id) {
|
||||
public string Albumname => HttpUtility.HtmlEncode(name);
|
||||
public string Albumurl => HttpUtility.HtmlAttributeEncode($"/music/album?id={HttpUtility.UrlEncode(id)}");
|
||||
public string Imgurl => HttpUtility.HtmlAttributeEncode(thumbnail);
|
||||
public string Imgurl => HttpUtility.HtmlAttributeEncode($"/api/v1/album-thumbnail?id={HttpUtility.UrlEncode(id)}");
|
||||
}
|
||||
|
||||
public static partial class Pages {
|
||||
@@ -21,7 +21,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Current = page,
|
||||
Next = HttpUtility.HtmlAttributeEncode($"/music/albums?q={HttpUtility.UrlEncode(query)}&page={page + 1}")
|
||||
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Prev = HttpUtility.HtmlAttributeEncode($"/music/artist?id={HttpUtility.UrlEncode(id.ToString())}&page={(page == 1 ? 1 : page - 1)}"),
|
||||
Current = page,
|
||||
Next = HttpUtility.HtmlAttributeEncode($"/music/artist?id={HttpUtility.UrlEncode(id.ToString())}&page={page + 1}")
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Prev = HttpUtility.HtmlAttributeEncode($"/music/artists?q={HttpUtility.UrlEncode(query)}&page={(page == 1 ? 1 : page - 1)}"),
|
||||
Current = page,
|
||||
Next = HttpUtility.HtmlAttributeEncode($"/music/artists?q={HttpUtility.UrlEncode(query)}&page={page + 1}")
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Hasanysongs = hasAny,
|
||||
Zipurl = HttpUtility.HtmlAttributeEncode($"/api/v1/album.zip?albumId={HttpUtility.UrlEncode(id)}"),
|
||||
Artists = artists
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Current = page,
|
||||
Next = HttpUtility.HtmlAttributeEncode($"/music/myalbums?q={HttpUtility.UrlEncode(query)}&page={page + 1}")
|
||||
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Prev = HttpUtility.HtmlAttributeEncode($"/music/myartist?q={HttpUtility.UrlEncode(query)}&id={HttpUtility.UrlEncode(id.ToString())}&page={(page == 1 ? 1 : page - 1)}"),
|
||||
Current = page,
|
||||
Next = HttpUtility.HtmlAttributeEncode($"/music/myartist?q={HttpUtility.UrlEncode(query)}&id={HttpUtility.UrlEncode(id.ToString())}&page={page + 1}")
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Prev = HttpUtility.HtmlAttributeEncode($"/music/myartists?q={HttpUtility.UrlEncode(query)}&page={(page == 1 ? 1 : page - 1)}"),
|
||||
Current = page,
|
||||
Next = HttpUtility.HtmlAttributeEncode($"/music/myartists?q={HttpUtility.UrlEncode(query)}&page={page + 1}")
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Tytdurl = HttpUtility.HtmlAttributeEncode($"{tytdEndpoint.TrimEnd('/')}/watch?v={HttpUtility.UrlEncode(video.VideoId)}"),
|
||||
Dlbtn = downloaded ? $"<a class=\"button\" href=\"/api/v1/song?albumId={HttpUtility.UrlEncode(album.AlbumId)}&songId={HttpUtility.UrlEncode(song.SongId)}\"><i>download</i> Download</a>" : string.IsNullOrEmpty(video.VideoId) ? "<span><i>file_download_off</i> Unavailable</span>" : "<span><i>downloading</i> Downloading</span>",
|
||||
Hasvideo = !string.IsNullOrEmpty(video.VideoId)
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Tesses.WebServer;
|
||||
using Scriban;
|
||||
using System.Web;
|
||||
using System.Text;
|
||||
namespace Tesses.YouTubeDownloader2025Companion
|
||||
{
|
||||
public static partial class Pages {
|
||||
|
||||
private static ReloadingScript mysong_albums = new ReloadingScript("wwwroot/pages/music/mysongs/song-albums.sbnhtml");
|
||||
|
||||
public static string MySongAlbums(List<MediaEntry> entries, Song song, List<Artist> artists)
|
||||
{
|
||||
StringBuilder builder=new StringBuilder();
|
||||
if(artists.Count > 0)
|
||||
builder.Append($"{artists[0].ArtistName} - ");
|
||||
builder.Append(song.SongName);
|
||||
|
||||
if(artists.Count > 1)
|
||||
builder.Append($" feat. {string.Join(",",artists.Skip(1).Select(e=>e.ArtistName))}");
|
||||
|
||||
|
||||
return Components.Shell($"{builder}'s Albums", mysong_albums.Render(new
|
||||
{
|
||||
Songname = builder.ToString(),
|
||||
Albums = entries.Select(e =>
|
||||
{
|
||||
return new
|
||||
{
|
||||
Albumurl = $"/music/myalbum?id={HttpUtility.UrlEncode(e.AlbumId)}",
|
||||
Albumname = HttpUtility.HtmlEncode(e.AlbumName),
|
||||
Url = $"/music/mysong?albumId={HttpUtility.UrlEncode(e.AlbumId)}&songId={song.SongId}",
|
||||
Imgurl = $"/api/v1/album-thumbnail?id={HttpUtility.UrlEncode(e.AlbumId)}"
|
||||
};
|
||||
})
|
||||
}), Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace Tesses.YouTubeDownloader2025Companion
|
||||
Prev = HttpUtility.HtmlAttributeEncode($"/music/mysongs?q={HttpUtility.UrlEncode(query)}&page={(page == 1 ? 1 : page - 1)}"),
|
||||
Current = page,
|
||||
Next = HttpUtility.HtmlAttributeEncode($"/music/mysongs?q={HttpUtility.UrlEncode(query)}&page={page + 1}")
|
||||
}),Program.DefaultLinks());
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Tesses.WebServer;
|
||||
using Scriban;
|
||||
using System.Web;
|
||||
namespace Tesses.YouTubeDownloader2025Companion
|
||||
{
|
||||
public class SongLink(string name, string id) {
|
||||
public string Name => HttpUtility.HtmlEncode(name);
|
||||
public string Url => HttpUtility.HtmlAttributeEncode($"/music/song?id={HttpUtility.UrlEncode(id)}");
|
||||
|
||||
}
|
||||
|
||||
public static partial class Pages {
|
||||
|
||||
private static ReloadingScript song_listing = new ReloadingScript("wwwroot/pages/music/songs/song-list.sbnhtml");
|
||||
public static string SongListing(string query, List<SongLink> links, int page)
|
||||
{
|
||||
return Components.Shell($"Song search {query}", song_listing.Render(new {
|
||||
Songs = links,
|
||||
Q = HttpUtility.HtmlAttributeEncode(query),
|
||||
Prev = HttpUtility.HtmlAttributeEncode($"/music/songs?q={HttpUtility.UrlEncode(query)}&page={(page == 1 ? 1 : page - 1)}"),
|
||||
Current = page,
|
||||
Next = HttpUtility.HtmlAttributeEncode($"/music/songs?q={HttpUtility.UrlEncode(query)}&page={page + 1}")
|
||||
}),Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Tesses.WebServer;
|
||||
using Scriban;
|
||||
using System.Web;
|
||||
using System.Text;
|
||||
namespace Tesses.YouTubeDownloader2025Companion
|
||||
{
|
||||
public static partial class Pages {
|
||||
|
||||
private static ReloadingScript song_albums = new ReloadingScript("wwwroot/pages/music/songs/song-albums.sbnhtml");
|
||||
|
||||
public static string SongAlbums(string songName, List<AlbumLink> albums)
|
||||
{
|
||||
return Components.Shell($"{songName}'s Albums", song_albums.Render(new
|
||||
{
|
||||
Songname = songName,
|
||||
Albums = albums
|
||||
}), Program.DefaultLinks(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -132,7 +132,7 @@ public static partial class Pages {
|
||||
body = await Program.SearchResultHandler.SearchAsync(q,false);
|
||||
}
|
||||
|
||||
return Components.Shell($"Search {q}",search_page.Render(new {body,q = HttpUtility.HtmlAttributeEncode(q)}),Program.DefaultLinks());
|
||||
return Components.Shell($"Search {q}",search_page.Render(new {body,q = HttpUtility.HtmlAttributeEncode(q)}),Program.DefaultLinks(1));
|
||||
}
|
||||
public static async Task<string> SearchDialogAsync(ServerContext ctx)
|
||||
{
|
||||
|
||||
+10
-1
@@ -16,7 +16,16 @@ public static partial class Pages {
|
||||
|
||||
public static string Settings(ServerContext ctx)
|
||||
{
|
||||
return Components.Shell("Settings",settings_page.Render(new{}),Program.DefaultLinks());
|
||||
bool tytdthumbnail = false;
|
||||
lock(Program.MyLockObject)
|
||||
{
|
||||
tytdthumbnail = Program.Config?.ThumbnailsThroughTYTD ?? false;
|
||||
}
|
||||
|
||||
return Components.Shell("Settings", settings_page.Render(new
|
||||
{
|
||||
Tytdthumbnail=tytdthumbnail
|
||||
}),Program.DefaultLinks(3));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user