Kodi Community Forum

Full Version: Using a human friendly folder structure and multiple music sources
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Kodi v18 supports users having a more human friendly folder structure for their music files.  This thread presents what the benefits of that are - why you may want to make use of it , and suggestions for moving to it - how to use it.

But let's be clear from the start, changing music folder layout is not compulsory.  If you have a modest or simple music library and are happy with what you have then it is fine to stay as you are.

If you have hit issues with local artist art e.g. have albums where artists collaborate (multiple album artists), want art or NFO for guest artists or other musicians etc. or just don't want images and NFO files mixed in with your media files, then you want to make use of having an Artist Information Folder (AIF) see https://kodi.wiki/view/Artist_information_folder. This is a new feature in v18, and a more flexible and robust way to handle artist art etc. so I encourage users to consider switching to it,  but you can still leave the music files themselves in whatever folder layout you used for previous versions.

However if you would like to reorganise your music files in a more human friendly way than a strict artist/album structure, and be able to browse and filter the library based on that arrangement then read on.

If you are a beginner wondering how best to organise things before using Kodi for the first time, then group your albums under folders in a manner that makes sense to you, and put artist art in correctly named folders an AIF.  Reading https://kodi.wiki/view/Music_tagging is the place to start, but you may find what is said here about filtering using multiple music sources interesting

History and limitations of Previous Versions
Kodi could always make a library from properly tagged music files regardless of how they were arranged, even if they were all in one flat folder, but support for local art and NFO for both artists and albums depended on a precise artist/album folder structure. Names of folders and files did not matter at all, but the files for an album need to be gathered in a unique folder, and all the albums by an album artist and only that album artist had to be under a unique folder. This led to users having an artist/album folder layout for their music files, and frequently just one music source being added (the top of that folder layout).

Having a folder for each album is an easy and obvious thing to do, with possibility for sub-folders for each disc should they have different disc art. But there are numerous situations where that exacting artist folder arrangement is impossible, as anyone with classical music (where the album artists are composer, conductor and orchestra) or other collaborative albums will know. Also users with larger music libraries and thousands of album artists often want to split them by other criteria e.g. genre, or perhaps put their kid's or spouse's music separately from their own, and artists may figure in more than one category. Arranging albums by album artist is not always the optimum human friendly way.

The other limitation of Kodi before v18 is that only album artists can have local art and NFO files. Artists that don't have albums but just appear as featured guest artists on songs on albums by others, or on various artist compilations, or those that contribute to the music in other ways e.g. producer, composer, lyricist, or musicians etc., they can not have local art or NFO to provide information. Some art addons would create additional folders for these artists mixed into the artist/album layout, that could result in hundreds of extra folders that didn't have music in them.

Why Change To A Different Music Folder Structure
The big reason to change your music folder structure is to be able to easily filter artists, albums and songs based on some user devised way of categorising your music.

This is best explained by an example, my own real life use. I have a music library of 2000 albums the majority popular music of some kind or other but 200 albums of classical music, 75 of classical/spanish/folk guitar,  50 soundtracks and film music, 80 Jazz (I rarely am in the mood to listen to) and a few albums that I ripped and probably will never listen to again but since I ripped them they may as well be in my library as long as they don't get in the way.  For my sanity music from each of these categories is under a separate folder e.g. "Popular", "Classical", "Guitar", "Soundtrack", "Jazz" and "Junk", often (but not always) with the albums in folders beneath some kind of artist folder.

Before v18 I only added the popular music to my music library, because I could not stand the mess of having classical composers, conductors and orchestras, jazz musicians and pop artists all jumbled together in the artists node. I could fix some by filtering by genre, but there were lots of crossover artists in more than one category. There were also numerous collaboration albums which made local artist art impossible too.

In v18 I have added each of these 6 category folders as a separate music source. I can now start my browsing from the Sources node, pick a source and just see that artists on the music in that category, or the albums or songs etc. I can also use this filtering  in both smart playlist rules and in the sideblade filter option. Click here for explanatory images

