it's working fine for me with both of those scenarios???
i've now edited to give a report at the end. this is what should happen:
example of duplicate track numbering (first number is generated by script, 2nd is actual value from tag)
-------------------------------------------------------------------
new album detected
HAIM|Days Are Gone|2013|1
1 => 1
2 => 2
3 => 3
4 => 4
5 => 5
6 => 6
7 => 6 (bad)
8 => 8
9 => 9
10 => 10
11 => 11
this album had mistmatched tracks. adding to playlist.
example of 1st track missing which throws off the matching for the entire album
-------------------------------------------------------------------
new album detected
Ivy|In The Clear|2005|?
1 => 2 (bad)
2 => 3 (bad)
3 => 4 (bad)
4 => 5 (bad)
5 => 6 (bad)
6 => 7 (bad)
7 => 8 (bad)
8 => 9 (bad)
9 => 10 (bad)
this album had mistmatched tracks. adding to playlist.
example of correctly tagged album
-------------------------------------------------------------------
new album detected
Abraham|On The Surface|2001|?
1 => 1
2 => 2
3 => 3
4 => 4
5 => 5
6 => 6
7 => 7
8 => 8
this album checked ok
updated code:
var album_tf = "%album artist%|%album%|%date%|%discnumber%";
var EMPTY = plman.GetPlaylistSelectedItems(-1);
function on_mouse_lbtn_dblclk() {
var items = plman.GetPlaylistItems(plman.ActivePlaylist);
if (items.Count == 0) return;
var current_album = "", text = "", temp_album, album_track , track, album_is_good = true;
var album_tracks = bad_albums = EMPTY.clone();
for (var i = 0; i < items.Count; i++) {
temp_album = fb.TitleFormat(album_tf).EvalWithMetadb(items.item(i));
if (temp_album != current_album) {
if (!album_is_good) {
text += "this album had mistmatched tracks. adding to playlist.\n";
bad_albums.AddRange(album_tracks);
album_tracks.Dispose();
} else if (i > 0) {
text += "this album checked ok" + "\n";
}
text += "-------------------------------------------------------------------\n";
text += "new album detected\n";
text += temp_album + "\n";
album_tracks = EMPTY.clone();
album_is_good = true;
current_album = temp_album;
album_track = 1;
}
track = fb.TitleFormat("$num(%tracknumber%,0)").EvalWithMetadb(items.item(i));
if (track != album_track) album_is_good = false;
text += album_track + " => " + track + (track != album_track ? " (bad)" : "") + "\n";
album_tracks.Add(items.item(i));
album_track++;
}
if (bad_albums.Count > 0) {
plman.CreatePlaylist(plman.PlaylistCount, "WSH suspicious items");
plman.ActivePlaylist = plman.PlaylistCount - 1;
plman.InsertPlaylistItems(plman.ActivePlaylist, 0, bad_albums);
} else {
text = "everything seems ok!\n\n" + text;
}
fb.ShowPopupMessage(text);
album_tracks.Dispose();
bad_albums.Dispose();
}
edited so report shows even with no problems.