[feat] Video system optimization2
This commit is contained in:
10
.idea/.idea.Abyss/.idea/workspace.xml
generated
10
.idea/.idea.Abyss/.idea/workspace.xml
generated
@@ -11,14 +11,6 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="bf317275-3039-49bb-a475-725a800a0cce" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Abyss/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Abyss/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Abyss/Components/Controllers/Media/ImageController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Controllers/Media/ImageController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Abyss/Components/Controllers/Media/LiveController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Controllers/Media/LiveController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Abyss/Components/Controllers/Media/VideoController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Controllers/Media/VideoController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Abyss/Components/Controllers/Security/RootController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Controllers/Security/RootController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Abyss/Components/Controllers/Security/UserController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Controllers/Security/UserController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Abyss/Components/Controllers/Task/TaskController.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Controllers/Task/TaskController.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Abyss/Components/Services/ResourceService.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Components/Services/ResourceService.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Abyss/Toolkits/update-video.py" beforeDir="false" afterPath="$PROJECT_DIR$/Abyss/Toolkits/update-video.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -230,7 +222,7 @@
|
||||
<workItem from="1758084310862" duration="17701000" />
|
||||
<workItem from="1758121232981" duration="69000" />
|
||||
<workItem from="1758279286341" duration="6796000" />
|
||||
<workItem from="1758303096075" duration="2017000" />
|
||||
<workItem from="1758303096075" duration="2560000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
||||
@@ -118,22 +118,34 @@ public class VideoController(ILogger<VideoController> logger, ResourceService rs
|
||||
public async Task<IActionResult> Subtitle(string klass, string id, string token)
|
||||
{
|
||||
var folder = Helpers.SafePathCombine(VideoFolder, new[] { klass, id });
|
||||
if (folder == null)
|
||||
if (folder == null)
|
||||
return StatusCode(403, new { message = "403 Denied" });
|
||||
|
||||
string? subtitlePath = null;
|
||||
|
||||
try
|
||||
{
|
||||
var preferred = Path.Combine(folder, "subtitle.ass");
|
||||
if (System.IO.File.Exists(preferred))
|
||||
var preferredVtt = Path.Combine(folder, "subtitle.vtt");
|
||||
if (System.IO.File.Exists(preferredVtt))
|
||||
{
|
||||
subtitlePath = preferred;
|
||||
subtitlePath = preferredVtt;
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitlePath = Directory.EnumerateFiles(folder, "*.ass")
|
||||
.FirstOrDefault();
|
||||
subtitlePath = Directory.EnumerateFiles(folder, "*.vtt").FirstOrDefault();
|
||||
|
||||
if (subtitlePath == null)
|
||||
{
|
||||
var preferredAss = Path.Combine(folder, "subtitle.ass");
|
||||
if (System.IO.File.Exists(preferredAss))
|
||||
{
|
||||
subtitlePath = preferredAss;
|
||||
}
|
||||
else
|
||||
{
|
||||
subtitlePath = Directory.EnumerateFiles(folder, "*.ass").FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
@@ -141,14 +153,22 @@ public class VideoController(ILogger<VideoController> logger, ResourceService rs
|
||||
return NotFound(new { message = "video folder not found" });
|
||||
}
|
||||
|
||||
if (subtitlePath == null)
|
||||
if (subtitlePath == null)
|
||||
return NotFound(new { message = "subtitle not found" });
|
||||
|
||||
var r = await rs.Get(subtitlePath, token, Ip);
|
||||
if (!r)
|
||||
if (!r)
|
||||
return StatusCode(403, new { message = "403 Denied" });
|
||||
|
||||
return PhysicalFile(subtitlePath, "text/x-ssa", enableRangeProcessing: false);
|
||||
var ext = Path.GetExtension(subtitlePath).ToLowerInvariant();
|
||||
var contentType = ext switch
|
||||
{
|
||||
".vtt" => "text/vtt",
|
||||
".ass" => "text/x-ssa",
|
||||
_ => "text/plain"
|
||||
};
|
||||
|
||||
return PhysicalFile(subtitlePath, contentType, enableRangeProcessing: false);
|
||||
}
|
||||
|
||||
[HttpGet("{klass}/{id}/av")]
|
||||
|
||||
Reference in New Issue
Block a user