Detect directory separators in paths
This commit is contained in:
@@ -60,20 +60,35 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
|
|||||||
/// Get video name from file path on the disk.
|
/// Get video name from file path on the disk.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">File path on disk.</param>
|
/// <param name="path">File path on disk.</param>
|
||||||
/// <returns></returns>
|
/// <returns>The video name.</returns>
|
||||||
public static string GetVideoNameFromPath(string path)
|
public static string GetVideoNameFromPath(string path)
|
||||||
{
|
{
|
||||||
return path.Split(Path.DirectorySeparatorChar).Last().Split(".").First();
|
return path.Split(DetectDirectorySeparator(path)).Last().Split(".").First();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get channel name from directory path on the disk.
|
/// Get channel name from directory path on the disk.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">Directory path on disk.</param>
|
/// <param name="path">Directory path on disk.</param>
|
||||||
/// <returns></returns>
|
/// <returns>The channel name.</returns>
|
||||||
public static string GetChannelNameFromPath(string path)
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@
|
|||||||
name: "TubeArchivistMetadata"
|
name: "TubeArchivistMetadata"
|
||||||
guid: "dc97d0c6-28b0-4242-afb4-5833ae1b3715"
|
guid: "dc97d0c6-28b0-4242-afb4-5833ae1b3715"
|
||||||
imageUrl: https://raw.githubusercontent.com/tubearchivist/tubearchivist-jf-plugin/master/images/logo.png
|
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"
|
targetAbi: "10.8.0.0"
|
||||||
framework: "net6.0"
|
framework: "net6.0"
|
||||||
overview: "Metadata for your TubeArchivist library on Jellyfin"
|
overview: "Metadata for your TubeArchivist library on Jellyfin"
|
||||||
@@ -14,4 +14,4 @@ owner: "DarkFighterLuke"
|
|||||||
artifacts:
|
artifacts:
|
||||||
- "Jellyfin.Plugin.TubeArchivistMetadata.dll"
|
- "Jellyfin.Plugin.TubeArchivistMetadata.dll"
|
||||||
changelog: >
|
changelog: >
|
||||||
Add fix for unclosed HTML breaks
|
Fix issues with directory separators
|
||||||
|
|||||||
Reference in New Issue
Block a user