New *basic* Script to insert fake plays from iPod
-
- Posts: 5559
- Joined: Wed Feb 07, 2007 11:07 pm
- Location: New Jersey, USA
- Contact:
Ok, thank you, will try running it again.
Nyn
EDIT: This is awesome, I had alot that needed fake plays.
Nyn
EDIT: This is awesome, I had alot that needed fake plays.
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
Link to Favorite Scripts/Skins
Join Dropbox, the online site to share your files
Ok, thank you very much.
Is it ok for you to write "Based on the FakePlays script by brianon. Now developed by Christoph."?
nynaevelan, from your point of you, could it be right, that your songs needed many fake plays? In my archive, it's right because I increase the play counter by myself when I played some songs on my mp3 player.
Christoph
Is it ok for you to write "Based on the FakePlays script by brianon. Now developed by Christoph."?
nynaevelan, from your point of you, could it be right, that your songs needed many fake plays? In my archive, it's right because I increase the play counter by myself when I played some songs on my mp3 player.
Christoph
-
- Posts: 5559
- Joined: Wed Feb 07, 2007 11:07 pm
- Location: New Jersey, USA
- Contact:
Yes it would be because there was a time when I was beta testing before the import database feature was available that I used Berny's import play counts script, so I was not suprised I had over 2000 that needed at least 1 fake date. I wanted the report because I wanted to check to make sure it consisted mostly of my "favorites". Also, since MM doesn't import play data from a Creative device, I had to manually change some play counts using the Set Playcount script. I am very eager to get home and try it on my main database to see how the true numbers will affect my Play History stats.Christoph wrote:Ok, thank you very much.
Is it ok for you to write "Based on the FakePlays script by brianon. Now developed by Christoph."?
nynaevelan, from your point of you, could it be right, that your songs needed many fake plays? In my archive, it's right because I increase the play counter by myself when I played some songs on my mp3 player.
Christoph
Thanks for this one.
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
Link to Favorite Scripts/Skins
Join Dropbox, the online site to share your files
Ok, in this case, all should be correct.
I noticed that the script adds floats in the played table with the wrong separator "," if you're working with a German windows.
I've added a little correction option that will fix this issue. You can activate it in line 32.
Christoph
Edit: Removed old code.
I noticed that the script adds floats in the played table with the wrong separator "," if you're working with a German windows.
I've added a little correction option that will fix this issue. You can activate it in line 32.
Christoph
Edit: Removed old code.
Last edited by Christoph on Sun Mar 16, 2008 4:06 pm, edited 1 time in total.
-
- Posts: 5559
- Joined: Wed Feb 07, 2007 11:07 pm
- Location: New Jersey, USA
- Contact:
Question:
If the script scans 8000 tracks and it finds 80 that need to have fake plays inserted, why does it tag all 8000 tracks, shouldn't it only be making adjustments to the 80 that need the fake plays??
Nyn
If the script scans 8000 tracks and it finds 80 that need to have fake plays inserted, why does it tag all 8000 tracks, shouldn't it only be making adjustments to the 80 that need the fake plays??
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
Link to Favorite Scripts/Skins
Join Dropbox, the online site to share your files
Hello again,
this issue should be fixed now.
Christoph
this issue should be fixed now.
Christoph
Code: Select all
' MediaMonkey Script
'
' NAME: FakePlays
'
' AUTHOR: Based on the FakePlays script by brianon. Now developed by Christoph.
' Start Date : 29-03-2008
'
'---------------------------------------------------------------------------------------------------------
' Ver 1.3.2 (16 Mar 2008)
'---------------------------------------------------------------------------------------------------------
Dim region
Dim simu
Sub FakePlays
Dim DB : Set DB = SDB.Database
Dim list, itm, i
Dim trackPlayCount, trackPlayDates, fakePlaysToCreate
Dim strSQL, sqlQry
Dim formattedAddedDate, dateToInsert
Dim secondsDiff
Dim lastSyncDate
Dim bHasSyncDate
Dim corr
If CDbl("1,0")=1.0 Then
region=true
Else
region=false
End If
simu=True 'Activate this for report generation
' corr=True 'Activate this for correcting the "," problem in the "played" database
If corr=True Then
SDB.Progress.Text="Correcting..."
Set sq=SDB.Database.OpenSQL("SELECT IDPlayed,PlayDate FROM Played WHERE playdate LIKE '%,%'")
While Not sq.EOF
DB.ExecSQL("UPDATE Played SET PlayDate="&Replace(sq.StringByName("PlayDate"),",",".")&" WHERE IDPlayed="&sq.StringByName("IDPlayed"))
sq.Next
WEnd
Set sqlQry=Nothing
SDB.Database.Commit
SDB.Progress=Nothing
Exit Sub
End If
'Create any temp tables we want and remove any from previous release if required.
DB.ExecSQL("CREATE TABLE IF NOT EXISTS tmpLastFakeSync (SongId INTEGER PRIMARY KEY, SyncDate VbDateTime)")
'DB.ExecSQL("DROP TABLE tmpLastFakeSync")
'Set up progress
Set Progress = SDB.Progress
'Get list of selected tracksfrom MediaMonkey
Set list = SDB.CurrentSongList
If list.Count=0 Then
Exit Sub
End If
Progress.Text = "Processing tracks..."
'Create the Report File
If Simu=True Then
Set f=CreateObject("Scripting.FileSystemObject")
Set file=f.OpenTextFile(Script.ScriptPath&".log",2,true)
file.WriteLine "FakePlay Log"
file.WriteLine "------------"
End If
'Process all selected tracks
SDB.Database.BeginTransaction
For i=0 To list.count-1
Progress.Text = "Processing track "&(i+1)&"/"&list.count&"..."
Set itm = list.Item(i)
'Get the start (BEGIN) date
Set sqlQry = SDB.Database.OpenSQL("SELECT tmpLastFakeSync.SyncDate AS LastSyncDate FROM tmpLastFakeSync WHERE tmpLastFakeSync.SongId="&itm.ID)
lastSyncDate = prepareDouble(sqlQry.StringByName("LastSyncDate"))
If lastSyncDate = "" Then
bHasSyncDate = false
'here we get the date this track was added to the library
Set sqlQry = SDB.Database.OpenSQL("SELECT Songs.DateAdded AS TrackAddedDate FROM Songs WHERE Songs.ID="&itm.ID)
lastSyncDate = prepareDouble(sqlQry.StringByName("TrackAddedDate"))
formattedSyncDate = FormatDateTime(lastSyncDate,2)&" "&FormatDateTime(lastSyncDate,3)
Else
bHasSyncDate = True
formattedSyncDate = FormatDateTime(lastSyncDate,2)&" "&FormatDateTime(lastSyncDate,3)
End If
'here we get the playcount of the current track
trackPlayCount = itm.PlayCounter
'here we get the number of time/date entries for this track from SQL query
Set sqlQry = SDB.Database.OpenSQL("SELECT Count(Played.IdSong) AS CountOfPlays FROM Played WHERE Played.IdSong="&itm.ID)
trackPlayDates = sqlQry.StringByName("CountOfPlays")
'get the difference
fakePlaysToCreate = trackPlayCount - trackPlayDates
If Simu=True Then
End If
' only continue if we have fake plays to create
' **TODO: could increment/decrement playcounter to match actual plays ?
If fakePlaysToCreate > 0 Then
'now we need to determine how many seconds we should add to our starting date each time
'we add a fake entry
secondsToAdd = calcSecondsToAdd(formattedSyncDate, fakePlaysToCreate)
If Simu=True Then
file.WriteLine "Insert "&fakePlaysToCreate&" fake plays: "&itm.Path&"("&itm.ID&")"
Else
dateToInsert = formattedSyncDate
'now create 'X' fake plays. For each play missing, add a 'dummy'
For x=0 To fakePlaysToCreate-1
dateToInsert = DateAdd("s",secondsToAdd, dateToInsert)
DB.ExecSQL("INSERT INTO Played (IdSong, PlayDate) VALUES ("&itm.ID&",'"&Replace(Cdbl(dateToInsert),",",".")&"')")
Next
' update the last played date
If itm.lastPlayed<CDbl(dateToInsert) Then
itm.lastPlayed=CDbl(dateToInsert)
End If
' now update our FakeSynList or add a new entry
If bHasSyncDate = true Then
DB.ExecSQL("UPDATE tmpLastFakeSync SET SyncDate = '" & Now() &"' WHERE SongId = " &itm.ID)
Else
DB.ExecSQL("INSERT INTO tmpLastFakeSync (SongId, SyncDate) values ("& itm.ID &", '" & Now() &"')")
End If
End If
ElseIf trackPlayCount>0 Then
Set sqlQry = SDB.Database.OpenSQL("SELECT PlayDate FROM Played WHERE IDSong="&itm.ID&" ORDER BY PlayDate DESC LIMIT 0,1")
dateToInsert = prepareDouble(sqlQry.StringByName("PlayDate"))
formattedSyncDate = FormatDateTime(dateToInsert,2)&" "&FormatDateTime(dateToInsert,3)
If DateDiff("s",itm.lastPlayed,formattedSyncDate)>0 Then
If simu=True Then
file.WriteLine "Update PlayDate: "&itm.Path
Else
itm.lastPlayed=formattedSyncDate
itm.UpdateDB
End If
End If
End If
Next
Set Progress = Nothing
Set sqlQry=Nothing
SDB.Database.Commit
If Simu=True Then
file.Close
End If
End Sub
Function calcSecondsToAdd(addedDate, playsToCreate)
calcSecondsToAdd = DateDiff("s",addedDate, Now)/(playsToCreate+1)
End Function
Function prepareDouble(number)
If region=True Then
prepareDouble=Replace(number,".",",")
Else
prepareDouble=number
End If
End Function
Here is my issue. when you import the itunes playcounts and stats it does not import the last played date. So I get all the playcounts but no playdate. What I'd like to do is give them all played dates even if they are a bit inaccurate. I tried using the last version of this script and it didn't update my lastplayed.
Hey,
ok, I tested the following:
I imported a song to my lib. Then I changed the playcount to 3. After that I executed the fakeplays script. And it works.
Maybe you didn't deactivated the simulation mode before running the script. You have to do this before applying it to your lib.
Just comment line 31:
Christoph
ok, I tested the following:
I imported a song to my lib. Then I changed the playcount to 3. After that I executed the fakeplays script. And it works.
Maybe you didn't deactivated the simulation mode before running the script. You have to do this before applying it to your lib.
Just comment line 31:
Code: Select all
' simu=True 'Activate this for report generation