Filtering by source is even better when using Yatse on a phone or tablet to control my music playback (which I often do since I listen with TV off). It supports common filtering by source across all music library views  - artists, albums, songs, genres and even the overview screen. I pick a source, usually "Popular", and all the other music is nicely hidden until I want to see it. And of course if I ever want to see everything then I can.

Simply making a folder moving the music files into folders beneath that and then adding it as a music source is a more user friendly way to adjust the way music is categorised at the highest level than changing music file tags or editing NFO files. My wife and I share similar music tastes and there are no kids at home, but I'm sure many of you have other people using Kodi with you and different music tastes. This gives you an easy way to split that up too, and still be able to search and see the entire library easily as well.

How to change to a different folder structure
1. Export Song Playback History
Assuming that you have at least some of your music in the library and want to keep playcounts, user ratings and last played date then you want to export this data.
  1. From Settings>Media>Library scroll down to the music library section
  2. Click on Export Library,
  3. Choose kind of export: "Single file"
  4. Select the Destination folder of your choice: (A single file will be created in the form of kodimusicdbYYYY_MM_DD.xml)
  5. Items to export: "Songs"
Making a note of the actual output filename, there is nothing in the name to indicate that is contains song history data.

For more information see: Music#Single_File (wiki)

2. Export existing additional album information and art
Assuming that you have scraped additional album information and art then capture that data to avoid repeating the requests to remote servers etc. to get it again and of course loss of any manual art selection you may have made.  Also since you will be moving files and folders local album art may also end up in a different place,  Kodi will automatically pick this up from the album folder when the library is repopulated.
  1. From Settings>Media>Library scroll down to the music library section
  2. Choose kind of export: "To library folders"
  3. Items to export: "Albums"
  4. Output information to NFO  files: enabled
  5. Include artwork such as fanart and thumbnails: enabled
  6. Overwrite existing files: disabled
Export creates image files at the resolution Kodi uses and caches them. If you have higher resolution local album art then you will need to take care that overwrite is disabled avoid export overwriting it.

This step will create album.nfo files and art in the current album folders, ready for Kodi to pick-up automatically when the library is repopulated once the music files are moved. However those users wanting to avoid creating album.nfo files, and already having album art as separate files can use export to single file instead as described in the previous step by adding to the setting Items to export. The resulting xml file of album data can be imported later.

For more information see: Music#To_library_folders (wiki)

3. Export existing additional artist information and art
Since you will probably no longer have all the music by and artist and only that artist under a unique artist folder, you will need to start using the  Artist Information Folder approach to local artist art and nfo files. You could manually move existing local artist art and NFO files into correct folders in the AIF, but it is simpler to let export do this for you. Also, as with albums you want to capture any information or art previously scraped from remote sources.

Nominate a folder to be your AIF under Settings>Media>Music see https://kodi.wiki/view/Settings/Media/Music#Library. This can be located anywhere, including with the music files, but since you may have music by an artist in several locations and the AIF is sensitive to artist folder names (while the rest of Kodi is not)  it is better if it is a separate location to the music files.
  1. On Export Library dialog enter
  2. Choose kind of export: "To library folders"
  3. Items to export: "Album Artists"
  4. Output information to NFO  files: enabled
  5. Include artwork such as fanart and thumbnails: enabled
  6. Overwrite existing files: disabled
This will create a folder in the AIF for every album artist that has additional information or art, and artist.nfo and images files within each folder.
Again export creates image files at the resolution Kodi uses and caches them. If you have higher resolution local artist currently located in the artist/album folder structure art then you will need to manually move this to the correct artist folder in the AIF.

The steps in this section and the previous section can of course be combined by selecting items to export of "Album Artists, Albums", but I know that some of you will want to be monitoring the outcome of each step. If you have set art for song artists (manually, via JSON or using an artwork  addon) then this can be captured too by selecting items to export of "Song Artists".

For more information see: Music#To_library_folders (wiki)

4. Drop the music source(s) and deep clean the library
Data captured, time to clean out the music library. Although there are some manual tricks you can use when you move music files, the kind of file/folder reorganisation you are doing it is best to simply wipe the library, move the files, and then repopulate it scanning tags and scraping from NFO files. It may take some time, but it is worth it.
  1. From file view select the music source, and on the context menu click on "Remove source". When asked if you want to remove all items within this path say yes. Repeat for all music sources that you are effecting by moving files.
  2. Clean the music library, removing any orphaned entries, from Settings>Media>Library, take care to scroll down the screen to the music library section before clicking on "Clean Library".
  3. Close Kodi
