From 56e8c29a9494adf4605a249be19dfefc12992388 Mon Sep 17 00:00:00 2001 From: DarkFighterLuke Date: Thu, 9 May 2024 15:32:18 +0200 Subject: [PATCH] Detect directory separators in paths --- .../Utils/Utils.cs | 23 +++++++++++++++---- build.yaml | 4 ++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Jellyfin.Plugin.TubeArchivistMetadata/Utils/Utils.cs b/Jellyfin.Plugin.TubeArchivistMetadata/Utils/Utils.cs index 590b253..e4a1876 100644 --- a/Jellyfin.Plugin.TubeArchivistMetadata/Utils/Utils.cs +++ b/Jellyfin.Plugin.TubeArchivistMetadata/Utils/Utils.cs @@ -60,20 +60,35 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities /// Get video name from file path on the disk. /// /// File path on disk. - /// + /// The video name. public static string GetVideoNameFromPath(string path) { - return path.Split(Path.DirectorySeparatorChar).Last().Split(".").First(); + return path.Split(DetectDirectorySeparator(path)).Last().Split(".").First(); } /// /// Get channel name from directory path on the disk. /// /// Directory path on disk. - /// + /// The channel name. public static string GetChannelNameFromPath(string path) { - return path.Split(Path.DirectorySeparatorChar).Last(); + return path.Split(DetectDirectorySeparator(path)).Last(); + } + + private static char DetectDirectorySeparator(string path) + { + int backslashCount = path.Count(c => c == '\\'); + int forwardSlashCount = path.Count(c => c == '/'); + + if (backslashCount > forwardSlashCount) + { + return '\\'; // Windows directory separator + } + else + { + return '/'; // Unix directory separator + } } } } diff --git a/build.yaml b/build.yaml index e557709..b8587e4 100644 --- a/build.yaml +++ b/build.yaml @@ -2,7 +2,7 @@ name: "TubeArchivistMetadata" guid: "dc97d0c6-28b0-4242-afb4-5833ae1b3715" imageUrl: https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png -version: "1.2.3.0" +version: "1.2.4.0" targetAbi: "10.8.0.0" framework: "net6.0" overview: "Metadata for your TubeArchivist library on Jellyfin" @@ -14,4 +14,4 @@ owner: "DarkFighterLuke" artifacts: - "Jellyfin.Plugin.TubeArchivistMetadata.dll" changelog: > - Add fix for unclosed HTML breaks + Fix issues with directory separators