Clever method to check if song in playlist?

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Clever method to check if song in playlist?

Re: Clever method to check if song in playlist?

by chrisjj » Fri Oct 14, 2016 4:57 am

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

Re: Clever method to check if song in playlist?

by chrisjj » Fri Oct 14, 2016 4:57 am

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?

by Just Guessing » Tue Sep 13, 2016 11:29 am

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?

by Lowlander » Tue Sep 13, 2016 11:13 am

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.

Clever method to check if song in playlist?

by Just Guessing » Tue Sep 13, 2016 10:18 am

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.

Top