At this point you may also want to use the texturecache utility to clean up your textures db and thumbnail cache as well.  Rebuilding your library may result in cache bloat for the moved art, which those that like to keep a tidy system (or have limited storage) will want to manage.

For more information see: Update_Music_Library#Remove_Source (wiki)

5. Move your music files
Rearrange your album folders into a layout that makes sense to you.

6). Rebuild your music library
  1. Start Kodi and in Settings>Media>Music enable "Fetch additional information during updates" which will ensure the album and artist nfo files are read.
  2. Add new music sources for your newly partitioned music folders and each time  say "yes" to scanning into library
This will scan the tags, remaking the music library entries and then scrape the NFO files for additional artist and album information.

7. Import Song Playback History
Finally restore the original song user ratings, playcount and last played date by importing the xml file created in step 1. From Settings>Media>Library scroll down to the music library section and click on Import Library, then select the xml file.

Opps I Nuked My Library!!
Well doing major moves like this it is a risk. Make backup copies of your userdata files especially MyMusic72.db, and take care with precious art or NFO files. I promise that Kodi will not overwrite art or NFO files unless you tell it to do so, and if will never change your music files, but users can make mistakes.
(2019-07-12, 10:50)black_eagle Wrote: [ -> ]Is there a 'best practice' method for moving from an artist/album structure to something better ?  I'd like to take advantage of all the work you have put in and split my music up differently in the future but the original library db was built probably with V15 and has only been upgraded through Kodi upgrades.  Everything is tagged with Picard and already has existing art and nfo files alongside the album tracks. Feel free to spin this off into a new thread if you feel it warrants it, or just point me to a link where you may have gone through all this before Big Grin

Well here you are @black_eagle as promised.

This content may get edited or eventually moved into a separate guide, but questions and feedback from users is welcome on this thread. If someone would like to test out the procedure  that would be great too.
A HUGE thanks Dave !! I'm following your guide and currently in the middle of exporting all the albums into one file.  I see no point in exporting art I already have.  Oh, the joy of flexibility !!!
Yes, also why I gave album and artist steps separately, you can choose to skip album art or NFO if you already have them.

It maybe too late, but in this case you probably want to leave "Fetch additional info on update" disabled. Then scan tags but not scrape, so you can import the album xml export, and then use "query info for all" on the context menu of the artists node to scrape just the artist.nfo

I'll be interested how you get on.
UPDATE

Well, that all went rather well !!  Ended up with a little bit of missing art but nothing that I couldn't sort out within a few minutes.

I think I will probably end up doing this a few more times as more possibilities are opening up to me regarding placement of files and filtering of them.  At least, I hope I will be able to achieve what I'm after, but I might do need some help with a bit of it.  It's easy enough to write a filter to just give me for instance, 'Stage Musicals' by using a path, but, these appear in the category area and I'd quite like want to be able to put them somewhere else if possible.  To explain - With Estuary, the categories are displayed across the top, with 'Recently played albums' below and 'Recently added albums' below that, etc etc.  Re-naming those (or even adding more) is easy enough, and I guess I could achieve what I'm after by creating smartplaylists based around path rules and using those or can I do something like 'library://music/musicals/stage_musicals/' or 'musicdb://source=nfs://server/blah/blah/path/to/files' which is more "node like", but in spite of using the library node editor I totally failed at actually getting the node to work with the path I wanted !! (I was trying to create a folder type node). The handwritten filter however, worked immediately.

xml:
<?xml version='1.0' encoding='UTF-8'?>
<node order="50" type="filter">
    <label>Stage Musicals</label>
    <content>albums</content>
    <order direction="descending">year</order>
    <rule field="path" operator="contains">
        <value>nfs://192.168.1.50/media/sde1/Musicals/StageMusicals/</value>
    </rule>
</node>

