Node Finished Executing Event or ...

Any ideas about how to improve MediaMonkey for Windows 4? Let us know!

Moderator: Gurus

raybeau528
Posts: 401
Joined: Thu Sep 27, 2007 4:19 pm
Location: Connecticut

Node Finished Executing Event or ...

Post by raybeau528 »

This request is for an event mechanism which is triggered when the current node (node in focus via script) finishes its execution and all tracks are available with SDB.AllVisibleSongList. Something like,

SDB.MainTree.CurrentNode.UseScript=Script.ScriptPath
Script.RegisterEvent SDB.MainTree.CurrentNode, "OnFinishedAdding", "mySubroutine"

The only reasonable way to accomplish this today seems to be to trigger a timer event with an aribitrary interval. This is hit and miss. A short timer interval executes quickly and may capture all tracks for a small collection but most likely won't get any/all tracks for a larger collection. Conversely, a large timer interval may catch most/all tracks of a large collection but is excessive for a small collection.

For more details and sample script demonstrating above timer method see http://www.mediamonkey.com/forum/viewto ... =2&t=35633

Thanks for considering this request!

Ray
raybeau528
Posts: 401
Joined: Thu Sep 27, 2007 4:19 pm
Location: Connecticut

Re: Node Finished Executing Event or ...

Post by raybeau528 »

Any scripters out there care to add their support for this request? !!! :)

Thanks!

Ray
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Re: Node Finished Executing Event or ...

Post by Bex »

Yes, an SDB.Application.OnFinishedAdding(Node As ISDBTreeNode) event which is fired when SDB.TracksWindow.FinishAdding is executed would be very handy.
I don't know if SDB.TracksWindow.FinishAddingEx could trigger the same event or if it needs its own.

Perhaps also a SDB.Application.OnStartAdding(Node As ISDBTreeNode) which is fired when track are being added, would be useful.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Node Finished Executing Event or ...

Post by MoDementia »

I will too

As for some of my custom nodes I have occasioanlly added the SQL (or relevant data) to 1 of the "custom" properties of the node so that I didn't have to wait for it to be populated before processing it.
But I belive these are not just your nodes so ...

Too drunk to look up the exact syntax off wiki :P
MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Node Finished Executing Event or ...

Post by MoDementia »

PS this should go in the scripts functionality thread, also too drunk to look up the link :P
raybeau528
Posts: 401
Joined: Thu Sep 27, 2007 4:19 pm
Location: Connecticut

Re: Node Finished Executing Event or ...

Post by raybeau528 »

Thanks!

Will posting this in the scripts forum get the attention of the developers?

Ray

PS Am I missing a festive occasion some where ? :)

Edit: ie too drunk to look up the link !
ZvezdanD
Posts: 3272
Joined: Thu Jun 08, 2006 7:40 pm

Re: Node Finished Executing Event or ...

Post by ZvezdanD »

raybeau528 wrote:Any scripters out there care to add their support for this request? !!! :)
I told you already in another thread that I am missing this event, and because of that I need to use some dirty tricks in my Export M3Us for Child Nodes script.
raybeau528 wrote:Script.RegisterEvent SDB.MainTree.CurrentNode, "OnFinishedAdding", "mySubroutine"
I think it should be an event for the SDBTracksWindow object, not the SDBTree. I want it for any node, not only for those created in my script. Also, there are other ways to add tracks to the tracklist, not only by the click on some node in the tree panel.
raybeau528 wrote:Will posting this in the scripts forum get the attention of the developers?
No comment. :wink: :lol:
● Magic Nodes 4.3.3 / 5.2 ● RegExp Find & Replace 4.4.9 / 5.2 ● Invert Selection/Select None 1.5.1 ● Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1 ● Expand Child Nodes/Expand All 1.1.2 ● Event Logger 2.7 ● Filtered Statistics Report 1.6 ● Track Redirection & Synchronization 3.4.2 ● Restore/Synchronize Database 3.1.8 / 4.0.1 ● Find Currently Playing Track 1.3.2 ● Queue List 1.2.1 ● Add to Library on Play 1.0.1 ● Tree Report for Child Nodes 1.1.1 ● Update Location of Files in Database 1.4.5 / 2.3 ● Inherit Child Playlists 1.0.3 ● Add Currently Playing/Selected Track(s) to Playlist 1.2
raybeau528
Posts: 401
Joined: Thu Sep 27, 2007 4:19 pm
Location: Connecticut

