importing playcounts from a file?

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

mohikaani
Posts: 63
Joined: Wed Oct 31, 2007 2:25 pm

importing playcounts from a file?

Post by mohikaani » Fri Mar 28, 2008 12:15 pm

Is there a script to import playcounts from e.g. txt or csv files or even SQL-database? Files would include the song path and number of playcounts.

benzo8
Posts: 43
Joined: Tue Feb 19, 2008 4:31 am

Post by benzo8 » Fri Mar 28, 2008 12:21 pm

See http://www.mediamonkey.com/forum/viewtopic.php?t=15800

The script in that thread currently only works with MM 2, but hopefully the author is looking at implementing it for MM3.

The PERL script for pulling your plays from LastFM works great!

mohikaani
Posts: 63
Joined: Wed Oct 31, 2007 2:25 pm

Post by mohikaani » Fri Mar 28, 2008 12:38 pm

Thanks for your quick reply. I´ve tried the LastFM PERL script and got it working but naturally the import was not succesfull because I'm using MM3.

However I thought that it would be easier to import playcounts if I had the absolute path of those files.

benzo8
Posts: 43
Joined: Tue Feb 19, 2008 4:31 am

Post by benzo8 » Fri Mar 28, 2008 12:52 pm

Unfortunately, the Play Count isn't just an entry in the Song record in the Song table in the database... Because MM records *when* a track is played, all plays are stored individually in another Plays table and linked to each song.

So, a script to read a text file cannot just go through and add your plays to each Song - it needs to increment through the file, create a new Played record with a spoofed date, and link it to the correct song.

If nothing moves with the current script over the next few days, I'm thinking about:

a) expanding the provided PERL script to add an idea of which week the play came from, so the spoofed dates are even vaguely accurate, and
b) updating the update script to work with MM3...

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

Post by nynaevelan » Fri Mar 28, 2008 12:56 pm

I don't know how you would get the plays into MM, but once you did you can use the Fake Plays script to update the Plays table.

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

metalgorilla
Posts: 3
Joined: Mon Mar 24, 2008 11:45 pm

Post by metalgorilla » Sat Mar 29, 2008 9:36 pm

@benzo8 3/28 @12:52 - It would be outstanding if you could make the mods you spoke of so that Last.FM play counts could be imported back to MM3. You're idea to dummy up the play date to have some semblance to reality is exactly what I've been looking for. It seems like most of the various script elements exist but they're not all put together to do the entire job.

One thing confuses me though: Why the available data from Last.FM does not have the actual play dates. I understand that the PERL script doesn't have this data because it gets SUMMARY information for each track (i.e. number of plays) for a given week.

But isn't there a way to obtain the information from Last.FM via the Recent Tracks Chart page? For example:

http://www.last.fm/user/RJ/charts/?char ... st&range=1

Can't the Artist, Track Name, and Play Timestamp be harvested from this page? And then iterate through page 1 to x? Sure, the script would need to be run every 14 days since the data will scroll off beyond the 14 day window but that seems a small price to pay for getting accurate play dates.

Am I missing something here? Why isn't this possible?

Anyway, I'm no scripter. But I look forward to your efforts to get Last.Fm play dates into MM3. Thanks!

Metalgorilla

mohikaani
Posts: 63
Joined: Wed Oct 31, 2007 2:25 pm

Re: importing playcounts from a file?

Post by mohikaani » Thu Sep 04, 2008 3:07 pm

Any news from this one?

My data is sorted to a spreadsheet file:
  • PlayedDate(yyyy-mm-dd hh:mm:ss) <tab> Filepath
    PlayedDate(yyyy-mm-dd hh:mm:ss) <tab> Filepath
    PlayedDate(yyyy-mm-dd hh:mm:ss) <tab> Filepath
Can it be imported to mediamonkey database via script?
Windows 7 | MediaMonkey 3.2.0.1294
Dell Studio 1537 (Core 2 Duo T6400, 320GB HD, 4GB RAM, ATI Radeon HD 3450)

Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Re: importing playcounts from a file?

Post by Big_Berny » Thu Sep 04, 2008 4:08 pm

Could you post a line of such a text-file? The MixMeister-BPM script should be very easy to modify to import this information.

EDIT: It's an excel-file? If yes, you had to convert it into a txt-file first.
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design

mohikaani
Posts: 63
Joined: Wed Oct 31, 2007 2:25 pm

Re: importing playcounts from a file?

Post by mohikaani » Thu Sep 04, 2008 4:35 pm

Windows 7 | MediaMonkey 3.2.0.1294
Dell Studio 1537 (Core 2 Duo T6400, 320GB HD, 4GB RAM, ATI Radeon HD 3450)

Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Re: importing playcounts from a file?

Post by Big_Berny » Fri Sep 05, 2008 2:12 pm

Ok mohikaani, here it is. :)

Should work fine with the converted text-file. At least it did here. It increases the playcounter and if needed the lastplayed-date. Let me know if you have any problems.

Code: Select all

Option Explicit
'1. Save this text as 'PlayCountImport.vbs' in the Scripts-folder of MediaMonkey
'2. Add this Section to Scripts.ini

'[PlayCountImport]
'FileName=PlayCountImport.vbs
'ProcName=PlayCountImport
'DisplayName=PlayCountImport
'Language=VBScript
'ScriptType=0

'3. Edit the path to your playcounter-file in the code below.
'4. Restart MediaMonkey
'5. You'll find "PlayCountImport" under Tools/Scripts

