@using System.Text.RegularExpressions @using System.Web @using InnerTube.Models @model LightTube.Contexts.PlayerContext @{ bool compatibility = false; if (Context.Request.Cookies.TryGetValue("compatibility", out string compatibilityString)) bool.TryParse(compatibilityString, out compatibility); ViewBag.Metadata = new Dictionary(); ViewBag.Metadata["author"] = Model.Video.Channel.Name; ViewBag.Metadata["og:title"] = Model.Player.Title; ViewBag.Metadata["og:url"] = $"{Url.ActionContext.HttpContext.Request.Scheme}://{Url.ActionContext.HttpContext.Request.Host}{Url.ActionContext.HttpContext.Request.Path}{Url.ActionContext.HttpContext.Request.QueryString}"; ViewBag.Metadata["og:image"] = $"{Url.ActionContext.HttpContext.Request.Scheme}://{Url.ActionContext.HttpContext.Request.Host}/proxy/image?url={HttpUtility.UrlEncode(Model.Player.Thumbnails.FirstOrDefault()?.Url?.ToString())}"; ViewBag.Metadata["twitter:card"] = $"{Url.ActionContext.HttpContext.Request.Scheme}://{Url.ActionContext.HttpContext.Request.Host}/proxy/image?url={HttpUtility.UrlEncode(Model.Player.Thumbnails.LastOrDefault()?.Url?.ToString())}"; ViewBag.Metadata["og:description"] = Model.Player.Description; ViewBag.Title = Model.Player.Title; Layout = "_Layout"; try { ViewBag.Metadata["og:video"] = $"/proxy/video?url={HttpUtility.UrlEncode(Model.Player.Formats.First().Url.ToString())}"; Model.Resolution ??= Model.Player.Formats.First().FormatNote; } catch { } ViewData["HideGuide"] = true; bool live = Model.Player.Formats.Length == 0 && Model.Player.AdaptiveFormats.Length > 0; string description = Model.Video.GetHtmlDescription(); const string youtubePattern = @"[w.]*youtube[-nockie]*\.com"; // turn URLs into hyperlinks Regex urlRegex = new(youtubePattern, RegexOptions.IgnoreCase); Match m; for (m = urlRegex.Match(description); m.Success; m = m.NextMatch()) description = description.Replace(m.Groups[0].ToString(), $"{Url.ActionContext.HttpContext.Request.Host}"); bool canPlay = true; }
@if (live) { } else if (Model.Player.Formats.Length > 0) { } else { canPlay = false;
@if (string.IsNullOrWhiteSpace(Model.Player.ErrorMessage)) { No playable streams returned from the API (@Model.Player.Formats.Length/@Model.Player.AdaptiveFormats.Length) } else { @Model.Player.ErrorMessage }
}
@if (Model.MobileLayout) {
@Model.Video.Title
@Model.Video.Views Published @Model.Video.UploadDate
@Model.Engagement.Likes
@Model.Engagement.Dislikes
Download Save YouTube link

@Html.Raw(description)


} else {
@Model.Video.Title

@Model.Video.Views  @Model.Video.UploadDate  @Html.Raw(description)

@Model.Engagement.Likes
@Model.Engagement.Dislikes
Download Save YouTube link
@Model.Video.Channel.SubscriberCount
}
@if (canPlay) { @if (Model.MobileLayout) { } else { } @if (!Model.CompatibilityMode && !live) { } else if (live) { } else { } }