MusicMatch Ratings 1.1 [MM2+3]
Posted: Tue Jan 17, 2006 5:56 am
As requested, this script copies ratings from MusicMatch (which apparently appear as values 1-5 in the Quality field) to MediaMonkey ratings (in the ratings field), of all the selected tracks. It does not remove the information from the Quality field (so the ratings should still appear fine in MusicMatch).
Code: Select all
'
' MediaMonkey Script
'
' NAME: MusicMatchRatings 1.1
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 04/12/2007
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately
'
' [MusicMatchRatings]
' FileName=MusicMatchRatings.vbs
' ProcName=MusicMatchRatings
' Order=19
' DisplayName=MusicMatch Ratings
' Description=Convert MusicMatch Ratings
' Language=VBScript
' ScriptType=0
'
' FIXES: Added text values are now also converted
'
Option Explicit
Dim Debug : Debug = False
Sub MusicMatchRatings
Dim list : Set list = SDB.CurrentSongList
If list.Count = 0 Then
Call SDB.MessageBox("MusicMatchRatings: There are no selected tracks to process.",mtError,Array(mbOk))
Exit Sub
End If
Dim prog : Set prog = SDB.Progress
prog.Text = "Initialising script..."
prog.MaxValue = list.Count
Dim log : Set log = Nothing
If Debug Then
Set log = SDB.Tools.FileSystem.CreateTextFile(Script.ScriptPath&".log",True)
If log Is Nothing Then
Debug = False
Else
Call log.WriteLine("*Processing "&list.Count&" tracks")
End If
End If
Dim c : c = 0
Dim i : i = 0
For i = 0 To list.Count-1
Dim itm : Set itm = list.Item(i)
prog.Text = "Checking track '"&itm.Title&"' ("&(i+1)&"/"&list.Count&")..."
prog.Value = i
SDB.ProcessMessages
Dim r : r = -1
If isNumeric(itm.Quality) Then
Dim q : q = Int(itm.Quality)
If q > -1 Then
If q < 6 Then
r = q * 20
c = c + 1
End If
End If
Else
Select Case itm.Quality
Case "Bad Taste"
r = 0
c = c + 1
Case "Poor"
r = 20
c = c + 1
Case "Fair"
r = 40
c = c + 1
Case "Good"
r = 60
c = c + 1
Case "Very Good"
r = 80
c = c + 1
Case "Excellent"
r = 100
c = c + 1
End Select
End If
itm.Rating = r
If Debug Then
Call log.WriteLine(itm.ID&":"&itm.Quality&"="&q&"="&r&"~"&itm.Title)
End If
If prog.Terminate Then
If Debug Then
Call log.WriteLine("*Cancelled by user")
End If
Exit For
End If
Next
prog.Text = "Finalising script..."
prog.Value = prog.MaxValue
If Not (prog.Terminate) Then
Call list.UpdateAll
If Debug Then
Call log.WriteLine("*Processed all")
End If
End If
If Debug Then
Call log.WriteLine("*Tracks updated: "&c&"/"&list.Count)
log.Close
End if
Call SDB.MessageBox("Tracks updated: "&c&" out of "&list.Count,mtInformation,Array(mbOk))
End Sub
Sub Install()
Dim inip : inip = SDB.ApplicationPath&"Scripts\Scripts.ini"
Dim inif : Set inif = SDB.Tools.IniFileByPath(inip)
If Not (inif Is Nothing) Then
inif.StringValue("MusicMatchRatings","Filename") = "MusicMatchRatings.vbs"
inif.StringValue("MusicMatchRatings","Procname") = "MusicMatchRatings"
inif.StringValue("MusicMatchRatings","Order") = "19"
inif.StringValue("MusicMatchRatings","DisplayName") = "MusicMatch Ratings"
inif.StringValue("MusicMatchRatings","Description") = "Convert MusicMatch Ratings"
inif.StringValue("MusicMatchRatings","Language") = "VBScript"
inif.StringValue("MusicMatchRatings","ScriptType") = "0"
SDB.RefreshScriptItems
End If
End Sub