From 5d15def140169770430f88a1292866976521cef3 Mon Sep 17 00:00:00 2001 From: Roman Stefko Date: Fri, 29 Apr 2022 06:50:44 +0200 Subject: [PATCH 1/2] Allow IDs to be string - used by owncloud music --- MB_SubSonic/Domain/subsonic-rest-api-1.14.0.Designer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MB_SubSonic/Domain/subsonic-rest-api-1.14.0.Designer.cs b/MB_SubSonic/Domain/subsonic-rest-api-1.14.0.Designer.cs index 60241af..ff83ae1 100644 --- a/MB_SubSonic/Domain/subsonic-rest-api-1.14.0.Designer.cs +++ b/MB_SubSonic/Domain/subsonic-rest-api-1.14.0.Designer.cs @@ -19970,14 +19970,14 @@ public partial class MusicFolder private bool _shouldSerializeid; - private int _id; + private string _id; private string _name; private static XmlSerializer serializer; [System.Xml.Serialization.XmlAttributeAttribute()] - public int id + public string id { get { @@ -20024,7 +20024,7 @@ public virtual bool ShouldSerializeid() { return true; } - return (_id != default(int)); + return !string.IsNullOrEmpty(_id); } /// From 17f16d021417c589ec2d31fa7add07747f162a92 Mon Sep 17 00:00:00 2001 From: Roman Stefko Date: Sat, 30 Apr 2022 21:01:27 +0200 Subject: [PATCH 2/2] Support for servers that does not provide path (eg. ownCloud Music) --- MB_SubSonic/Subsonic.cs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/MB_SubSonic/Subsonic.cs b/MB_SubSonic/Subsonic.cs index 4aa49b6..a2b6fae 100644 --- a/MB_SubSonic/Subsonic.cs +++ b/MB_SubSonic/Subsonic.cs @@ -466,7 +466,7 @@ private static IEnumerable> GetIndexes(string colle return folders; } - private static void GetFolderFiles(string baseFolderName, string folderId, + private static void GetFolderFiles(string baseFolderName, string folderPath, string folderId, ICollection[]> files) { // Workaround for MusicBee calling GetFile on root folder(s) @@ -499,6 +499,12 @@ private static void GetFolderFiles(string baseFolderName, string folderId, var childEntry = content.child[index]; if (!childEntry.isDir) { + // Support for servers that does not provide path (eg. ownCloud Music) + if (childEntry.path == null) + { + childEntry.path = string.Concat(folderPath.Substring(baseFolderName.Length + 1), childEntry.id); + } + var tags = GetTags(childEntry, baseFolderName); if (tags != null) files.Add(tags); @@ -551,7 +557,7 @@ private static KeyValuePair[][] GetFolderFiles(string path) if (rootFolders.Any(x => x.Key.Equals(folderId))) return new KeyValuePair[][] { }; - GetFolderFiles(path.Substring(0, path.IndexOf(@"\", StringComparison.Ordinal)), folderId, files); + GetFolderFiles(path.Substring(0, path.IndexOf(@"\", StringComparison.Ordinal)), path, folderId, files); return files.ToArray(); } @@ -646,7 +652,8 @@ private static string GetTranslatedUrl(string url) private static string GetFileId(string url) { var folderId = GetFolderId(url); - if (string.IsNullOrWhiteSpace(folderId)) return null; + if (string.IsNullOrWhiteSpace(folderId)) + return null; // Workaround for MusicBee calling this on root folder(s) var rootFolders = GetRootFolders(true, true, false); @@ -670,11 +677,22 @@ private static string GetFileId(string url) var content = result.Item as Directory; var filePath = GetTranslatedUrl(url.Substring(url.IndexOf(@"\", StringComparison.Ordinal) + 1)); - if (content?.child == null) return null; + if (content?.child == null) + return null; foreach (var childEntry in content.child) + { + // Support for servers that does not provide path (eg. ownCloud Music) + if (childEntry.path == null && filePath.EndsWith(childEntry.id)) + { + return childEntry.id; + } + if (childEntry.path == filePath) + { return childEntry.id; + } + } } else { @@ -689,7 +707,8 @@ private static string GetFileId(string url) var content = result.Item as LibreSonicAPI.Directory; var filePath = GetTranslatedUrl(url.Substring(url.IndexOf(@"\", StringComparison.Ordinal) + 1)); - if (content?.child == null) return null; + if (content?.child == null) + return null; foreach (var childEntry in content.child) if (childEntry.path == filePath)