I guess what I'm after ultimately, is a row of thumbs depicting various different categories through which I can drill down to the content I want.  EG Musicals takes you to two thumbs of Screen Musicals and Stage Musicals.  Stage musicals takes you to albums like Phantom of the Opera, Cats, Starlight Express etc etc, Screen musicals to Jesus Christ Superstar, Cabaret, Grease etc.  If I have to do it with smartplaylists, then that's fine but if there is a better way, then I'd like to pursue it.
Glad that things went well @black_eagle, even better that you are being inspired by possibilities  Smile

The row of things at the top of the Estuary main screen that you are calling "categories"  (maybe because the wiki recent did?) have been called "nodes" for a much longer time, so I'm going to encourage use of that term.  Estuary then uses smartplaylists to show the other rows of artists or albums etc.  Messing with skins is above my pay grade, but I'm sure you can customise the skin to show what you want.

The library node editor is an addon, and so probably has not been updated to cover the new music nodes/filters that are possible with v18. This needs an addon person to look at it, meanwhile editing the xsp files is just so easy (I know not for those on a device without a keyboard!!).
 
Quote:I guess what I'm after ultimately, is a row of thumbs depicting various different categories through which I can drill down to the content I want. 
There is now a (folder type) default node called "sources", that I think shows what you want without using a smartplaylist at all.
sources.xml
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<node order="135" type="folder">
    <label>39031</label>
    <icon>DefaultMusicSources.png</icon>
    <path>musicdb://sources</path>
</node>
This does get installed by default in v18, but if you have your own menus/nodes defined  (in userdata/library/music) you may not have seen it. In that case have a look under system/library/music for it and copy into userdata/library/music.

Have a look at that node, then come back if you have more questions.
@HomerJau I have split your question into a thread of its own because it is more an AIF and artist at question than about using human friendly folder layouts (although I get that this is stopping you doing the other)
A-ha !!!  I was indeed missing that, since I already had some custom nodes defined from ages ago.  It almost does what I want.....  Is there a way to get it show albums in a source, rather than artist -> album ?  EG, navigating that way, I get artists such as Hans Zimmer.  Now I know that he wrote the score for The Lion King, along with Elton John, but if my wife were looking for that album, she wouldn't know that.  In that case, seeing the actual albums in the source, rather than the artists is a better way (for us) to navigate it.
I don't think there is a way to skip levels on sources>artists>albums>songs or on genres>artists>albums>songs navigation come to that, but maybe I have just forgotten something. But it is just one more click to see the albums on a source - click on "all  artists" item.
@DaveBlake Looking at the Years node it uses Group

xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<node order="60" type="filter" visible="Library.HasContent(Music)">
<label>652</label>
<icon>DefaultMusicYears.png</icon>
<content>albums</content>
<group>years</group>
</node>

Doesn't this allow it to skip an artists level? so it returns only albums but grouped by years, so the group gives 1st level of Years then when you enter each it gives the Albums.

Could it be feasible to add more options for Group (since when I look at smartplaylists only Default & Years are options for Group by) such as sources, genres to make something like the following possible:

xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<node order="60" type="filter" visible="Library.HasContent(Music)">
<label>sources</label>
<icon>DefaultMusicYears.png</icon>
<content>albums</content>
<group>sources</group>
</node>

or

xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<node order="60" type="filter" visible="Library.HasContent(Music)">
<label>genres</label>
<icon>DefaultMusicYears.png</icon>
<content>albums</content>
<group>genres</group>
</node>
Maybe it's just me, but if Kodi is moving to a more 'human friendly' way of storing the music so that people can categorise and sort their collections in a much less rigid way than artist/album, then surely, being able to browse it in a similar way is more logical for the end user than still using artist/album when doing so ?

I realise that Dave is probably no where near finished with this but it just makes more sense to me that if I have sources of say, 'Classical', 'Musicals', 'Classic Rock', 'whatever', that I have the option of either viewing by artist or album or composer or whatever other tags are available to use.  At the moment, if I navigate my HDD and open Musicals, I get presented with two directories and opening either of them leads directly to the albums because of the AIF.  The disk is cleaner and better laid out (in my head ayway) and I don't have to scroll through 100 different artists to navigate to an album.  It's immensly more flexible in the way that I can sort stuff and lay it out on HDD, just maybe a little less flexible in Kodi currently.

