diff --git a/DataModels/Tables/User.cs b/DataModels/Tables/User.cs index 00fa098..873f554 100644 --- a/DataModels/Tables/User.cs +++ b/DataModels/Tables/User.cs @@ -12,7 +12,6 @@ namespace RTMPDash.DataModels.Tables { [Column(Name = "PronounPossessive")] public string PronounPossessive { get; set; } [Column(Name = "ChatUrl")] public string ChatUrl { get; set; } [Column(Name = "AnnouncementUrl")] public string AnnouncementUrl { get; set; } - [Column(Name = "SrcRes")] public string SrcRes { get; set; } [Column(Name = "RestreamTargets")] public string RestreamTargets { get; set; } [Column(Name = "RestreamUrls")] public string RestreamUrls { get; set; } } diff --git a/Pages/Dashboard.cshtml b/Pages/Dashboard.cshtml index f165e45..3541df0 100644 --- a/Pages/Dashboard.cshtml +++ b/Pages/Dashboard.cshtml @@ -104,26 +104,6 @@ else { - if (user.SrcRes == "unspecified") { - - } - -
-
-
- Source Resolution -
- - -
- -
-
-
- @if (user.AllowRestream) {
diff --git a/Pages/Dashboard.cshtml.cs b/Pages/Dashboard.cshtml.cs index 27d2009..2f2d27f 100644 --- a/Pages/Dashboard.cshtml.cs +++ b/Pages/Dashboard.cshtml.cs @@ -75,15 +75,6 @@ namespace RTMPDash.Pages { Response.Redirect("/Dashboard"); } - if (Request.Form["action"] == "srcres_set") { - var target = string.IsNullOrWhiteSpace(Request.Form["value"]) - ? "unspecified" - : Request.Form["value"].ToString(); - user!.SrcRes = target; - db.Update(user); - Response.Redirect("/Dashboard"); - } - if (Request.Form["action"] == "streamkey_reset") { user!.StreamKey = Guid.NewGuid().ToString().Substring(9, 14); db.Update(user); diff --git a/Pages/Register.cshtml.cs b/Pages/Register.cshtml.cs index e4f005f..b66cf0f 100644 --- a/Pages/Register.cshtml.cs +++ b/Pages/Register.cshtml.cs @@ -31,8 +31,7 @@ namespace RTMPDash.Pages { Password = Request.Form["pass"].ToString().Sha256(), StreamKey = Guid.NewGuid().ToString().Substring(9, 14), PronounSubject = "they", - PronounPossessive = "their", - SrcRes = "unspecified" + PronounPossessive = "their" }; db.Insert(user); diff --git a/Pages/profile.cshtml b/Pages/profile.cshtml index e4d0676..69e7dc8 100644 --- a/Pages/profile.cshtml +++ b/Pages/profile.cshtml @@ -10,6 +10,10 @@ } var user = db.Users.First(p => p.Username == Model.User); var live = StreamUtils.IsLive(user.Username); + Stream stream = null; + if (live) { + stream = StreamUtils.GetStatsObject().Server.Applications.First(p => p.Name == "ingress").MethodLive.Streams.First(p => p.Name == user.Username); + } var pronounAdditional = user.PronounSubject == "they" ? "are" : "is"; // TODO make this configurable too } @@ -23,14 +27,14 @@

@user.PronounSubject.FirstCharToUpper() @pronounAdditional currently live! @user.PronounSubject.FirstCharToUpper() have not specified a stream chat URL, so enjoy @user.PronounPossessive content!

}
- Source + Source - @(stream.Meta.Video.Height)p @if (user.AllowRestream) { if ((user.RestreamUrls ?? "").Contains(",")) { - Twitch Restream + Source - @(stream.Meta.Video.Height)p">Twitch Restream YouTube Restream } else if (!string.IsNullOrWhiteSpace(user.RestreamUrls)) { - Twitch Restream + Source - @(stream.Meta.Video.Height)p">Twitch Restream } } diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 8a0bd2a..1b8a7e6 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -8,7 +8,7 @@ "commandName": "Project", "dotnetRunMessages": "true", "launchBrowser": false, - "applicationUrl": "https://localhost:5001;http://localhost:5000", + "applicationUrl": "http://localhost:60001", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/Startup.cs b/Startup.cs index 936b1ed..28ab900 100644 --- a/Startup.cs +++ b/Startup.cs @@ -38,7 +38,6 @@ namespace RTMPDash { app.UseHsts(); } - app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSession(); diff --git a/StreamUtils.cs b/StreamUtils.cs index a8a8019..b8e22b3 100644 --- a/StreamUtils.cs +++ b/StreamUtils.cs @@ -3,22 +3,17 @@ using System.IO; using System.Linq; using System.Net; using System.Xml.Serialization; -using RTMPDash.DataModels; namespace RTMPDash { public class StreamUtils { - private const string Hlsroot = "/mnt/ssd_data/hls/src"; + public static bool IsLive(string user) => GetStatsObject() + .Server.Applications.First(p => p.Name == "ingress") + .MethodLive.Streams.Any(p => p.Name == user); - public static bool IsLive(string user) => File.Exists(Path.Combine(Hlsroot, $"{user}.m3u8")); - - public static List ListLiveUsers() { - var db = new AppDb.DbConn(); - return (from file in Directory.EnumerateFiles(Path.Combine(Hlsroot)) - where file.EndsWith(".m3u8") - && db.Users.Any(p => p.Username == Path.GetFileNameWithoutExtension(file)) - select Path.GetFileNameWithoutExtension(file)).OrderBy(p => p) - .ToList(); - } + public static List ListLiveUsers() => GetStatsObject() + .Server.Applications.First(p => p.Name == "ingress") + .MethodLive.Streams.Select(p => p.Name) + .ToList(); public static StatsObject GetStatsObject() { var serializer = new XmlSerializer(typeof(StatsObject));