Re: Node Finished Executing Event or ...

Post by raybeau528 »

The more I think about this and try different workarounds the more this feels like a fundamental flaw (big bad bug), not a request for new functionality. It's no different than an I/O request to disk or network transfer. You wouldn't expect to have to put in a loop or timer event, or heaven's forbid a Sleep, and guess when the I/O is completed. That's exactly what you're forcing us to do.

Would it be too much to ask the developers to acknowledge this request (bug!) and let us know what you intend to do ?

Looking forward to a response.

Thanks!

Ray
MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Node Finished Executing Event or ...

Post by MoDementia »

The work around approach if I needed it would be;

1. Read the node caption.
2. Have a cross reference for common/std nodes and lookup a table with the SQL statement to get the same track listing
3. If it isn't in the common nodes list then check the ini for magic node name and generate the SQL from the ini
4. etc for any other script generated nodes. i.e. as users report nodes that they need access to, have a look at the script, add the relevant SQL to the common/std lookup.
ZvezdanD
Posts: 3272
Joined: Thu Jun 08, 2006 7:40 pm

Re: Node Finished Executing Event or ...

Post by ZvezdanD »

Well, I don't think this is a bug. Some kind of loop should exists somewhere, in our scripts or program itself. Actually, network functions have timeout argument which is nothing then timed loop which executes called function. There is nothing wrong with such approach, but we need to know when to stop that loop or timer - currently, it could be blind guess.

By the way, Magic Nodes are not stored in the .ini file as SQL queries. I am not using such approach even with my script Export M3u for Child Nodes. Also, there are scripts which are not adding tracks to the tracklist with AddTracksFromQuery, but with AddTrack with some unknown logic internal to the script. It could be too much work to implement such thing, it is much easier just to select needed node and to wait for tracklist to be populated.
● Magic Nodes 4.3.3 / 5.2 ● RegExp Find & Replace 4.4.9 / 5.2 ● Invert Selection/Select None 1.5.1 ● Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1 ● Expand Child Nodes/Expand All 1.1.2 ● Event Logger 2.7 ● Filtered Statistics Report 1.6 ● Track Redirection & Synchronization 3.4.2 ● Restore/Synchronize Database 3.1.8 / 4.0.1 ● Find Currently Playing Track 1.3.2 ● Queue List 1.2.1 ● Add to Library on Play 1.0.1 ● Tree Report for Child Nodes 1.1.1 ● Update Location of Files in Database 1.4.5 / 2.3 ● Inherit Child Playlists 1.0.3 ● Add Currently Playing/Selected Track(s) to Playlist 1.2
raybeau528
Posts: 401
Joined: Thu Sep 27, 2007 4:19 pm
Location: Connecticut

Re: Node Finished Executing Event or ...

Post by raybeau528 »

Yes but the loops and time outs are deterministic...that is, the loop is usually testing for some flag to be set and when it sets it exits the loop. And network timeouts are waiting for a packet or an Ack or Nack or something . And then for disk I/O at the hardware level a loop is used to check some bit of the status register like a ready bit or a TUR test unit ready. When the I/O completes, the status bit is set and the loop exits. You then know the I/O has completed the transfer and the data is available in a buffer or memory.

But with the Main Tracks Window there is NO status bit or Ack or anything that indicates that all tracks from the node are now available via an SDB.AllVisibleSongList or other method. There is no deterministic way to tell that the I/O has finished. My Event Timer method and your loop method are just a guess that hopefully the Main Tracks Window is FinishedAdding. Even if you set the timer for 5 seconds you don't know absolutely that it has finishedAdding. It's just a reasonable guess that it should be finished adding.

