Change GetItem to return null to handle nullable LibraryManager (#137)
This commit is contained in:
parent
c4fbfd43ab
commit
920fa34a43
@ -154,7 +154,7 @@ public class SkipIntroController : ControllerBase
|
|||||||
{
|
{
|
||||||
// Get the details of the item from Jellyfin
|
// Get the details of the item from Jellyfin
|
||||||
var rawItem = Plugin.Instance.GetItem(intro.Key);
|
var rawItem = Plugin.Instance.GetItem(intro.Key);
|
||||||
if (rawItem is not Episode episode)
|
if (rawItem == null || rawItem is not Episode episode)
|
||||||
{
|
{
|
||||||
throw new InvalidCastException("Unable to cast item id " + intro.Key + " to an Episode");
|
throw new InvalidCastException("Unable to cast item id " + intro.Key + " to an Episode");
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,7 @@ public class VisualizationController : ControllerBase
|
|||||||
foreach (var e in episodes)
|
foreach (var e in episodes)
|
||||||
{
|
{
|
||||||
Plugin.Instance!.Intros.Remove(e.EpisodeId);
|
Plugin.Instance!.Intros.Remove(e.EpisodeId);
|
||||||
|
Plugin.Instance!.Credits.Remove(e.EpisodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin.Instance!.SaveTimestamps();
|
Plugin.Instance!.SaveTimestamps();
|
||||||
|
@ -351,7 +351,7 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
return commit;
|
return commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal BaseItem GetItem(Guid id)
|
internal BaseItem? GetItem(Guid id)
|
||||||
{
|
{
|
||||||
return _libraryManager.GetItemById(id);
|
return _libraryManager.GetItemById(id);
|
||||||
}
|
}
|
||||||
@ -363,7 +363,15 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
/// <returns>Full path to item.</returns>
|
/// <returns>Full path to item.</returns>
|
||||||
internal string GetItemPath(Guid id)
|
internal string GetItemPath(Guid id)
|
||||||
{
|
{
|
||||||
return GetItem(id).Path;
|
var item = GetItem(id);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
// Handle the case where the item is not found
|
||||||
|
_logger.LogWarning("Item with ID {Id} not found.", id);
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -373,7 +381,15 @@ public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
|
|||||||
/// <returns>List of chapters.</returns>
|
/// <returns>List of chapters.</returns>
|
||||||
internal List<ChapterInfo> GetChapters(Guid id)
|
internal List<ChapterInfo> GetChapters(Guid id)
|
||||||
{
|
{
|
||||||
return _itemRepository.GetChapters(GetItem(id));
|
var item = GetItem(id);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
// Handle the case where the item is not found
|
||||||
|
_logger.LogWarning("Item with ID {Id} not found.", id);
|
||||||
|
return new List<ChapterInfo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
return _itemRepository.GetChapters(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void UpdateTimestamps(Dictionary<Guid, Intro> newTimestamps, AnalysisMode mode)
|
internal void UpdateTimestamps(Dictionary<Guid, Intro> newTimestamps, AnalysisMode mode)
|
||||||
|
@ -63,7 +63,15 @@ public class QueueManager
|
|||||||
{
|
{
|
||||||
foreach (var location in folder.Locations)
|
foreach (var location in folder.Locations)
|
||||||
{
|
{
|
||||||
QueueLibraryContents(_libraryManager.FindByPath(location, true).Id);
|
var item = _libraryManager.FindByPath(location, true);
|
||||||
|
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Unable to find linked item at path {0}", location);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QueueLibraryContents(item.Id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user