TrickplayController return 404 if playlist doesn't exist. Minor code style/format changes (crobibero)
This commit is contained in:
parent
a9594cd8b4
commit
049361b66c
|
@ -1,9 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Jellyfin.Api.Attributes;
|
using Jellyfin.Api.Attributes;
|
||||||
|
@ -50,6 +47,7 @@ public class TrickplayController : BaseJellyfinApiController
|
||||||
/// <returns>A <see cref="FileResult"/> containing the trickplay tiles file.</returns>
|
/// <returns>A <see cref="FileResult"/> containing the trickplay tiles file.</returns>
|
||||||
[HttpGet("Videos/{itemId}/Trickplay/{width}/tiles.m3u8")]
|
[HttpGet("Videos/{itemId}/Trickplay/{width}/tiles.m3u8")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[ProducesPlaylistFile]
|
[ProducesPlaylistFile]
|
||||||
public ActionResult GetTrickplayHlsPlaylist(
|
public ActionResult GetTrickplayHlsPlaylist(
|
||||||
[FromRoute, Required] Guid itemId,
|
[FromRoute, Required] Guid itemId,
|
||||||
|
@ -109,7 +107,7 @@ public class TrickplayController : BaseJellyfinApiController
|
||||||
var resolution = $"{tilesInfo.Width}x{tilesInfo.Height}";
|
var resolution = $"{tilesInfo.Width}x{tilesInfo.Height}";
|
||||||
var layout = $"{tilesInfo.TileWidth}x{tilesInfo.TileHeight}";
|
var layout = $"{tilesInfo.TileWidth}x{tilesInfo.TileHeight}";
|
||||||
var tilesPerGrid = tilesInfo.TileWidth * tilesInfo.TileHeight;
|
var tilesPerGrid = tilesInfo.TileWidth * tilesInfo.TileHeight;
|
||||||
var tileDuration = tilesInfo.Interval / 1000m;
|
var tileDuration = tilesInfo.Interval / 1000d;
|
||||||
var infDuration = tileDuration * tilesPerGrid;
|
var infDuration = tileDuration * tilesPerGrid;
|
||||||
var tileGridCount = (int)Math.Ceiling((decimal)tilesInfo.TileCount / tilesPerGrid);
|
var tileGridCount = (int)Math.Ceiling((decimal)tilesInfo.TileCount / tilesPerGrid);
|
||||||
|
|
||||||
|
@ -132,18 +130,10 @@ public class TrickplayController : BaseJellyfinApiController
|
||||||
infDuration = tileDuration * tilesPerGrid;
|
infDuration = tileDuration * tilesPerGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = string.Format(
|
|
||||||
CultureInfo.InvariantCulture,
|
|
||||||
urlFormat,
|
|
||||||
width.ToString(CultureInfo.InvariantCulture),
|
|
||||||
i.ToString(CultureInfo.InvariantCulture),
|
|
||||||
mediaSourceId.ToString("N"),
|
|
||||||
User.GetToken());
|
|
||||||
|
|
||||||
// EXTINF
|
// EXTINF
|
||||||
builder
|
builder
|
||||||
.Append("#EXTINF:")
|
.Append("#EXTINF:")
|
||||||
.Append(string.Format(CultureInfo.InvariantCulture, decimalFormat, infDuration))
|
.AppendFormat(CultureInfo.InvariantCulture, decimalFormat, infDuration)
|
||||||
.AppendLine(",");
|
.AppendLine(",");
|
||||||
|
|
||||||
// EXT-X-TILES
|
// EXT-X-TILES
|
||||||
|
@ -153,10 +143,19 @@ public class TrickplayController : BaseJellyfinApiController
|
||||||
.Append(",LAYOUT=")
|
.Append(",LAYOUT=")
|
||||||
.Append(layout)
|
.Append(layout)
|
||||||
.Append(",DURATION=")
|
.Append(",DURATION=")
|
||||||
.AppendLine(string.Format(CultureInfo.InvariantCulture, decimalFormat, tileDuration));
|
.AppendFormat(CultureInfo.InvariantCulture, decimalFormat, tileDuration)
|
||||||
|
.AppendLine();
|
||||||
|
|
||||||
// URL
|
// URL
|
||||||
builder.AppendLine(url);
|
builder
|
||||||
|
.AppendFormat(
|
||||||
|
CultureInfo.InvariantCulture,
|
||||||
|
urlFormat,
|
||||||
|
width.ToString(CultureInfo.InvariantCulture),
|
||||||
|
i.ToString(CultureInfo.InvariantCulture),
|
||||||
|
mediaSourceId.ToString("N"),
|
||||||
|
User.GetToken())
|
||||||
|
.AppendLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.AppendLine("#EXT-X-ENDLIST");
|
builder.AppendLine("#EXT-X-ENDLIST");
|
||||||
|
@ -164,6 +163,6 @@ public class TrickplayController : BaseJellyfinApiController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FileContentResult(Array.Empty<byte>(), MimeTypes.GetMimeType("playlist.m3u8"));
|
return NotFound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Controller.Trickplay;
|
using MediaBrowser.Controller.Trickplay;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.Trickplay;
|
namespace MediaBrowser.Providers.Trickplay;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user