I would be ecstatic to hear from the developers that I am indeed wrong and there is a method. Anyone? Anyone?

Ray
MoDementia
Posts: 1321
Joined: Thu Jun 15, 2006 3:26 pm
Location: Geelong, Victoria, Australia

Re: Node Finished Executing Event or ...

Post by MoDementia »

Have a check to see if the nodes you are interested in generate a "MM.DB-journal" (same directory as MM.DB) while adding tracks

If so it is a sure way to check when it is finished (still a timer check) but a definiate end
i.e. no "MM.DB-journal" = finished adding tracks

I have code in DEISync if you want to have a look.
ZvezdanD
Posts: 3272
Joined: Thu Jun 08, 2006 7:40 pm

Re: Node Finished Executing Event or ...

Post by ZvezdanD »

raybeau528 wrote:Yes but the loops and time outs are deterministic... My Event Timer method and your loop method are just a guess that hopefully the Main Tracks Window is FinishedAdding.
Of course. This is why I wrote "we need to know when to stop that loop or timer - currently, it could be blind guess."

By the way, my script don't have a problem with nodes and tracklists which have tracks - it returns almost immediately after adding tracks. The problem are empty tracklists when it wait in a loop.
● Magic Nodes 4.3.3 / 5.2 ● RegExp Find & Replace 4.4.9 / 5.2 ● Invert Selection/Select None 1.5.1 ● Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1 ● Expand Child Nodes/Expand All 1.1.2 ● Event Logger 2.7 ● Filtered Statistics Report 1.6 ● Track Redirection & Synchronization 3.4.2 ● Restore/Synchronize Database 3.1.8 / 4.0.1 ● Find Currently Playing Track 1.3.2 ● Queue List 1.2.1 ● Add to Library on Play 1.0.1 ● Tree Report for Child Nodes 1.1.1 ● Update Location of Files in Database 1.4.5 / 2.3 ● Inherit Child Playlists 1.0.3 ● Add Currently Playing/Selected Track(s) to Playlist 1.2
ZvezdanD
Posts: 3272
Joined: Thu Jun 08, 2006 7:40 pm

Re: Node Finished Executing Event or ...

Post by ZvezdanD »

Wow! There are a whole bunch of new events added this day. More than all of them from last two years! Just take a look at Recent Changes. Unfortunately, there is still no event for OnFinishAdding. Maybe OnTrackListSelectionChanged could be used instead...

EDIT: OnTrackListSelectionChanged cannot be used in cases with empty tracklists, but I see now a new OnTrackListFilling which will be available from 3.1.0.1218.
● Magic Nodes 4.3.3 / 5.2 ● RegExp Find & Replace 4.4.9 / 5.2 ● Invert Selection/Select None 1.5.1 ● Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1 ● Expand Child Nodes/Expand All 1.1.2 ● Event Logger 2.7 ● Filtered Statistics Report 1.6 ● Track Redirection & Synchronization 3.4.2 ● Restore/Synchronize Database 3.1.8 / 4.0.1 ● Find Currently Playing Track 1.3.2 ● Queue List 1.2.1 ● Add to Library on Play 1.0.1 ● Tree Report for Child Nodes 1.1.1 ● Update Location of Files in Database 1.4.5 / 2.3 ● Inherit Child Playlists 1.0.3 ● Add Currently Playing/Selected Track(s) to Playlist 1.2
raybeau528
Posts: 401
Joined: Thu Sep 27, 2007 4:19 pm
Location: Connecticut

Re: Node Finished Executing Event or ...

Post by raybeau528 »

Modementia,

I never noticed an "MM.DB-journal" file and not sure how or why one would exist. If all Nodes generated one, then that would be a great indicator.

Ray
Post Reply