mickle026 401 Posted February 5 Share Posted February 5 I am wanting to use this interface for some data importing public Task<MetadataResult<MusicAlbum>> GetMetadata(ItemInfo info, LibraryOptions libraryOptions, IDirectoryService directoryService, CancellationToken cancellationToken) however from here I can get Album Name and The Album Id , but thats about it. I want to be able to get the Albums root path. I know how to get it from the Audio (song) by getting the parent path, but thats not the interface I want to use, I do not wish to probe every song when I probably don't need to. I only want to work at album level. Is that still possible? public Task<MetadataResult<Audio>> GetMetadata(ItemInfo info, LibraryOptions libraryOptions, IDirectoryService directoryService, CancellationToken cancellationToken) info.Path is blank/empty. info.ContaingFolder is blank/empty. I understand this decision was probably made to drop duplicate iformation from the database, but you are able to get the base path somehow when you select an album to delete it. So I am currently trying to get the delete paths, so that I can thus apply some logic and determine the basepath from that. var pathx = libraryManager.GetItemById(info.Id); List<FileSystemMetadata> dpths = pathx.GetDeletePaths(false); However when I try to use GetDeletePaths I keep getting GenericList Exceptions - Method Not Found *** Error Report *** Version: 4.8.0.78 Command line: C:\Users\mike\AppData\Roaming\Emby-Server\system\EmbyServer.dll -noautorunwebapp Operating system: Microsoft Windows 6.2.9200 Framework: .NET 6.0.26 OS/Process: x64/x64 Runtime: C:/Users/mike/AppData/Roaming/Emby-Server/system/System.Private.CoreLib.dll Processor count: 4 Data path: C:\Users\mike\AppData\Roaming\Emby-Server\programdata Application path: C:\Users\mike\AppData\Roaming\Emby-Server\system System.MissingMethodException: System.MissingMethodException: Method not found: 'System.Collections.Generic.List`1<MediaBrowser.Model.IO.FileSystemMetadata> MediaBrowser.Controller.Entities.BaseItem.GetDeletePaths(Boolean)'. at LocalAlbumCoverImporter.LocalAlbumCoverImporter.GetMetadata(ItemInfo info, LibraryOptions libraryOptions, IDirectoryService directoryService, CancellationToken cancellationToken) at Emby.Providers.Manager.MetadataService`2.RefreshWithProviders(MetadataResult`1 metadata, TIdType id, MetadataRefreshMode metadataRefreshMode, Boolean replaceAllMetadata, MetadataRefreshOptions options, BaseItem[] collectionFolders, LibraryOptions libraryOptions, List`1 providers, ItemImageProvider imageService, CancellationToken cancellationToken) Source: LocalAlbumCoverImporter TargetSite: System.Threading.Tasks.Task`1[MediaBrowser.Controller.Providers.MetadataResult`1[MediaBrowser.Controller.Entities.Audio.MusicAlbum]] GetMetadata(MediaBrowser.Controller.Providers.ItemInfo, MediaBrowser.Model.Configuration.LibraryOptions, MediaBrowser.Controller.Providers.IDirectoryService, System.Threading.CancellationToken) Please tell me there is a simpler way to do this? i.e, to get the albums basepath from this Interface? Link to comment Share on other sites More sharing options...
Luke 37133 Posted February 6 Share Posted February 6 Quote Version: 4.8.0.78 You should update to 4.8.0.80 or higher and use the new stable release nuget package. Link to comment Share on other sites More sharing options...
Luke 37133 Posted February 6 Share Posted February 6 To answer the original question, albums are virtual items, so officially, there is no way. You can infer the album path by looking at the media path, and take the parent folder from that. Granted this is a huge assumption, but fine for a personal plugin. Link to comment Share on other sites More sharing options...
mickle026 401 Posted February 6 Author Share Posted February 6 40 minutes ago, Luke said: To answer the original question, albums are virtual items, so officially, there is no way. You can infer the album path by looking at the media path, and take the parent folder from that. Granted this is a huge assumption, but fine for a personal plugin. Thats what I thought. But the question is how to look at the media path from within this interface? - as trying to probe the children also throws an error, i am going to assume that it'll probably be due to the directory sevice for a virtual item and therefore being not applicable. So then how do I get the child media items of the virtual album from within this interface? var pathx = libraryManager.GetItemById(info.Id); var children = pathx.GetFileSystemChildren(directoryService); The error *** Error Report *** Version: 4.9.0.0 Command line: C:\Users\mike\AppData\Roaming\Emby-Server\system\EmbyServer.dll Operating system: Microsoft Windows 6.2.9200 Framework: .NET 6.0.26 OS/Process: x64/x64 Runtime: C:/Users/mike/AppData/Roaming/Emby-Server/system/System.Private.CoreLib.dll Processor count: 4 Data path: C:\Users\mike\AppData\Roaming\Emby-Server\programdata Application path: C:\Users\mike\AppData\Roaming\Emby-Server\system System.ArgumentNullException: System.ArgumentNullException: Value cannot be null. (Parameter 'key') at System.ThrowHelper.ThrowArgumentNullException(String name) at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) at MediaBrowser.Controller.Providers.DirectoryService.GetFileSystemEntries(String path) at MediaBrowser.Controller.Entities.BaseItem.GetFileSystemChildren(IDirectoryService directoryService) at LocalAlbumCoverImporter.LocalAlbumCoverImporter.GetMetadata(ItemInfo info, LibraryOptions libraryOptions, IDirectoryService directoryService, CancellationToken cancellationToken) at Emby.Providers.Manager.MetadataService`2.RefreshWithProviders(MetadataResult`1 metadata, TIdType id, MetadataRefreshMode metadataRefreshMode, Boolean replaceAllMetadata, MetadataRefreshOptions options, BaseItem[] collectionFolders, LibraryOptions libraryOptions, List`1 providers, ItemImageProvider imageService, CancellationToken cancellationToken) Source: System.Collections.Concurrent TargetSite: Void ThrowArgumentNullException(System.String) SO if I try to get media sources I virtually get the same error , it just says path cannot be null (so there cannot be any data to retrieve here!) var children = pathx.GetMediaSources(false, false, libraryOptions); The error *** Error Report *** Version: 4.9.0.0 Command line: C:\Users\mike\AppData\Roaming\Emby-Server\system\EmbyServer.dll Operating system: Microsoft Windows 6.2.9200 Framework: .NET 6.0.26 OS/Process: x64/x64 Runtime: C:/Users/mike/AppData/Roaming/Emby-Server/system/System.Private.CoreLib.dll Processor count: 4 Data path: C:\Users\mike\AppData\Roaming\Emby-Server\programdata Application path: C:\Users\mike\AppData\Roaming\Emby-Server\system System.ArgumentNullException: System.ArgumentNullException: Value cannot be null. (Parameter 'path') at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options) at System.IO.Directory.GetFiles(String path, String searchPattern, EnumerationOptions enumerationOptions) at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption) at LocalAlbumCoverImporter.LocalAlbumCoverImporter.<>c__DisplayClass16_0.<GetFiles>b__0(String filter) at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToArray() at LocalAlbumCoverImporter.LocalAlbumCoverImporter.GetFiles(String sourceFolder, String filters, SearchOption searchOption) at LocalAlbumCoverImporter.LocalAlbumCoverImporter.GetMetadata(ItemInfo info, LibraryOptions libraryOptions, IDirectoryService directoryService, CancellationToken cancellationToken) at Emby.Providers.Manager.MetadataService`2.RefreshWithProviders(MetadataResult`1 metadata, TIdType id, MetadataRefreshMode metadataRefreshMode, Boolean replaceAllMetadata, MetadataRefreshOptions options, BaseItem[] collectionFolders, LibraryOptions libraryOptions, List`1 providers, ItemImageProvider imageService, CancellationToken cancellationToken) Source: System.Private.CoreLib TargetSite: System.Collections.Generic.IEnumerable`1[System.String] InternalEnumeratePaths(System.String, System.String, System.IO.SearchTarget, System.IO.EnumerationOptions) can you give me an example of how to do this ?? Quote You can infer the album path by looking at the media path, and take the parent folder from that. Or is the only way to do this by using the song <Audio> Interface? public Task<MetadataResult<Audio>> GetMetadata(ItemInfo info, LibraryOptions libraryOptions, IDirectoryService directoryService, CancellationToken cancellationToken) { var pSongID = libraryManager.GetItemById(info.Id); var pAlbumID = libraryManager.GetItemById(info.Id).ParentId; var pAlbumName = libraryManager.GetItemById(info.Id).Parent.Name; var pathx = pSongID.Parent.Path; From the song Track interface it works just fine But it repeats for every track scanned. Some of my "Home made Albums" have 100's of tracks, this means that I would do the same task 100's of unneccessary times, and probably many thousands of times in the whole library. Is there really only a way to get the parent from the child, but not the children from the parent? - I can see this becoming an issue as now plugin dev is gaining pace. Link to comment Share on other sites More sharing options...
Luke 37133 Posted February 6 Share Posted February 6 As I said officially there is no way, so I wouldn't suggest doing any of that. More data would have to be added to the ItemInfo class. Link to comment Share on other sites More sharing options...
ebr 14939 Posted February 7 Share Posted February 7 The bottom line is there is no such thing as an "Album path" because there is no requirement for the songs of an album to exist in any specific place. Link to comment Share on other sites More sharing options...
mickle026 401 Posted February 7 Author Share Posted February 7 (edited) 35 minutes ago, ebr said: The bottom line is there is no such thing as an "Album path" because there is no requirement for the songs of an album to exist in any specific place. That'll be why I'm always having issues with emby detecting all of my album covers even though they conform to the emby file naming convention. On the particular machine I want it for, which is not very quick but fine for playing music, a full library scan takes over a month. so a fix for me would be removing the library, full scan, put the library back, do a full scan and see if it fixes the dB. That will takes approximately 2 months. However as I understand what is being said. When loading albums, the album name is shown, the album cover is show and all the tracks, so when you fetch MusicAlbum you are able to get the tracks and thus from that you will be able to get the paths of the tracks. I am asking over and over how you get the album children from the music album. But, it appears I might be asking the wrong question or making invalid assumptions, because all answers are you can't do this, you can't get the album path. So your saying I can't get a music track path either from this interface? I don't just want to fix my album covers from this interface, I want to add album artist data and images from a local file. Edited February 7 by mickle026 Link to comment Share on other sites More sharing options...
ebr 14939 Posted February 7 Share Posted February 7 42 minutes ago, mickle026 said: I am asking over and over how you get the album children from the music album. But, it appears I might be asking the wrong question or making invalid assumptions, because all answers are you can't do this, you can't get the album path. What does the album "path" (which doesn't really exist) have to do with the album children? Album children are easily obtained through the normal queries. Link to comment Share on other sites More sharing options...
mickle026 401 Posted February 7 Author Share Posted February 7 I love this forum, you never actually get the answer you ask for .. you just either get no or vague answers that really dont help and still have to go and work it out for yourself. 6 minutes ago, ebr said: What does the album "path" (which doesn't really exist) have to do with the album children? Album children are easily obtained through the normal queries. 3rd post in this thread - from Luke Quote You can infer the album path by looking at the media path As all of my music files are under the ablum path I cannot even fathom why im asking if I can find out how to get the children (media files) and thus their path from this interface? Or at the media files not the children? My Setup: /Album Name/ /Album Name/My Mp3 File.mp3 or /Album Name/ /Album Name/CD1 /Album Name/CD1/My Mp3 File.mp3 get a child path, loose the child file name (and in some cases the cd folder) - et voila the album path! Quote Album children are easily obtained through the normal queries. What normal queries? when I only have the Album Virtual Name and the Id of that? The virtual Album must be linked somehow to the music files...... - an example would be nice? - as above getfilesystemchildren and getmediasources are unavaileable from here because there is no album path. Im sorry for being sarcastic, but i am going round in circles here asking how to do this from the information I have and being told no you can't get the Album path _ I already understood that - that was the reason for the posting in the fist place!. I still haven't been actually told I cant get the children from here or an explanation why or infact if I can and and explanation how? Link to comment Share on other sites More sharing options...
Luke 37133 Posted February 10 Share Posted February 10 The intention behind the metadata providers is that they are built to be a generalized search that could be used for mulitple purposes, with metadata downloading for library items being just one of them. That's why the incoming search objects don't contain any info that pointing back to the original item. It's more generalized like name, year, provider ids, etc. Link to comment Share on other sites More sharing options...
Luke 37133 Posted February 10 Share Posted February 10 Quote I love this forum, you never actually get the answer you ask for I already answered it clearly. I said there was no official way, but you just didn't like the answer. I understand you want to achieve your objective, and therefore you're going to do whatever you need to do to make that happen, but I did give you an answer. Link to comment Share on other sites More sharing options...
mickle026 401 Posted February 11 Author Share Posted February 11 On 07/02/2024 at 18:18, mickle026 said: I love this forum, you never actually get the answer you ask for Did I get the answer for the question that I asked? - In My opinion - NO I asked is there any way to get the Album path from this MusicAlbum interface....I got a "so officially, there is no way." , That is not exactly what I asked, I asked is there any way... I thought I asked clearly too. So you also included "You can infer the album path by looking at the media path" - meaning you inferred well yes the probably is a way... So I thought I then asked how to do this, and I thought I was clear with that too. This question was not answered at all. 5 hours ago, Luke said: but you just didn't like the answer So even though your answer was clear and I already knew that answer even before posting, so you are right I did not like the answer because it didn't answer the question I actually asked. The actual answer is YES you can, using the info.Id and probing librarymanager for the Song Tracks. Simple too, it wouldn't have been too hard to write this. I will put the solution incase anyone else is looking for it. var Tracklist = libraryManager.GetItemIds(new InternalItemsQuery { AlbumIds = new[] { info.Id } }); From the Tracklist you can get any of the tracks.path then you can infer the album path from that, and even better for me I can then find my data files. Just use the first track (use some error trap if there is no tracks) var pTrack = libraryManager.GetItemById(Tracklist[0]); var TrackPath = pTrack.Path; or for all of them foreach (var Track in Tracklist) { var pTrack = libraryManager.GetItemById(Track); var TrackPath = pTrack.Path; } So any of these gives the tracks path, the album path can easily be found from that 11.Feb.2024 - 03.36.54 [NewDetection] ---------------------------------------------- 11.Feb.2024 - 03.36.54 [info.Name(Album)] NOW Glam Pop 70s 11.Feb.2024 - 03.36.54 [info.Id(TrackID)] 3214185 11.Feb.2024 - 03.36.54 [TrackListCount] 80 11.Feb.2024 - 03.36.54 [TrackName] Killer Queen 11.Feb.2024 - 03.36.54 [TrackPath] \\Music\Now Music\VA - NOW Glam Pop 70s (4CD) (2021)\CD 1\01 - Killer Queen.mp3 11.Feb.2024 - 03.36.54 [Artist] Queen 11.Feb.2024 - 03.36.55 [TrackName] Cum on Feel the Noize 11.Feb.2024 - 03.36.55 [TrackPath] \\\Music\Now Music\VA - NOW Glam Pop 70s (4CD) (2021)\CD 1\02 - Cum on Feel the Noize.mp3 I feel like my question was not answered and you feel like you did answer, Lets call this a misunderstanding, I didn't intend to offend, so I am sorry if I did. Link to comment Share on other sites More sharing options...
Luke 37133 Posted February 11 Share Posted February 11 Quote I asked is there any way to get the Album path from this MusicAlbum interface....I got a "so officially, there is no way." , Sorry, I thought this was about a metadata provider. Actually you're in luck. You don't need any queries. The album has a GetMediaContainingFolderPath method. Link to comment Share on other sites More sharing options...
mickle026 401 Posted February 12 Author Share Posted February 12 Thank You , That answers the original question and works just fine, very helpful - thank you var mAlbum = libraryManager.GetItemById(info.Id); string AlbumMediaFolder = mAlbum.GetMediaContainingFolderPath(libraryOptions); . 12.Feb.2024 - 05.06.24 [NewDetection] ---------------------------------------------- 12.Feb.2024 - 05.06.24 [info.Name(Album)] NOW Glam Pop 70s 12.Feb.2024 - 05.06.24 [info.Id(TrackID)] 3214185 12.Feb.2024 - 05.06.24 [AlbumMediaFolder] \\Music\Now Music\VA - NOW Glam Pop 70s (4CD) (2021) metadata provider - it works just fine there too. public Task<MetadataResult<MusicAlbum>> GetMetadata(ItemInfo info, LibraryOptions libraryOptions, IDirectoryService directoryService, CancellationToken cancellationToken) { var thisAlbum = libraryManager.GetItemById(info.Id); string AlbumMediaFolder = thisAlbum.GetMediaContainingFolderPath(libraryOptions); var result = new MetadataResult<MusicAlbum>(); result.HasMetadata = false; result.Item = new MusicAlbum(); // rest of code // // if metadata or images found set the HasMetadata to true return Task.FromResult(result); } Thank You 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now