Note - I'm still on V18 so no access to any recent changes there may have been and aware that any improvements are highly unlikely to be back-ported so it might just be that this is simply not achievable for me at the moment.
@black_eagle I'm all for more flexible ways of browsing your music collection, but the fundamentals of Kodi GUI navigation are hard things to change. I'm a database guy so I start at that end of things, because that has to be inplace before anything else can work.  I will also admit my motivation for tackling the GUI navigation end of things has dropped since I found out that Yatse already does most of what I personally want anyway. But that doesn't mean I won't look at it.

It is kind of ironic that my work so far has left you prefering file view mode (with your new music folder layout). That was not the plan!! What you ask for here - a means to navigate sources directly to albums - is very reasonable but as a new feature would not be backportable to a point release (not my rules BTW). Is the extra click on "*all artists" too bad a step in the meantime? You are seeing that item, right?

The historic differences between filter and folder nodes, when <group> works and how it works are messy @jjd-uk. As a means for the user to specify what they want the nodes to do your suggestions are good, but there is more internal work needed to get that facility to work.
(2019-07-17, 12:52)DaveBlake Wrote: [ -> ]The historic differences between filter and folder nodes, when <group> works and how it works are messy @jjd-uk. As a means for the user to specify what they want the nodes to do your suggestions are good, but there is more internal work needed to get that facility to work.

Yep I know more internal work would be required to do what I suggested, all I was wondering was first of all would it be feasible to use Group to offer more flexibility in this way as it's purpose seems to be to allow a layer of filtering to be displayed between the node and the content, and if it was feasible so how complex it would be. I did do some searching which led me to https://github.com/xbmc/xbmc/blob/master...rouped.cpp however from your answer I guess that it's not as easy as adding some lines that file.
(2019-07-17, 12:52)DaveBlake Wrote: [ -> ]@black_eagle I'm all for more flexible ways of browsing your music collection, but the fundamentals of Kodi GUI navigation are hard things to change. I'm a database guy so I start at that end of things, because that has to be inplace before anything else can work.  I will also admit my motivation for tackling the GUI navigation end of things has dropped since I found out that Yatse already does most of what I personally want anyway. But that doesn't mean I won't look at it.

It is kind of ironic that my work so far has left you prefering file view mode (with your new music folder layout). That was not the plan!! What you ask for here - a means to navigate sources directly to albums - is very reasonable but as a new feature would not be backportable to a point release (not my rules BTW). Is the extra click on "*all artists" too bad a step in the meantime? You are seeing that item, right?

 I did have that setting turned off, but have now re-enabled it.

I'm not preferring file view mode. That, in my view, totally negates the entire point of the library, although I will concede that I did briefly consider going in that direction to achieve my intended result.

It's not too bad with the extra step, it's just the explaining I will be doing about why. I had to do plenty of that when I took the music library off-line and the wife couldn't play any music while I was moving things, but I managed to placate her with statements like "The music will be better organised" and "it'll be easier to find the stuff you want to". It is much easier to do that, I just know what's coming, down the line Big Grin "Why do I have to pick that everytime, can't you just make it show the albums ?"  Hence my original question Smile
Wanting to navigate sources directly to albums  is very reasonable, shame I didn't think about that when I implemented it! I will look at making that improvement (and sort out the whole group by thing that jjd has brought up if I can).

Meanwhile the only way around explaining to the wife I can think of is for you to make a set of filter type custom nodes of  "albums" each with a "source is X" rule, and put them under a separate menu. It is not slick, and tedious if you have a lot of sources now or will be adding news ones frequently, but it is a way to avoid that extra step at artists level.

Example for one of my music sources: ClassicalSourceAlbums.xml
Code:
<?xml version='1.0' encoding='UTF-8'?>
<node order="1" type="filter" visible="Library.HasContent(Music)">
    <label>Classical Albums</label>
    <icon>ClassicalAlbums.png</icon>
    <content>albums</content>
    <rule field="source" operator="is">
        <value>Classical Music</value>
    </rule>
</node>
Pages: 1 2