Public Const path = "c:\bpm_test.txt" 'PUT THE PATH TO YOUR FILE HERE

Sub PlayCountImport
	Dim str, arr, songpath, sit, itm, playdate
	Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
	if fso.FileExists(path) then
		Dim txt : Set txt = fso.OpenTextFile(path,1,False)
		SDB.Database.BeginTransaction
		Do While Not txt.AtEndOfStream
			SDB.ProcessMessages
			str = Trim(txt.ReadLine)
			arr = Split(str,Chr(9))
			songpath = Mid(arr(1),2)
			playdate = FormatDateTime(arr(0))
			Set sit = SDB.Database.QuerySongs("AND (Songs.SongPath = '"&Replace(songpath,"'","''")&"')")
			If Not (sit.EOF) Then 
				Set itm = sit.Item
				itm.Playcounter = itm.PlayCounter + 1
				if DateValue(itm.LastPlayed) < DateValue(playdate) then
					itm.LastPlayed = playdate
				end if
			itm.UpdateDB
			End If
		Loop
		Set sit = Nothing
		SDB.Database.Commit
	else
		SDB.MessageBox "The file `"&path&"` unfortunately doesn't exist."& vbCrLf &"Please modify the path to the file in the Scriptcode.", mtError, Array(mbOk)
	end if
End sub
Hope you like it! :) And if you have any problems let me know.

Big_Berny
Last edited by Big_Berny on Fri Sep 05, 2008 4:04 pm, edited 1 time in total.
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design

mohikaani
Posts: 63
Joined: Wed Oct 31, 2007 2:25 pm

Re: importing playcounts from a file?

Post by mohikaani » Fri Sep 05, 2008 2:27 pm

Holy cow! This is awesome :) THX
Windows 7 | MediaMonkey 3.2.0.1294
Dell Studio 1537 (Core 2 Duo T6400, 320GB HD, 4GB RAM, ATI Radeon HD 3450)

mohikaani
Posts: 63
Joined: Wed Oct 31, 2007 2:25 pm

Re: importing playcounts from a file?

Post by mohikaani » Fri Sep 05, 2008 3:48 pm

I've got errors when trying to import many playcounts (> few hundred)

Image
Image

MM aclaims to store the playcounts but after restart the playcounts gets lost.
Windows 7 | MediaMonkey 3.2.0.1294
Dell Studio 1537 (Core 2 Duo T6400, 320GB HD, 4GB RAM, ATI Radeon HD 3450)

Big_Berny
Posts: 1784
Joined: Mon Nov 28, 2005 11:55 am
Location: Switzerland
Contact:

Re: importing playcounts from a file?

Post by Big_Berny » Fri Sep 05, 2008 4:05 pm

Hi mohikaani,
sorry about that. Please copy the script again, it should be fixed now.

Big_Berny
Image
Scripts in use: Genre Finder / Last.fm DJ / Magic Nodes / AutoRateAccurate / Last.FM Node
Skins in use: ZuneSkin SP / Eclipse SP
AutoRateAccurate 3.0.0 (New) - Rates all your songs in less than 5 seconds!
About me: icoaching - internet | marketing | design

mohikaani
Posts: 63
Joined: Wed Oct 31, 2007 2:25 pm

Re: importing playcounts from a file?

Post by mohikaani » Fri Sep 05, 2008 4:23 pm

Yes! It's fixed 8)
Windows 7 | MediaMonkey 3.2.0.1294
Dell Studio 1537 (Core 2 Duo T6400, 320GB HD, 4GB RAM, ATI Radeon HD 3450)

metalgorilla
Posts: 3
Joined: Mon Mar 24, 2008 11:45 pm

Re: importing playcounts from a file?

Post by metalgorilla » Thu Nov 13, 2008 10:17 am

Big_Berny,

I would like to try and use your PlayCountImport script for some MM DB clean-up I'm trying to do. Can you post a sample record showing the format of the input file? The link to the sample originally provided by mohikaani on Sept 4 is dead.

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
EXTRA DETAIL FOR ANYONE WHO IS INTERESTED:

What I'm trying to do is import my Last.FM play stats including play dates for each track. I use SqueezeBox as my main player. I use MM for collection management but I don't use it much to actually listen to music. As such, the scrobbled play history at Last.FM is the only accurate list of what I listen to. I've been unable to find an existing script that accomplishes pulls Last.FM playcounts AND play dates for each track. I currently have 18 months of Last.FM play history that I'd like to get into MM.

Because I don't know VBS, I wrote a VBA module in MS Access to loop through the 650+ pages of my Last.FM listening history. The track name and play date/time is extracted and written to a file. This worked fine. I believe I can easily adjust the format of this file to match whatever input format your PlayCountImport script needs.

Ideally, if I could have my wish, I'd love to have a MM script that actually combines in one place my Last.FM "history harvest" with a MM play count/play date update. Given a user's Last.FM ID the script would go fetch all Last.FM play history occurring since the prior Last.FM history update. Maybe the script keeps a record of each import date/time and only retrieves history from current date back to last update. If done right the script could probably pull the data to a temp table in MM and then update MM DB without even using a file.

Such a script is beyond my skills. However, if anyone else is interested I'd be glad to share my MS Access VBA code that retrieves play history (with dates) from Last.FM.

But even if no one wants to tackle my dream script I think your PlayCountImport is what I need to manually update my MM play history.

Thanks!

Post Reply