Restore/Synchronize Database 3.1.2 (2013-08-31) [MM3+]

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Benn
Posts: 300
Joined: Sat Jul 12, 2008 11:59 am
Location: Cornwall, United Kingdom

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by Benn » Sun Aug 23, 2009 2:41 pm

This is great ZvezdanD, a real help if my DB ever gets corrupted again.

Soon, I will be using a laptop in addition to my PC, where I store all of my music. Considering I also have an exact backup of this on my external HD, which the laptop would use for music: would I be able to merge the playhistory of my laptop onto my PC .db using this script?

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by nynaevelan » Sun Aug 23, 2009 2:55 pm

Benn wrote:
... would I be able to merge the playhistory of my laptop onto my PC .db using this script?
:lol: :lol: I was thinking the same thing.
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by nynaevelan » Sun Aug 23, 2009 3:34 pm

Z:

My system seems to lock up for several minutes when switching databases. :-?
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files

ZvezdanD
Posts: 3089
Joined: Thu Jun 08, 2006 7:40 pm

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by ZvezdanD » Sun Aug 23, 2009 4:00 pm

Benn wrote:would I be able to merge the playhistory of my laptop onto my PC .db using this script?
Yes, you would if you turn off the Clear Played... option and, of course, if your tracks have same paths or checksums in both databases.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.7 / 4.0  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.3 / 2.2.2  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

ZvezdanD
Posts: 3089
Joined: Thu Jun 08, 2006 7:40 pm

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by ZvezdanD » Sun Aug 23, 2009 4:05 pm

nynaevelan wrote:My system seems to lock up for several minutes when switching databases. :-?
Well, this is expected since every time when you change database file, the script generates table of matching tracks. You could see the result of that operation in the panel on the bottom of dialog box saying: Backup: xxx, current DB: yyy, matched tracks: zzz.

I could move that operation to be executed after you click on the Replace button, but it should be executed anyway and in that case you would lose mentioned information about number of matched tracks.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.7 / 4.0  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.3 / 2.2.2  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by nynaevelan » Sun Aug 23, 2009 4:18 pm

I suppose I will have to deal with it, it is only annoying when it happens to have the system locked up at the end of the playing song.

But I have another problem, the tracks only seem to restore the playcounts when I have the Clear Played table... option checked. Prior to running script I reset the playcounts to zero for the test tracks.

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files

Mizery_Made
Posts: 2283
Joined: Tue Aug 29, 2006 1:09 pm
Location: Kansas City, Missouri, United States

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by Mizery_Made » Sun Aug 23, 2009 4:30 pm

Code: Select all

UPDATE Songs
SET PlayCounter = (SELECT COUNT(*) FROM Played WHERE Played.IDSong = Songs.ID GROUP BY Played.IDSong),
LastTimePlayed = (SELECT MAX(PlayDate) FROM Played WHERE Played.IDSong = Songs.ID GROUP BY Played.IDSong)
WHERE Songs.ID IN
(SELECT IDSong FROM Played, Songs WHERE Played.IDSong = Songs.ID GROUP BY IDSong
HAVING PlayCounter<>COUNT(*) OR CAST(LastTimePlayed AS TEXT)<>CAST(MAX(PlayDate) AS TEXT))
Bex gave that SQL statement a while back, for fixing the difference between Play Count and History Plays (caused by iPod sinking I believe), and I believe it calculates the number of plays in the Played table and sets the Playcount of the track to the number. I believe it also sets Last Played based on the newest play in said table as well.

For the "Merge" ability, something like this might need to be implemented to run after the IDs are updated or whatnot. Then again, you might already have something like this under the hood (as I have not peeked inside the script) and it's simply breaking due to a type or something. Or maybe you didn't include such a feature, as it would erase these ghost iPod plays. *Shrugs*

ZvezdanD
Posts: 3089
Joined: Thu Jun 08, 2006 7:40 pm

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by ZvezdanD » Sun Aug 23, 2009 4:33 pm

nynaevelan wrote:I have another problem, the tracks only seem to restore the playcounts when I have the Clear Played table... option checked.
If you turn off the Clear Played... option you would get merged playing history from backup database with the current one. Maybe you have turned on the Restore data for filtered tracks only option and your test track is excluded with the active filter. What you got in the panel on the bottom saying matched tracks: zzz?
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.7 / 4.0  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.3 / 2.2.2  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by nynaevelan » Sun Aug 23, 2009 4:44 pm

The tracks and everything matches, here is what it looks like:

Image

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files

ZvezdanD
Posts: 3089
Joined: Thu Jun 08, 2006 7:40 pm

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by ZvezdanD » Sun Aug 23, 2009 4:52 pm

