ShowAllNodes add nodes

To discuss development of addons / skins / customization of MediaMonkey.

Moderators: jiri, drakinite, Addon Administrators

morrigan777
Posts: 6
Joined: Tue Aug 26, 2014 9:43 am

ShowAllNodes add nodes

Post by morrigan777 »

i installed ShowAllNodes, but i would like also non-default fields, like custom.
Also i would like fields like director only show the directors not all person fields.

I have looked to find instructions or help on how to edit the ShowAllNodes .
But i have not found it.

is it possible?
is there documentation or info?
Peke
Posts: 17446
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Re: ShowAllNodes add nodes

Post by Peke »

Hi,
as of past few versions ShowAllNodes is integrated in MM5 under tree ⋮ menu.

If you installed Debug version you can inspect each element and change it.

Currently there is no complete documentation published online I would suggest to ask here and look here.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
TIV73
Posts: 229
Joined: Sat Nov 12, 2011 1:31 pm

Re: ShowAllNodes add nodes

Post by TIV73 »

Hey morrigan,
I recently wanted to do something similar a while ago, so I wrote a quick extension for it. It's not exactly the same thing that you want to do, but it might give you some hints.

The extension checks for the existence of a collection called NewColl, and if found, modifies its albums node to list all albums in the format '([Album track count]) [Album name]'. To use it, create a new addon, create a viewHandlers_add.js file and add the code below:

Code: Select all

var albumCountDic = {}

nodeHandlers.albums.override({
    hasTreeChildren: () => {
        return true;
    },

    getChildren: function ($super, node) {
        if(node.collection.name !== 'NewColl'){
            return $super(node);
        }

        return new Promise(function (resolve, reject) {
            var coll = nodeUtils.getNodeCollection(node);

            coll.getAlbumList('known only').whenLoaded()
                .then(list => {
                    var promList = []
                    var nodeList = [];

                    list.forEach(album => {
                        nodeList.push(album);

                        promList.push(new Promise(function (resolve, reject){
                            album.getNumberOfTracks().then(function (cnt) {
                                album.NumberOfTracks = cnt

                                albumCountDic[album.id] = {
                                    id: album.id,
                                    count : cnt
                                }
                                resolve();
                            })
                        }))
                    })

                    Promise.all(promList).then(album =>{
                        nodeList.sort((a, b) => (a.NumberOfTracks < b.NumberOfTracks) ? 1 : -1)

                        nodeList.forEach(album =>{
                            node.addChild(album,'album')
                        })

                        resolve();
                    })
                })
        });
    },
});

nodeHandlers.album.override({

    title: function ($super, node) {
        if (!node.collection)
        return '';

        if(node.collection.name !== 'NewColl'){
            return $super(node);
        }

        var trackCount = albumCountDic[node.dataSource.id] ? albumCountDic[node.dataSource.id] : null

        if(trackCount){
            return '(' + trackCount.count + ') ' + node.dataSource.title ;
        }

        node.dataSource.getNumberOfTracks().then(function (cnt) {

            albumCountDic[node.dataSource.id] = {
                id: node.dataSource.id,
                count : cnt
            }
        })

        return node.dataSource.title
    },
});
Note that the track count property for an album has to be retrieved asynchronously, but the node title property seems to be resolved as string and doesn't care about promises, that's why I had to implement the rather unsavory workaround for where I preload the whole list before resolving the child node list.

You might want to avoid doing the exact same thing as it probably kills performance for bigger collections, but it works for my use case and I wasn't planning on ever releasing a proper extension for it, so I didn't really care about production quality code.

Also make sure to have a look viewHandlers.js in the mediamonkey root directory which contains all the node handlers in MediaMonkey, so you basically just either need to override an existing node, or create a new one, inherit from another node (or base) and hook it into whatever parent node you want.
Post Reply