View Issue Details

IDProjectCategoryView StatusLast Update
0011097MMW v4Framework: Scripts/Extensionspublic2013-07-26 17:29
Reporterzvezdan Assigned To 
PriorityhighSeverityminorReproducibilityalways
Status assignedResolutionreopened 
Fixed in Version4.1 
Summary0011097: Strange behavior of ISDBPlaylist::CreateChildPlaylist
DescriptionHere is the description from Wiki: "Creates a new sub-playlists of this playlist with the given Title. Reference to the newly created playlist is returned.". Please note the words "NEW" and "NEWLY". Now, we have two problems.

1. If there already exists a sub-playlist with the given Title, we would get a reference to that existing playlist, but not really "to the newly created playlist" with the same name. Well, it is fine for me because I really don't understand why MM GUI allows creating of playlists with the same name inside of the same parent playlist. However, I think that we should be somehow informed if the reference is to the new sub-playlist or to the existing playlist with the same name. Also, you should modify your description accordingly, because it is now misleading.

2. If there already exists a sub-auto-playlist with the given Title, we would get a reference to that existing auto-playlist. This is really unwanted because MM API doesn't allow modifying of auto-playlists and because of that behavior we could get the issue with AddTrack method mentioned in [11092].

One solution to the first problem would be adding a new property ISDBPlaylist::ChildPlaylistExists(Title As String) As Boolean, which we could test before CreateChildPlaylist. ISDBApplication::PlaylistByTitle cannot be used for this purpose because of this another problem with the mentioned property: "If multiple playlists with the same name exist, PlaylistByTitle returns the first one it finds in the database." Now, I am using For ... Next loop with ChildPlaylists to test if such playlist already exists, but it would be much cleaner if you add the suggested ChildPlaylistExists property for that.

Alternatively, or maybe even better, you could add one new property similar to PlaylistByTitle, but with one more argument, e.g. PlaylistByTitleEx(ParentPlaylist As Object, Title As String) As ISDBPlaylist.
TagsNo tags attached.
Fixed in build1652

Relationships

related to 0011092 closedLudek ISDBPlaylist::AddTrack should not add tracks to auto-playlists 
related to 0011100 new ISDBPlaylist::ChildPlaylist property needed 

Activities

Ludek

2013-07-26 14:32

developer   ~0037013

Last edited: 2013-07-26 14:45

Added new ISDBPlaylist::ChildPlaylistExists(Title As String) As Boolean
in build 1652:
http://www.mediamonkey.com/wiki/index.php/ISDBPlaylist::ChildPlaylistExists

And updated the description of
http://www.mediamonkey.com/wiki/index.php/ISDBPlaylist::CreateChildPlaylist

zvezdan

2013-07-26 15:54

updater   ~0037014

Thanks for the new property. However, we still have the second mentioned problem with auto-playlists. I think that there is not any valid reason for CreateChildPlaylist to return reference to some auto-playlist, even if it has the given Title. As I said, your API doesn't allow modifications of auto-playlists, your API even doesn't allow creating of truly new auto-playlist, i.e. if you specify Title which have none playlist, then you would always get the new static playlist as a result. So, if we cannot create some new auto-playlist, why should we get a reference to some existing auto-playlist using the mentioned method?

Actually, when I think more about those problems, it seems to me that you should remove a possibility for CreateChildPlaylist to return a reference to some existing playlist, static or auto-playlist. I think that you should create another static playlist with the same name anyway. Yes, I don't like multiple playlists with the same name inside of the same parent, but your GUI already allows that. Then, why not allowing that to your API as well?

As I said, it would be better if you have added a property which returns the playlist object. The script could test if playlist with the given Title exists even with such property, comparing it with Nothing. Here is the example how to get a reference to the existing playlist with the same name if you decide to modify CreateChildPlaylist to always create a truly new static playlists:

If oParentPlaylist.ChildPlaylist("Title") Is Nothing Then
    Set oChildPlaylist = oParentPlaylist.CreateChildPlaylist("Title")
Else
    Set oChildPlaylist = oParentPlaylist.ChildPlaylist("Title")
End If

However, if some script wants to create the another playlist with the same name, it could have just:
    Set oChildPlaylist = oParentPlaylist.CreateChildPlaylist("Title")

Please note that I am using here one another suggestion for the property mentioned in issue 0011100.

zvezdan

2013-07-26 17:29

updater   ~0037015

After even more thinking, I begin to see how complex this problem is. I hate to say, but it seems that none of my suggestions is too much useful. Let say that I want to add static playlist within some parent. If I check with ChildPlaylistExists if playlist with the same name exists, and if I get True as a result, I still don't know if that playlist is static or auto-playlist.

If you add my another suggestion with ChildPlaylist property, I could test its resulting playlist if it is static or auto-playlist, but if it returns auto-playlist I still don't know if there exists the static playlists with the same name, but with higher ID. I would need to use For ... Next loop and ChildPlaylists property anyway, just to be sure that the static playlist with the given Title exists.

Nevertheless, I still think that CreateChildPlaylist should not return a reference to existing playlists, but to create a new static playlist with the same name in case that playlist with the given name already exists.