"Item.SongID > -1" isn't the same as "Not

This forum is for reporting bugs in MediaMonkey for Windows 4. Note that version 4 is no longer actively maintained as it has been replaced by version 5.

Moderator: Gurus

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

"Item.SongID > -1" isn't the same as "Not

Post by Steegy »

Hello

I had a scripting problem and I didn't understand why it wasn't working. After testing several things, I saw that when adding a new SongData to the Player's playlist (using SDB.NewSongData, without adding to the library) for an external audio file, the SongID is -1 as it should be, but IsntInDB is wrong (either false, or some similar value, definitely not true).

When I change "Not Item.IsntInDB" by "Item.SongID > -1", it works fine.
Normally these 2 things should be identical, no?

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
jiri
Posts: 5426
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Post by jiri »

No, 'IsntInDB' is true only if MM checked Path of track and found that it isnt' in database. SongID can be -1 even if track is in database, but MM doesn't know about it yet.

Jiri
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

Ok, but the track that I add to the playlist is an external track (added using a new SongData object and filled the path, artist and title), that is not in the library/database. So shouldn't the 'IsntInDB' property be true then?

Adding external tracks to the Now Playing list (by drag&drop) sets the IsntInDB property to true.
However, if I add them through code (new SongData, without using UpdateDB or so), then the IsntInDB property is not true.

There are no songs with ID = -1 (or without ID) in my Songs table, and I haven't found any occurence of these external tracks in the library.

BTW: This is about the "SaveAndRestoreNowPlaying" script, that I pm'ed you about some time ago.
SongID can be -1 even if track is in database, but MM doesn't know about it yet.
When would this be then?

Anyway, that part of the code works now, but it can be useful to fully understand why this behaviour of MM is happening.

Thanks
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
jiri
Posts: 5426
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Post by jiri »

Let me try to give you an example:

1. You add a track to Now Playing with SongID=-1, IsntInDB=false, Path=C:\music\x.mp3
2. MM starts a thread and so _later_ it finds out whether this track is in DB:
2a. Track is in DB => SongID=n (n>0), IsntInDB=false
2b. Track isn't in DB => SongID=-1, IsntInDB=true

In other words:
IsntInDB = true: We are sure that this track isn't stored in Library, i.e. we have already made an SQL query and it wasn't there.
IsntInDB = false: If SongID>0 then track is clearly in Library, if SongID=-1 then we don't know anything yet.

I can also add that device plug-ins use this property to Set (i.e. they don't read it) that a track isn't in library and thus make MM operations faster - MM doesn't need to execute a SQL query about such a track.

Jiri
Post Reply