Import Play Counts From RockBox

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

smilerz

Import Play Counts From RockBox

Post by smilerz »

This script only works if you have the last.fm log enabled on your rockbox. Essentially it parses through the log and increments each song that it finds by 1.

Code: Select all

Option Explicit
'on error resume Next
' - this script will parse through a scrobbler.log (as implemented on RockBox) and update MediaMonkey's Play Count
' - this script operates under several assumptions
' - A) A query for album, artist & song title will be unique
' - B) That each entry in scrobbler.log is equivalent to 1 play
' - C) That the script is always being read for the first time - it will always update the full contents of the Log
' - D) the only lines that need skipped begin with a '#'
' - Todo - Upload scrobbler.log to last.fm

Sub RockScrobblerPlayCounts
	Const ForReading = 1
	Dim strPath
	Dim objFSO
	Dim objScrobbler
	Dim strReadLine
	Dim arrScrobblerInfo
	Dim objRecordSet
	Dim objSong
	Dim strAlbum
	Dim strArtist
	Dim strSongTitle
	
	' - open .scrobbler.log
	strPath = InputBox ("Enter Path to scrobbler.log", "Enter Path", "D:\.scrobbler.log")
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	If Not objFSO.FileExists(strPath) Then
		MsgBox "Scrobbler Log Could Not Be Found"
		WScript.Quit
	End If
	Set objScrobbler = objFSO.OpenTextFile(strPath, ForReading)
	
	' parse through the log and find tracks that have been played
	Do Until objScrobbler.AtEndOfStream
		strReadLine = objScrobbler.ReadLine
		' - skip any lines that begin with '#'
		If Left(strReadLine,1) <> "#" Then
			arrScrobblerInfo = Split(strReadLine,vbTab)
			strAlbum = arrScrobblerInfo(1)
			strArtist = arrScrobblerInfo(0)
			strSongTitle = arrScrobblerInfo(2)
		
			' - find the track
			Set objRecordSet = SDB.Database.QuerySongs("AND Album = " & chr(34) & _
				strAlbum & Chr(34) & "AND Artist = " & CHR(34) & strArtist & chr(34) & _
				"AND SongTitle = " & chr(34) & strSongTitle & chr(34))
			
			' - increment the play counter
			While Not objRecordSet.eof
				Set objSong = objRecordSet.item
				objSong.playcounter = objSong.PlayCounter + 1
				objSong.updatedb
				objRecordSet.next
			Wend
		End If
	Loop
	
	MsgBox "Completed Updating Playcounts"
	' - Cleanup
	objScrobbler.Close
	Set objScrobbler 	= Nothing
	Set objFSO 			= Nothing
End Sub
mkny13
Posts: 64
Joined: Mon Mar 31, 2008 7:33 am
Contact:

Re: Import Play Counts From RockBox

Post by mkny13 »

Forgive my ignorance, but how would one use this script? Paste it into a vbs file?
Post Reply