Rework fingerprint visualizer backend
This commit is contained in:
parent
715eea743f
commit
c72d8bafdf
@ -105,7 +105,7 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<details>
|
<details id="visualizer">
|
||||||
<summary>Fingerprint Visualizer</summary>
|
<summary>Fingerprint Visualizer</summary>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -178,6 +178,7 @@
|
|||||||
var shows = {};
|
var shows = {};
|
||||||
|
|
||||||
// ui elements
|
// ui elements
|
||||||
|
var visualizer = document.querySelector("details#visualizer");
|
||||||
var canvas = document.querySelector("canvas#troubleshooter");
|
var canvas = document.querySelector("canvas#troubleshooter");
|
||||||
var selectShow = document.querySelector("select#troubleshooterShow");
|
var selectShow = document.querySelector("select#troubleshooterShow");
|
||||||
var selectSeason = document.querySelector("select#troubleshooterSeason");
|
var selectSeason = document.querySelector("select#troubleshooterSeason");
|
||||||
@ -188,8 +189,14 @@
|
|||||||
var btnEraseTimestamps = document.querySelector("button#btnEraseTimestamps");
|
var btnEraseTimestamps = document.querySelector("button#btnEraseTimestamps");
|
||||||
var windowHashInterval = 0;
|
var windowHashInterval = 0;
|
||||||
|
|
||||||
// config page loaded, populate show names
|
// when the fingerprint visualizer opens, populate show names
|
||||||
async function onLoad() {
|
async function visualizerToggled() {
|
||||||
|
if (!visualizer.open) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
shows = await getJson("Intros/Shows");
|
shows = await getJson("Intros/Shows");
|
||||||
|
|
||||||
var sorted = [];
|
var sorted = [];
|
||||||
@ -201,6 +208,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectShow.value = "";
|
selectShow.value = "";
|
||||||
|
|
||||||
|
Dashboard.hideLoadingMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
// show changed, populate seasons
|
// show changed, populate seasons
|
||||||
@ -480,6 +489,7 @@
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
visualizer.addEventListener("toggle", visualizerToggled);
|
||||||
txtOffset.addEventListener("change", renderTroubleshooter);
|
txtOffset.addEventListener("change", renderTroubleshooter);
|
||||||
selectShow.addEventListener("change", showChanged);
|
selectShow.addEventListener("change", showChanged);
|
||||||
selectSeason.addEventListener("change", seasonChanged);
|
selectSeason.addEventListener("change", seasonChanged);
|
||||||
@ -540,9 +550,6 @@
|
|||||||
timeContainer.style.left = "25px";
|
timeContainer.style.left = "25px";
|
||||||
timeContainer.style.top = (-1 * rect.height + y).toString() + "px";
|
timeContainer.style.top = (-1 * rect.height + y).toString() + "px";
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: fix
|
|
||||||
setTimeout(onLoad, 250);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -5,6 +5,7 @@ using System.Globalization;
|
|||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace ConfusedPolarBear.Plugin.IntroSkipper.Controllers;
|
namespace ConfusedPolarBear.Plugin.IntroSkipper.Controllers;
|
||||||
|
|
||||||
@ -17,11 +18,15 @@ namespace ConfusedPolarBear.Plugin.IntroSkipper.Controllers;
|
|||||||
[Route("Intros")]
|
[Route("Intros")]
|
||||||
public class VisualizationController : ControllerBase
|
public class VisualizationController : ControllerBase
|
||||||
{
|
{
|
||||||
|
private readonly ILogger<VisualizationController> _logger;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="VisualizationController"/> class.
|
/// Initializes a new instance of the <see cref="VisualizationController"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public VisualizationController()
|
/// <param name="logger">Logger.</param>
|
||||||
|
public VisualizationController(ILogger<VisualizationController> logger)
|
||||||
{
|
{
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -31,23 +36,36 @@ public class VisualizationController : ControllerBase
|
|||||||
[HttpGet("Shows")]
|
[HttpGet("Shows")]
|
||||||
public ActionResult<Dictionary<string, HashSet<string>>> GetShowSeasons()
|
public ActionResult<Dictionary<string, HashSet<string>>> GetShowSeasons()
|
||||||
{
|
{
|
||||||
|
_logger.LogDebug("Returning season names by series");
|
||||||
|
|
||||||
var showSeasons = new Dictionary<string, HashSet<string>>();
|
var showSeasons = new Dictionary<string, HashSet<string>>();
|
||||||
|
|
||||||
// Loop through all episodes in the analysis queue
|
// Loop through all seasons in the analysis queue
|
||||||
foreach (var episodes in Plugin.Instance!.AnalysisQueue)
|
foreach (var kvp in Plugin.Instance!.AnalysisQueue)
|
||||||
{
|
{
|
||||||
foreach (var episode in episodes.Value)
|
// Check that this season contains at least one episode.
|
||||||
|
var episodes = kvp.Value;
|
||||||
|
if (episodes is null || episodes.Count == 0)
|
||||||
{
|
{
|
||||||
// Add each season's name to the series hashset
|
_logger.LogDebug("Skipping season {Id} (null or empty)", kvp.Key);
|
||||||
var series = episode.SeriesName;
|
continue;
|
||||||
|
|
||||||
if (!showSeasons.ContainsKey(series))
|
|
||||||
{
|
|
||||||
showSeasons[series] = new HashSet<string>();
|
|
||||||
}
|
|
||||||
|
|
||||||
showSeasons[series].Add(GetSeasonName(episode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Peek at the top episode from this season and store the series name and season number.
|
||||||
|
var first = episodes[0];
|
||||||
|
var series = first.SeriesName;
|
||||||
|
var season = GetSeasonName(first);
|
||||||
|
|
||||||
|
// Validate the series and season before attempting to store it.
|
||||||
|
if (string.IsNullOrWhiteSpace(series) || string.IsNullOrWhiteSpace(season))
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Skipping season {Id} (no name or number)", kvp.Key);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TryAdd is used when adding the HashSet since it is a no-op if one was already created for this series.
|
||||||
|
showSeasons.TryAdd(series, new HashSet<string>());
|
||||||
|
showSeasons[series].Add(season);
|
||||||
}
|
}
|
||||||
|
|
||||||
return showSeasons;
|
return showSeasons;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user