From d78640d931220bf6a30123287842954fd1d9b2b5 Mon Sep 17 00:00:00 2001 From: tcely Date: Mon, 13 Jan 2025 17:11:46 -0500 Subject: [PATCH] Match a specific YouTube ID The old code was finding the first image file with any YouTube ID in the filename. --- .../LocalMetadata/YoutubeLocalImageProvider.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Jellyfin.Plugin.YoutubeMetadata/Providers/LocalMetadata/YoutubeLocalImageProvider.cs b/Jellyfin.Plugin.YoutubeMetadata/Providers/LocalMetadata/YoutubeLocalImageProvider.cs index 53a3269..eb5e891 100644 --- a/Jellyfin.Plugin.YoutubeMetadata/Providers/LocalMetadata/YoutubeLocalImageProvider.cs +++ b/Jellyfin.Plugin.YoutubeMetadata/Providers/LocalMetadata/YoutubeLocalImageProvider.cs @@ -28,7 +28,7 @@ public YoutubeLocalImageProvider(IFileSystem fileSystem, ILogger Constants.PluginName; public int Order => 1; - private string GetSeriesInfo(string path) + private string GetSeriesInfo(string ytID, string path) { _logger.LogDebug("YTLocalImage GetSeriesInfo: {Path}", path); Matcher matcher = new(); @@ -37,7 +37,8 @@ private string GetSeriesInfo(string path) string infoPath = ""; foreach (string file in matcher.GetResultsInFullPath(path)) { - if (Regex.Match(file, Constants.YTID_RE).Success) + var match = Regex.Match(file, Constants.YTID_RE); + if (match.Success && match.Value == ytID) { infoPath = file; break; @@ -56,11 +57,8 @@ public IEnumerable GetImages(BaseItem item, IDirectoryService di { _logger.LogDebug("YTLocalImage GetImages: {Name}", item.Name); var list = new List(); - string jpgPath = GetSeriesInfo(item.ContainingFolderPath); - if (String.IsNullOrEmpty(jpgPath)) - { - return list; - } + var id = Utils.GetYTID(item.FileNameWithoutExtension); + string jpgPath = GetSeriesInfo(id, item.ContainingFolderPath); if (String.IsNullOrEmpty(jpgPath)) { return list;