Make actual use of the new stats object; remove SrcRes database object
This commit is contained in:
parent
fce7380d19
commit
70bb5c49cd
|
@ -12,7 +12,6 @@ namespace RTMPDash.DataModels.Tables {
|
||||||
[Column(Name = "PronounPossessive")] public string PronounPossessive { get; set; }
|
[Column(Name = "PronounPossessive")] public string PronounPossessive { get; set; }
|
||||||
[Column(Name = "ChatUrl")] public string ChatUrl { get; set; }
|
[Column(Name = "ChatUrl")] public string ChatUrl { get; set; }
|
||||||
[Column(Name = "AnnouncementUrl")] public string AnnouncementUrl { 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 = "RestreamTargets")] public string RestreamTargets { get; set; }
|
||||||
[Column(Name = "RestreamUrls")] public string RestreamUrls { get; set; }
|
[Column(Name = "RestreamUrls")] public string RestreamUrls { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,26 +104,6 @@ else {
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
if (user.SrcRes == "unspecified") {
|
|
||||||
<div class="alert alert-warning" role="alert">
|
|
||||||
<b>Hey, you!</b>
|
|
||||||
<span>You have not yet specified the resolution and bitrate in which you stream. Please do so below. Thank you!</span>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
<form method="POST">
|
|
||||||
<div class="input-group mb-3">
|
|
||||||
<div class="input-group-prepend">
|
|
||||||
<span class="input-group-text" style="width:23ch">Source Resolution</span>
|
|
||||||
</div>
|
|
||||||
<input type="hidden" value="srcres_set" name="action">
|
|
||||||
<input type="text" class="form-control" name="value" placeholder="example: 1080p60 @@ 10Mbit (Shown in profile page tooltip)" value="@(user.SrcRes == "unspecified" ? "" : user.SrcRes)">
|
|
||||||
<div class="input-group-append">
|
|
||||||
<button type="submit" class="btn btn-primary">Submit</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
@if (user.AllowRestream) {
|
@if (user.AllowRestream) {
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<div class="input-group mb-3">
|
<div class="input-group mb-3">
|
||||||
|
|
|
@ -75,15 +75,6 @@ namespace RTMPDash.Pages {
|
||||||
Response.Redirect("/Dashboard");
|
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") {
|
if (Request.Form["action"] == "streamkey_reset") {
|
||||||
user!.StreamKey = Guid.NewGuid().ToString().Substring(9, 14);
|
user!.StreamKey = Guid.NewGuid().ToString().Substring(9, 14);
|
||||||
db.Update(user);
|
db.Update(user);
|
||||||
|
|
|
@ -31,8 +31,7 @@ namespace RTMPDash.Pages {
|
||||||
Password = Request.Form["pass"].ToString().Sha256(),
|
Password = Request.Form["pass"].ToString().Sha256(),
|
||||||
StreamKey = Guid.NewGuid().ToString().Substring(9, 14),
|
StreamKey = Guid.NewGuid().ToString().Substring(9, 14),
|
||||||
PronounSubject = "they",
|
PronounSubject = "they",
|
||||||
PronounPossessive = "their",
|
PronounPossessive = "their"
|
||||||
SrcRes = "unspecified"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
db.Insert(user);
|
db.Insert(user);
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
}
|
}
|
||||||
var user = db.Users.First(p => p.Username == Model.User);
|
var user = db.Users.First(p => p.Username == Model.User);
|
||||||
var live = StreamUtils.IsLive(user.Username);
|
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
|
var pronounAdditional = user.PronounSubject == "they" ? "are" : "is"; // TODO make this configurable too
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,14 +27,14 @@
|
||||||
<p>@user.PronounSubject.FirstCharToUpper() @pronounAdditional currently live! @user.PronounSubject.FirstCharToUpper() have not specified a stream chat URL, so enjoy @user.PronounPossessive content!</p>
|
<p>@user.PronounSubject.FirstCharToUpper() @pronounAdditional currently live! @user.PronounSubject.FirstCharToUpper() have not specified a stream chat URL, so enjoy @user.PronounPossessive content!</p>
|
||||||
}
|
}
|
||||||
<div class="btn-group btn-group-lg" role="group">
|
<div class="btn-group btn-group-lg" role="group">
|
||||||
<a href="@Program.PlayerDomain/@user.Username" target="_blank" role="button" class="btn btn-success" data-toggle="tooltip" data-placement="bottom" title="@user.SrcRes">Source</a>
|
<a href="@Program.PlayerDomain/@user.Username" target="_blank" role="button" class="btn btn-success" data-toggle="tooltip" data-placement="bottom" title="@(stream.Meta.Video.Width)x@(stream.Meta.Video.Height) @@ @(Math.Round(float.Parse(stream.BwIn) / 1000000, 2)) Mbps">Source - @(stream.Meta.Video.Height)p</a>
|
||||||
@if (user.AllowRestream) {
|
@if (user.AllowRestream) {
|
||||||
if ((user.RestreamUrls ?? "").Contains(",")) {
|
if ((user.RestreamUrls ?? "").Contains(",")) {
|
||||||
<a href="@user.RestreamUrls!.Split(",")[0]" target="_blank" role="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="@user.SrcRes">Twitch Restream</a>
|
<a href="@user.RestreamUrls!.Split(",")[0]" target="_blank" role="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="@(stream.Meta.Video.Width)x@(stream.Meta.Video.Height) @@ @(Math.Round(float.Parse(stream.BwIn) / 1000000, 2)) Mbps">Source - @(stream.Meta.Video.Height)p">Twitch Restream</a>
|
||||||
<a href="@user.RestreamUrls!.Split(",")[1]" target="_blank" role="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="Source @@ 10Mbit VBR">YouTube Restream</a>
|
<a href="@user.RestreamUrls!.Split(",")[1]" target="_blank" role="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="Source @@ 10Mbit VBR">YouTube Restream</a>
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrWhiteSpace(user.RestreamUrls)) {
|
else if (!string.IsNullOrWhiteSpace(user.RestreamUrls)) {
|
||||||
<a href="@user.RestreamUrls" target="_blank" role="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="@user.SrcRes">Twitch Restream</a>
|
<a href="@user.RestreamUrls" target="_blank" role="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="@(stream.Meta.Video.Width)x@(stream.Meta.Video.Height) @@ @(Math.Round(float.Parse(stream.BwIn) / 1000000, 2)) Mbps">Source - @(stream.Meta.Video.Height)p">Twitch Restream</a>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": "true",
|
"dotnetRunMessages": "true",
|
||||||
"launchBrowser": false,
|
"launchBrowser": false,
|
||||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
"applicationUrl": "http://localhost:60001",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ namespace RTMPDash {
|
||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
||||||
app.UseSession();
|
app.UseSession();
|
||||||
|
|
|
@ -3,22 +3,17 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using RTMPDash.DataModels;
|
|
||||||
|
|
||||||
namespace RTMPDash {
|
namespace RTMPDash {
|
||||||
public class StreamUtils {
|
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<string> ListLiveUsers() => GetStatsObject()
|
||||||
|
.Server.Applications.First(p => p.Name == "ingress")
|
||||||
public static List<string> ListLiveUsers() {
|
.MethodLive.Streams.Select(p => p.Name)
|
||||||
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();
|
.ToList();
|
||||||
}
|
|
||||||
|
|
||||||
public static StatsObject GetStatsObject() {
|
public static StatsObject GetStatsObject() {
|
||||||
var serializer = new XmlSerializer(typeof(StatsObject));
|
var serializer = new XmlSerializer(typeof(StatsObject));
|
||||||
|
|
Loading…
Reference in a new issue