89 lines
2.6 KiB
C#
Raw Normal View History

2022-11-23 01:20:48 -06:00
using System;
using System.Net.Mime;
using System.Text;
using MediaBrowser.Common;
2024-05-13 23:50:51 +02:00
using MediaBrowser.Common.Api;
2024-04-20 13:04:56 +02:00
using MediaBrowser.Common.Configuration;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace ConfusedPolarBear.Plugin.IntroSkipper.Controllers;
/// <summary>
/// Troubleshooting controller.
/// </summary>
2024-05-13 23:50:51 +02:00
[Authorize(Policy = Policies.RequiresElevation)]
[ApiController]
[Produces(MediaTypeNames.Application.Json)]
[Route("IntroSkipper")]
public class TroubleshootingController : ControllerBase
{
private readonly IApplicationHost _applicationHost;
private readonly ILogger<TroubleshootingController> _logger;
/// <summary>
/// Initializes a new instance of the <see cref="TroubleshootingController"/> class.
/// </summary>
/// <param name="applicationHost">Application host.</param>
/// <param name="logger">Logger.</param>
public TroubleshootingController(
IApplicationHost applicationHost,
ILogger<TroubleshootingController> logger)
{
_applicationHost = applicationHost;
_logger = logger;
}
/// <summary>
/// Gets a Markdown formatted support bundle.
/// </summary>
/// <response code="200">Support bundle created.</response>
/// <returns>Support bundle.</returns>
[HttpGet("SupportBundle")]
[Produces(MediaTypeNames.Text.Plain)]
public ActionResult<string> GetSupportBundle()
{
2024-04-20 13:04:56 +02:00
ArgumentNullException.ThrowIfNull(Plugin.Instance);
var bundle = new StringBuilder();
bundle.Append("* Jellyfin version: ");
bundle.Append(_applicationHost.ApplicationVersionString);
bundle.Append('\n');
2024-04-20 12:21:07 +02:00
var version = Plugin.Instance.Version.ToString(3);
2022-11-23 01:20:48 -06:00
try
{
2024-04-20 12:21:07 +02:00
var commit = Plugin.Instance.GetCommit();
2022-11-23 01:20:48 -06:00
if (!string.IsNullOrWhiteSpace(commit))
{
version += string.Concat("+", commit.AsSpan(0, 12));
}
}
catch (Exception ex)
{
_logger.LogWarning("Unable to append commit to version: {Exception}", ex);
}
bundle.Append("* Plugin version: ");
2022-11-23 01:20:48 -06:00
bundle.Append(version);
bundle.Append('\n');
bundle.Append("* Queue contents: ");
2024-04-20 12:21:07 +02:00
bundle.Append(Plugin.Instance.TotalQueued);
2023-06-08 00:51:18 -05:00
bundle.Append(" episodes, ");
2024-04-20 12:21:07 +02:00
bundle.Append(Plugin.Instance.TotalSeasons);
2023-06-08 00:51:18 -05:00
bundle.Append(" seasons\n");
2022-11-06 21:25:23 -06:00
bundle.Append("* Warnings: `");
bundle.Append(WarningManager.GetWarnings());
bundle.Append("`\n");
2022-08-28 22:35:43 -05:00
bundle.Append(FFmpegWrapper.GetChromaprintLogs());
return bundle.ToString();
}
}