|
@@ -49,8 +49,8 @@ namespace FNZCM.ConHost
|
|
//media
|
|
//media
|
|
var mediaFiles = FileSystem.GetFiles(albumPath, SearchOption.SearchTopLevelOnly, ConfigFile.Instance.MediaFilePattern);
|
|
var mediaFiles = FileSystem.GetFiles(albumPath, SearchOption.SearchTopLevelOnly, ConfigFile.Instance.MediaFilePattern);
|
|
foreach (var mediaFile in mediaFiles) mappings[$"/media/{library.Key}/{albumName}/{Path.GetFileName(mediaFile)}".ToLower()] = mediaFile;
|
|
foreach (var mediaFile in mediaFiles) mappings[$"/media/{library.Key}/{albumName}/{Path.GetFileName(mediaFile)}".ToLower()] = mediaFile;
|
|
- var trackers = mediaFiles.Select(Path.GetFileName).ToArray();
|
|
|
|
- var trackerPaths = trackers.Select(p => p.ToLower()).ToArray();
|
|
|
|
|
|
+ var tracks = mediaFiles.Select(Path.GetFileName).ToArray();
|
|
|
|
+ var trackPaths = tracks.Select(p => p.ToLower()).ToArray();
|
|
|
|
|
|
//bk
|
|
//bk
|
|
var bkPath = Path.Combine(albumPath, "bk");
|
|
var bkPath = Path.Combine(albumPath, "bk");
|
|
@@ -66,7 +66,7 @@ namespace FNZCM.ConHost
|
|
var coverPath = Path.Combine(albumPath, "cover.jpg");
|
|
var coverPath = Path.Combine(albumPath, "cover.jpg");
|
|
if (File.Exists(coverPath)) mappings[$"/cover/{library.Key}/{albumName}/{Path.GetFileName(coverPath)}".ToLower()] = coverPath;
|
|
if (File.Exists(coverPath)) mappings[$"/cover/{library.Key}/{albumName}/{Path.GetFileName(coverPath)}".ToLower()] = coverPath;
|
|
|
|
|
|
- albumObjects.Add(new Album(albumName, albumPathName, trackers, trackerPaths, bks));
|
|
|
|
|
|
+ albumObjects.Add(new Album(albumName, albumPathName, tracks, trackPaths, bks));
|
|
}
|
|
}
|
|
|
|
|
|
libs[library.Key.ToLower()] = new Library(libraryName, libraryPathName, albumObjects);
|
|
libs[library.Key.ToLower()] = new Library(libraryName, libraryPathName, albumObjects);
|
|
@@ -76,7 +76,7 @@ namespace FNZCM.ConHost
|
|
_pathMapping = mappings;
|
|
_pathMapping = mappings;
|
|
|
|
|
|
Console.WriteLine($" Scanned all {libs.Count} library");
|
|
Console.WriteLine($" Scanned all {libs.Count} library");
|
|
- Console.WriteLine($" Total {libs.Sum(p => p.Value.Albums.Count)} Albums, {libs.Sum(p => p.Value.Albums.Sum(q => q.Trackers.Count))} Trackers");
|
|
|
|
|
|
+ Console.WriteLine($" Total {libs.Sum(p => p.Value.Albums.Count)} Albums, {libs.Sum(p => p.Value.Albums.Sum(q => q.Tracks.Count))} Tracks");
|
|
|
|
|
|
Console.Write("Reading small files to cache");
|
|
Console.Write("Reading small files to cache");
|
|
Console.WriteLine();
|
|
Console.WriteLine();
|
|
@@ -99,7 +99,7 @@ namespace FNZCM.ConHost
|
|
|
|
|
|
_smallFileCaches = caches;
|
|
_smallFileCaches = caches;
|
|
|
|
|
|
- Console.WriteLine($" Cached {_smallFileCaches.Count} small files, total {_smallFileCaches.Values.Sum(p=>p.Length)/(1024.0*1024):N6} MB");
|
|
|
|
|
|
+ Console.WriteLine($" Cached {_smallFileCaches.Count} small files, total {_smallFileCaches.Values.Sum(p => p.Length) / (1024.0 * 1024):N6} MB");
|
|
|
|
|
|
Console.WriteLine("Starting...");
|
|
Console.WriteLine("Starting...");
|
|
|
|
|
|
@@ -138,8 +138,8 @@ namespace FNZCM.ConHost
|
|
{
|
|
{
|
|
var timeSpan = DateTime.Now - _lastRequestAccepted;
|
|
var timeSpan = DateTime.Now - _lastRequestAccepted;
|
|
var up = DateTime.Now - upTime;
|
|
var up = DateTime.Now - upTime;
|
|
- Console.Title =
|
|
|
|
- "FNZCM"
|
|
|
|
|
|
+ Console.Title =
|
|
|
|
+ "FNZCM"
|
|
+ $" UP {up.Days:00}D {up.Hours:00}H {up.Minutes:00}M {up.Seconds:00}S {up.Milliseconds:000}"
|
|
+ $" UP {up.Days:00}D {up.Hours:00}H {up.Minutes:00}M {up.Seconds:00}S {up.Milliseconds:000}"
|
|
+ $" / "
|
|
+ $" / "
|
|
+ $" LA {timeSpan.Days:00}D {timeSpan.Hours:00}H {timeSpan.Minutes:00}M {timeSpan.Seconds:00}S {timeSpan.Milliseconds:000}"
|
|
+ $" LA {timeSpan.Days:00}D {timeSpan.Hours:00}H {timeSpan.Minutes:00}M {timeSpan.Seconds:00}S {timeSpan.Milliseconds:000}"
|
|
@@ -185,7 +185,7 @@ namespace FNZCM.ConHost
|
|
// foo=library bar=album
|
|
// foo=library bar=album
|
|
// GET /list/foo/ show all album and cover with name, provide m3u path
|
|
// GET /list/foo/ show all album and cover with name, provide m3u path
|
|
// GET /list/foo/bar/bk/ list all picture as grid
|
|
// GET /list/foo/bar/bk/ list all picture as grid
|
|
- // GET /list/foo/bar/trackers/ list all trackers as text list
|
|
|
|
|
|
+ // GET /list/foo/bar/tracks/ list all tracks as text list
|
|
// GET /list/foo/bar/playlist.m3u8 auto gen
|
|
// GET /list/foo/bar/playlist.m3u8 auto gen
|
|
|
|
|
|
// media streaming HTTP Partial RANGE SUPPORT
|
|
// media streaming HTTP Partial RANGE SUPPORT
|
|
@@ -263,7 +263,7 @@ namespace FNZCM.ConHost
|
|
sb.Append("<div class=item>");
|
|
sb.Append("<div class=item>");
|
|
sb.Append($"<img class=cover src=\"/cover/{lib.PathName}/{a.PathName}/cover.jpg\" />");
|
|
sb.Append($"<img class=cover src=\"/cover/{lib.PathName}/{a.PathName}/cover.jpg\" />");
|
|
sb.Append("<div class=buttons>");
|
|
sb.Append("<div class=buttons>");
|
|
- sb.Append($"<a class=button href=\"/list/{lib.PathName}/{a.PathName}/trackers/\">[TRACKERS]</a>");
|
|
|
|
|
|
+ sb.Append($"<a class=button href=\"/list/{lib.PathName}/{a.PathName}/tracks/\">[TRACKERS]</a>");
|
|
if (a.Bks != null) sb.Append($"<a class=button href=\"/list/{lib.PathName}/{a.PathName}/bk/\">[BK]</a>");
|
|
if (a.Bks != null) sb.Append($"<a class=button href=\"/list/{lib.PathName}/{a.PathName}/bk/\">[BK]</a>");
|
|
sb.Append($"<a class=button href=\"/list/{lib.PathName}/{a.PathName.FuckVlc()}/playlist.m3u8\">[M3U8]</a>");
|
|
sb.Append($"<a class=button href=\"/list/{lib.PathName}/{a.PathName.FuckVlc()}/playlist.m3u8\">[M3U8]</a>");
|
|
sb.Append("</div>");
|
|
sb.Append("</div>");
|
|
@@ -280,7 +280,7 @@ namespace FNZCM.ConHost
|
|
context.Response.Redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
|
|
context.Response.Redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if (pathParts.Count == 4 && pathParts[0] == "list" && pathParts[3] == "trackers")
|
|
|
|
|
|
+ else if (pathParts.Count == 4 && pathParts[0] == "list" && pathParts[3] == "tracks")
|
|
{
|
|
{
|
|
var libName = pathParts[1];
|
|
var libName = pathParts[1];
|
|
var albPath = pathParts[2];
|
|
var albPath = pathParts[2];
|
|
@@ -290,12 +290,12 @@ namespace FNZCM.ConHost
|
|
{
|
|
{
|
|
var sb = new StringBuilder();
|
|
var sb = new StringBuilder();
|
|
sb.Append("<!DOCTYPE html><html lang=\"zh-cn\"><meta charset=\"UTF-8\">");
|
|
sb.Append("<!DOCTYPE html><html lang=\"zh-cn\"><meta charset=\"UTF-8\">");
|
|
- sb.Append($"<body bgColor=skyBlue style=font-size:2vh><h2>Trackers of</h2><h1>{alb.Name}</h1>");
|
|
|
|
|
|
+ sb.Append($"<body bgColor=skyBlue style=font-size:2vh><h2>Tracks of</h2><h1>{alb.Name}</h1>");
|
|
sb.Append($"<div><a href=/list/{lib.PathName}/>Back to library</a></div>");
|
|
sb.Append($"<div><a href=/list/{lib.PathName}/>Back to library</a></div>");
|
|
|
|
|
|
- for (var i = 0; i < alb.TrackerPaths.Count; i++)
|
|
|
|
|
|
+ for (var i = 0; i < alb.TrackPaths.Count; i++)
|
|
{
|
|
{
|
|
- sb.Append($"<li><a href=\"/media/{lib.PathName.FuckVlc()}/{alb.PathName.FuckVlc()}/{alb.TrackerPaths[i].FuckVlc()}\" >{alb.Trackers[i]}</a></li>");
|
|
|
|
|
|
+ sb.Append($"<li><a href=\"/media/{lib.PathName.FuckVlc()}/{alb.PathName.FuckVlc()}/{alb.TrackPaths[i].FuckVlc()}\" >{alb.Tracks[i]}</a></li>");
|
|
}
|
|
}
|
|
|
|
|
|
context.Response.ContentType = "text/html";
|
|
context.Response.ContentType = "text/html";
|
|
@@ -349,9 +349,9 @@ namespace FNZCM.ConHost
|
|
var sb = new StringBuilder();
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
sb.AppendLine("#EXTM3U");
|
|
sb.AppendLine("#EXTM3U");
|
|
- foreach (var tracker in alb.TrackerPaths)
|
|
|
|
|
|
+ foreach (var track in alb.TrackPaths)
|
|
{
|
|
{
|
|
- var mediaKey = $"/media/{lib.PathName}/{alb.PathName}/{tracker}";
|
|
|
|
|
|
+ var mediaKey = $"/media/{lib.PathName}/{alb.PathName}/{track}";
|
|
var coverKey = $"/cover/{lib.PathName}/{alb.PathName}/cover.jpg";
|
|
var coverKey = $"/cover/{lib.PathName}/{alb.PathName}/cover.jpg";
|
|
|
|
|
|
if (false == MediaTags.TryGetValue(mediaKey, out var mediaTag))
|
|
if (false == MediaTags.TryGetValue(mediaKey, out var mediaTag))
|
|
@@ -364,7 +364,7 @@ namespace FNZCM.ConHost
|
|
sb.AppendLine(prefix + mediaKey.FuckVlc());
|
|
sb.AppendLine(prefix + mediaKey.FuckVlc());
|
|
}
|
|
}
|
|
|
|
|
|
- context.Response.ContentType = "audio/x-mpegurl";
|
|
|
|
|
|
+ context.Response.ContentType = "audio/mpegurl";
|
|
context.Response.ContentEncoding = Encoding.UTF8;
|
|
context.Response.ContentEncoding = Encoding.UTF8;
|
|
context.Response.WriteText(sb.ToString());
|
|
context.Response.WriteText(sb.ToString());
|
|
}
|
|
}
|
|
@@ -394,6 +394,7 @@ namespace FNZCM.ConHost
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ context.Response.ContentType = "video/mp4";
|
|
context.Response.OutputStream.Write(data);
|
|
context.Response.OutputStream.Write(data);
|
|
}
|
|
}
|
|
}
|
|
}
|