nynaevelan wrote:Prior to running script I reset the playcounts to zero for the test tracks.
Mizery_Made wrote:Bex gave that SQL statement a while back, for fixing the difference between Play Count and History Plays (caused by iPod sinking I believe
Well, I think you are right. Nyn is cleared playcount data from the Songs table, but her Played table remained intact, so she has the difference between those two data. When I merge data from the backup with the current database I calculate the number of different records between Played tables and add that number to the playcount field - since both backup and current database have same Played table in her case, there is not addition to the playcount field in Songs table. So Nyn, you should have consistent data between playcount field and Played table before you use this script.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.7 / 4.0  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.3 / 2.2.2  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by nynaevelan » Sun Aug 23, 2009 4:55 pm

ZvezdanD wrote:
nynaevelan wrote:Prior to running script I reset the playcounts to zero for the test tracks.
Mizery_Made wrote:Bex gave that SQL statement a while back, for fixing the difference between Play Count and History Plays (caused by iPod sinking I believe
Well, I think you are right. Nyn is cleared playcount data from the Songs table, but her Played table remained intact, so she has the difference between those two data. When I merge data from the backup with the current database I calculate the number of different records between Played tables and add that number to the playcount field - since both backup and current database have same Played table in her case, there is not addition to the playcount field in Songs table. So Nyn, you should have consistent data between playcount field and Played table before you use this script.
Actually guys these tracks do not have any data in the played table, they only have playcounts because they were added by the Track Redirection script. And yes I used Bex's AddRemove Playstats script prior to selecting my test tracks just to be sure.
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files

ZvezdanD
Posts: 3089
Joined: Thu Jun 08, 2006 7:40 pm

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by ZvezdanD » Sun Aug 23, 2009 5:12 pm

nynaevelan wrote:Actually guys these tracks do not have any data in the played table, they only have playcounts because they were added by the Track Redirection script. And yes I used Bex's AddRemove Playstats script prior to selecting my test tracks just to be sure.
Only thing that comes to my mind is that your Played table in the backup database is empty as well. There is no help in that case. I simply cannot add any number to the playcount field because I don't know which plays are same between those two databases and which plays are new only to the current database.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.7 / 4.0  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.3 / 2.2.2  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by nynaevelan » Sun Aug 23, 2009 5:23 pm

So if the played table is empty for the selected tracks, then you have to have the Clear Played.... option selected??
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files

ZvezdanD
Posts: 3089
Joined: Thu Jun 08, 2006 7:40 pm

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by ZvezdanD » Sun Aug 23, 2009 5:43 pm

nynaevelan wrote:So if the played table is empty for the selected tracks, then you have to have the Clear Played.... option selected??
I am ready for any suggestion, but if I want to merge two databases I cannot simply add playcounts from the backup to the current database. I need to find which plays was same in both databases and which are different, but it cannot be done in your case since your Played table is empty. As I said, your Played table should be consistent with the Playcount field in the Songs table if you want the correct value.

It is totally different thing if you choose the Clear Played... option. In that case the play history data from the backup database would be simply copied over same data in the current database.
Magic Nodes 4.3.3 / 5.2 RegExp Find & Replace 4.4.9 / 5.2  Invert Selection/Select None 1.5.1  Export/Create Playlists for Child Nodes 4.1 / 5.4  Expand Child Nodes/Expand All 1.1.2  Event Logger 2.7  Filtered Statistics Report 1.6  Track Redirection & Synchronization 3.4.2  Restore/Synchronize Database 3.1.7 / 4.0  Find Currently Playing Track 1.3.2  Queue List 1.2.1  Add to Library on Play 1.0.1  Tree Report for Child Nodes 1.1.1  Update Location of Files in Database 1.4.3 / 2.2.2  Inherit Child Playlists 1.0.2  Add Currently Playing/Selected Track(s) to Playlist 1.1.2

nynaevelan
Posts: 5559
Joined: Wed Feb 07, 2007 11:07 pm
Location: New Jersey, USA
Contact:

Re: Restore Play History/Date Added 1.2 (2009-08-23) [MM3]

Post by nynaevelan » Sun Aug 23, 2009 5:51 pm

Ok:

I think I understand now, I do not think you need to make any changes, these redirected tracks do not have any playhistory so they would not be something that will be restored anyway. I'll test this on my "true" tracks in my test account.

Nyn
3.2x - Win7 Ultimate (Zen Touch 2 16 GB/Zen 8GB)
Link to Favorite Scripts/Skins

Join Dropbox, the online site to share your files

Post Reply