Indicate logged-in using token. Improve data shown on the search and media page.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -21,11 +21,23 @@ public abstract class BasicLayout
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
var webshare = Program._webshare;
|
||||
if (webshare != null && await webshare.GetTokenAsync(cancel) == null)
|
||||
string? userName;
|
||||
if (webshare != null)
|
||||
{
|
||||
string? token = await webshare.GetTokenAsync(cancel);
|
||||
if (token == null)
|
||||
{
|
||||
// Automatic logout
|
||||
Program._webshare = null;
|
||||
userName = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
userName = webshare.UserName.Length != 0 ? HttpUtility.HtmlEncode(webshare.UserName) : "<em>token</em>";
|
||||
}
|
||||
} else
|
||||
userName = null;
|
||||
|
||||
string? userName = Program._webshare != null ? Program._webshare.UserName : null;
|
||||
RenderHeader(Title, userName, w);
|
||||
await RenderContentAsync(req, w, cancel);
|
||||
RenderFooter(w);
|
||||
|
||||
@@ -21,7 +21,25 @@ public class MediaPage : BasicLayout
|
||||
protected override async Task RenderContentAsync(HttpRequest req, TextWriter w, CancellationToken cancel)
|
||||
{
|
||||
w.WriteLine("<h1>" + HttpUtility.HtmlEncode(_title) + "</h1>");
|
||||
w.WriteLine("<div>TODO</div>");
|
||||
MediaSource? source = await Metadata.DetailAsync(_id, cancel);
|
||||
InfoLabelI18n? label = source == null ? null : source.i18n_info_labels?.Where(x => x.lang == "cs").FirstOrDefault();
|
||||
if (label == null && source != null)
|
||||
label = source.i18n_info_labels?.FirstOrDefault();
|
||||
|
||||
if (source != null && source.info_labels != null)
|
||||
w.WriteLine("<div><small>" + HttpUtility.HtmlEncode(source.info_labels.originaltitle) + "</small></div>");
|
||||
if (source != null && label != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(label.art?.poster) && Uri.TryCreate(label.art.poster, UriKind.Absolute, out Uri? posterUri)) {
|
||||
if (Metadata.TryGetThumbnail(posterUri, 400, 600, out Uri? posterThumbUri))
|
||||
posterUri = posterThumbUri;
|
||||
w.WriteLine("<div style=\"float:left; margin:0em 1em 1em 0em\"><img src=\"" + posterUri.ToString() + "\" style=\"width:400px\"/></div>");
|
||||
}
|
||||
|
||||
w.WriteLine($"<div>{source.info_labels?.year} | {source.ratings?.overall?.rating} | {TimeSpan.FromSeconds(source.info_labels?.duration ?? 0).TotalMinutes}m | { string.Join(", ", source.info_labels?.director ?? [])} </div>");
|
||||
w.WriteLine($"<div>{label.plot}</div>");
|
||||
}
|
||||
|
||||
w.WriteLine("<h2>Zvolte kvalitu</h2>");
|
||||
|
||||
CinemaLib.API.Stream[]? res = await Metadata.StreamsAsync(_id, cancel: cancel);
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SearchPage : BasicLayout
|
||||
|
||||
w.WriteLine("<div class=\"media-info\">");
|
||||
w.WriteLine("<div class=\"media-art\"><a href=\"" + detailUri + "\"><img src=\"" + artUri?.ToString() + "\"></a></div>");
|
||||
w.WriteLine("<div class=\"media-title\"><a href=\"" + detailUri + "\">" + HttpUtility.HtmlEncode(label?.title) + "</a></div>");
|
||||
w.WriteLine("<div class=\"media-title\"><a href=\"" + detailUri + "\">" + HttpUtility.HtmlEncode(label?.title) + "</a> | " + i._source.info_labels?.year + " | " + i._source.ratings?.overall?.rating + "</div>");
|
||||
w.WriteLine("<div class=\"media-plot\">" + HttpUtility.HtmlEncode(label?.plot) + "</div>");
|
||||
w.WriteLine("</div>"); // media-info
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user