官网:
easydarwin.org
问题:
Hls不能保存列表,解决方案已给出: http://www.pfeng.org/archives/857
但是不太好用。作者给出了原理。自己写了一个
解决方案:
核心代码:
namespace ExecApp { /// <summary> /// 保存 EasyDarwin 的 HLS 中的列表 /// </summary> public class HlsSaveHandler : ICommandHandler { public string Host { get; set; } public string Name { get; set; } public string Url { get; set; } public HlsSaveHandler(CmdArgs args) { args.ToModel(this); } public string Do() { if (this.Name.HasValue() == false) { return "请提供 Name 参数"; } if (this.Url.HasValue() == false) { return "请提供 Url 参数"; } var ssid = ""; MyNet.HttpPost(this.Host + "/login.html", o => { o.Headers["Cookie"] = "language0=0"; o.ContentType = "application/x-www-form-urlencoded"; return "name=admin&password=admin"; }, o => { if (o.StatusCode != System.Net.HttpStatusCode.Redirect) return; ssid = o.Headers["Set-Cookie"].AsString().MySplit(‘;‘).First(); }); if (ssid.HasValue() == false) return "登录失败"; MyNet.HttpPost(this.Host + "/api/addHLSList", o => { o.ContentType = "Content-Type:application/x-www-form-urlencoded; charset=UTF-8"; o.Headers["Cookie"] = "language0=0; " + ssid; return string.Format(@"n1={0}&n2={1}&n3=0", this.Name, HttpUtility.UrlEncode(this.Url)); }); return ""; } } }
调用:
bin\debug\ExecApp -HlsSave -Host "http://localhost:8088" -Name ab -Url "rtsp://admin:[email protected]"
可以写一个Bat,循环调用。
程序下载地址:http://files.cnblogs.com/files/newsea/ExecApp.rar
时间: 2024-10-12 18:40:48