Page 1 of 1

Clever method to check if song in playlist?

Posted: Tue Sep 13, 2016 10:18 am
by Just Guessing
Is there a simple scripting method to test if a song is already in a playlist?

I'd like to avoid the MM duplication confirmation page I would get otherwise. Obviously one could go through a loop of each song in playlist, but I'm wondering if it isn't easier than that.

Re: Clever method to check if song in playlist?

Posted: Tue Sep 13, 2016 11:13 am
by Lowlander
The following Addon can show this in a panel: http://www.mediamonkey.com/forum/viewto ... tion+panel

The Classification tab of the Properties window will also show what Playlist(s) a file belongs to.

Re: Clever method to check if song in playlist?

Posted: Tue Sep 13, 2016 11:29 am
by Just Guessing
No, I mean in order to accomplish an IF/THEN like below:

If Not In Playlist "whatever"( theSong) then
SDB.PlaylistByTitle("whatever").AddTrack( theSong )
end if

I can tighten the goal down to 5 lines of code, but wonder if I haven't missed some single line that does the job:
Dup = False
for i = 0 To SDB.PlaylistByTitle(Playlist).Tracks.Count - 1
if SDB.PlaylistByTitle(Playlist).Tracks.Item(i).ID = NewSong.ID Then Dup = True
next
if Dup = False Then SDB.PlaylistByTitle(Playlist).AddTrack NewSong

Re: Clever method to check if song in playlist?

Posted: Fri Oct 14, 2016 4:57 am
by chrisjj
Just Guessing wrote: I can tighten the goal down to 5 lines of code, but wonder if I haven't missed some single line that does the job:
Dup = False
for i = 0 To SDB.PlaylistByTitle(Playlist).Tracks.Count - 1
if SDB.PlaylistByTitle(Playlist).Tracks.Item(i).ID = NewSong.ID Then Dup = True
next
if Dup = False Then SDB.PlaylistByTitle(Playlist).AddTrack NewSong
You could accelerate that by exiting the loop in the THEN.

Re: Clever method to check if song in playlist?

Posted: Fri Oct 14, 2016 4:57 am
by chrisjj
Just Guessing wrote:Is there a simple scripting method to test if a song is already in a playlist?

I'd like to avoid the MM duplication confirmation page I would get otherwise.
Don't you get this option to avoid that confirmation dialog?

Image