Is it possible..
Is it possible..
Is it possible to write a script that would, when activated, pause the music between each song and prompt me for a rating? This would be useful when listening to something for the first time, as all to often I forget about rating the music so end up with only one or two tracks with ratings.
Thanks!
Thanks!
You want this prompt to appear at the end of every song?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Code: Select all
See new version below
Last edited by Steegy on Wed Jul 04, 2007 7:34 am, edited 1 time in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
See newer version below.If it's easy enough a menu item or some other way to turn it on or off would be great.
Last edited by Steegy on Wed Jul 04, 2007 7:33 am, edited 1 time in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
As I don't like to rate songs the first time I actually listened to them, I did a little modification to this script which actually considers the playcount of the played song as well. This way I get the popup after listening to the song the second time.
Simply replace:
in RatePlayedSong.vbs with
Of course, you can set this number to any other as well (if you want to listen to a song for ten times, before you rate it 
Simply replace:
Code: Select all
If PreviouslyPlayedSong.Rating = -1 Then
Code: Select all
If PreviouslyPlayedSong.Rating = -1 And PreviouslyPlayedSong.Playcounter > 1 Then

Here's an updated version.
You can change the caption of the rating buttons by changing the contents of the BtnCapt array.
This script in an autoscript without installer. See the FAQ for installation instructions.
You can change the caption of the rating buttons by changing the contents of the BtnCapt array.
This script in an autoscript without installer. See the FAQ for installation instructions.
Code: Select all
'====================================================================================
' MEDIAMONKEY SCRIPT: RatePlayedSong v1.1 (last updated 2007-07-04) by Steegy
'
' Shows a dialog when a song is started, to rate the previous played song.
'====================================================================================
Option Explicit
Dim BtnCapt : BtnCapt = Array("5", "4½", "4", "3½", "3", "2½", "2", "1½", "1", "½", "0")
Dim PreviousSong
Dim DoneSettingRating
Dim MI
Sub OnStartup
If SDB.IniFile.StringValue("RatePlayedSong", "Enabled") = "" Then
SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = True
End If
Set MI = SDB.UI.AddMenuItem(SDB.UI.Menu_Scripts, 1, 1)
MI.Caption = "Rate Played Song"
MI.Hint = "Activate/deactivate dialog for rating played song"
MI.Checked = SDB.IniFile.BoolValue("RatePlayedSong", "Enabled")
Script.RegisterEvent MI, "OnClick", "MI_OnClick"
Script.RegisterEvent SDB, "OnPlay", "RatePlayedSong"
End Sub
Sub RatePlayedSong
If Not IsEmpty(PreviousSong) And MI.Checked Then
If PreviousSong.Rating = -1 Then
SDB.Player.Pause
SDB.Player.PlaybackTime = 0
Dim PreviousSongRating : PreviousSongRating = PreviousSong.Rating
Dim Ret : Ret = GetForm().ShowModal
If Ret = 2 Then ' If Cancel
PreviousSong.Rating = PreviousSongRating
PreviousSong.UpdateDB
End If
SDB.Player.Play
End If
End If
Set PreviousSong = SDB.Player.CurrentSong
End Sub
Function GetForm
Set GetForm = SDB.Objects("RatePlayedSong_Form")
If GetForm Is Nothing Then
Dim bheight : bheight = 23
Dim bwidth : bwidth = 35
Set GetForm = SDB.UI.NewForm
GetForm.Common.SetRect 100, 100, 360, 190
GetForm.BorderStyle = 3 ' Resizable
GetForm.FormPosition = 4 ' Screen Center
GetForm.SavePositionName = "RatePlayedSong_Form"
GetForm.Caption = "Rate Previously Played Song"
Set SDB.Objects("RatePlayedSong_Form") = GetForm
Dim lblTit : Set lblTit = SDB.UI.NewLabel(GetForm)
lblTit.Caption = "Title: " & PreviousSong.Title
lblTit.Common.Left = 10
lblTit.Common.Top = 14
Dim lblArt : Set lblArt = SDB.UI.NewLabel(GetForm)
lblArt.Caption = "Artist: " & PreviousSong.ArtistName
lblArt.Common.Left = 10
lblArt.Common.Top = lblTit.Common.Top + lblTit.Common.Height +7
Dim i, btnPcnt
For i = 0 To 10
Set btnPcnt = SDB.UI.NewButton(GetForm)
btnPcnt.Caption = BtnCapt(i)
btnPcnt.Common.MinHeight = i
btnPcnt.Common.Height = bheight
btnPcnt.Common.Width = bwidth
btnPcnt.Common.Top = lblArt.Common.Top + lblArt.Common.Height + 10 + (i MOD 2)*bheight
btnPcnt.Common.Left = 50 + i*(bwidth - bwidth/2 + 5)
Script.RegisterEvent btnPcnt.Common, "OnClick", "RateButton_OnClick"
Next
Dim btnOk : Set btnOk = SDB.UI.NewButton(GetForm)
btnOk.Caption = "OK"
btnOk.Common.SetRect GetForm.Common.Width/2 - 155, lblArt.Common.Top + lblArt.Common.Height + 10 + 2*bheight + 10 + 5, 150, bheight
btnOk.Default = True
btnOk.ModalResult = 1
Dim btnCancel : Set btnCancel = SDB.UI.NewButton(GetForm)
btnCancel.Caption = "Cancel Changes"
btnCancel.Common.SetRect GetForm.Common.Width/2 + 5, BtnOK.Common.Top, 150, bheight
btnCancel.Cancel = True
btnCancel.ModalResult = 2
End If
End Function
Sub RateButton_OnClick(RateButton)
PreviousSong.Rating = 100 - 10 * RateButton.Common.MinHeight
PreviousSong.UpdateDB
End Sub
Sub MI_OnClick(MI)
MI.Checked = Not MI.Checked
SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = MI.Checked
End Sub
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
-
- Posts: 11
- Joined: Wed Sep 12, 2007 5:38 pm
- Location: NY, USA - BP, HUN
Small change to fix a minor annoyance
Hello all, especially Steegy,
Thanks for the script. I find it quite useful, but there was this annoying behavior: it would show the title and artist of the first song that had to be rated and it would not update afterwards.
I made some small modifications to the GetForm function (commented all he changes). Here it is - just swap it out with the current 'GetForm' with the help of a text editor to try it.
Thanks for the script. I find it quite useful, but there was this annoying behavior: it would show the title and artist of the first song that had to be rated and it would not update afterwards.
I made some small modifications to the GetForm function (commented all he changes). Here it is - just swap it out with the current 'GetForm' with the help of a text editor to try it.

Code: Select all
Function GetForm
Set GetForm = SDB.Objects("RatePlayedSong_Form")
' Initialize the two variables here because they will be used in both sides of the conditional
Dim lblTit
Dim lblArt
If GetForm Is Nothing Then
Dim bheight : bheight = 23
Dim bwidth : bwidth = 35
Set GetForm = SDB.UI.NewForm
GetForm.Common.SetRect 100, 100, 360, 190
GetForm.BorderStyle = 3 ' Resizable
GetForm.FormPosition = 4 ' Screen Center
GetForm.SavePositionName = "RatePlayedSong_Form"
GetForm.Caption = "Rate Previously Played Song"
Set SDB.Objects("RatePlayedSong_Form") = GetForm
Set lblTit = SDB.UI.NewLabel(GetForm)
lblTit.Caption = "Title: " & PreviousSong.Title
lblTit.Common.Left = 10
lblTit.Common.Top = 14
' Initialize a new named label object, so we can refer to it later
Set SDB.Objects("RatePlayedSong_Form_lblTit") = lblTit
Set lblArt = SDB.UI.NewLabel(GetForm)
lblArt.Caption = "Artist: " & PreviousSong.ArtistName
lblArt.Common.Left = 10
lblArt.Common.Top = lblTit.Common.Top + lblTit.Common.Height +7
' same as above
Set SDB.Objects("RatePlayedSong_Form_lblArt") = lblArt
Dim i, btnPcnt
For i = 0 To 10
Set btnPcnt = SDB.UI.NewButton(GetForm)
btnPcnt.Caption = BtnCapt(i)
btnPcnt.Common.MinHeight = i
btnPcnt.Common.Height = bheight
btnPcnt.Common.Width = bwidth
btnPcnt.Common.Top = lblArt.Common.Top + lblArt.Common.Height + 10 + (i MOD 2)*bheight
btnPcnt.Common.Left = 50 + i*(bwidth - bwidth/2 + 5)
Script.RegisterEvent btnPcnt.Common, "OnClick", "RateButton_OnClick"
Next
Dim btnOk : Set btnOk = SDB.UI.NewButton(GetForm)
btnOk.Caption = "OK"
btnOk.Common.SetRect GetForm.Common.Width/2 - 155, lblArt.Common.Top + lblArt.Common.Height + 10 + 2*bheight + 10 + 5, 150, bheight
btnOk.Default = True
btnOk.ModalResult = 1
Dim btnCancel : Set btnCancel = SDB.UI.NewButton(GetForm)
btnCancel.Caption = "Cancel Changes"
btnCancel.Common.SetRect GetForm.Common.Width/2 + 5, BtnOK.Common.Top, 150, bheight
btnCancel.Cancel = True
btnCancel.ModalResult = 2
Else
' this bit is for when the form appears for not the first time
' capture the named label objects in lblTit and lblArt and update their content
Set lblTit = SDB.Objects("RatePlayedSong_Form_lblTit")
lblTit.Caption = "Title: " & PreviousSong.Title
Set lblArt = SDB.Objects("RatePlayedSong_Form_lblArt")
lblArt.Caption = "Artist: " & PreviousSong.ArtistName
End If
End Function
HTH,
Gábor
Gábor
Oops. So my "updated" version wasn't completely fine.
Thanks for the update.
Thanks for the update.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
Re: Is it possible..
This is a GREAT script for those who rate songs. My problem was that I found myself distracted and not listening to the songs every time. I needed a replay button. So I eliminated the OK button and replaced it with a Replay Song button. Now if you click a rating, the song is rated and the form exits. If you click replay song, the song replays and the form exits.
I could have never done this from scratch, so thank you Steegy and others.
I could have never done this from scratch, so thank you Steegy and others.
Code: Select all
'====================================================================================
' MEDIAMONKEY SCRIPT: RatePlayedSong v1.1 (last updated 2007-07-04) by Steegy
'
' Shows a dialog when a song is started, to rate the previous played song.
'====================================================================================
Option Explicit
Dim BtnCapt : BtnCapt = Array("5", "4½", "4", "3½", "3", "2½", "2", "1½", "1", "½", "0")
Dim Rpl
Dim PreviousSong
Dim DoneSettingRating
Dim MI
Sub OnStartup
If SDB.IniFile.StringValue("RatePlayedSong", "Enabled") = "" Then
SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = True
End If
Set MI = SDB.UI.AddMenuItem(SDB.UI.Menu_Scripts, 1, 1)
MI.Caption = "Rate Played Song"
MI.Hint = "Activate/deactivate dialog for rating played song"
MI.Checked = SDB.IniFile.BoolValue("RatePlayedSong", "Enabled")
Script.RegisterEvent MI, "OnClick", "MI_OnClick"
Script.RegisterEvent SDB, "OnPlay", "RatePlayedSong"
End Sub
Sub RatePlayedSong
If Rpl = 1 Then
Rpl = 0
Exit Sub
Else
If Not IsEmpty(PreviousSong) And MI.Checked Then
If PreviousSong.Rating = -1 Then
SDB.Player.Pause
SDB.Player.PlaybackTime = 0
Dim PreviousSongRating : PreviousSongRating = PreviousSong.Rating
Dim Ret : Ret = GetForm().ShowModal
If Ret <> 1 Then ' If Cancel or Rated
SDB.Player.Play
End If
End If
End If
End If
Set PreviousSong = SDB.Player.CurrentSong
End Sub
Function GetForm
Set GetForm = SDB.Objects("RatePlayedSong_Form")
' Initialize the two variables here because they will be used in both sides of the conditional
Dim lblTit
Dim lblArt
If GetForm Is Nothing Then
Dim bheight : bheight = 23
Dim bwidth : bwidth = 35
Set GetForm = SDB.UI.NewForm
GetForm.Common.SetRect 100, 100, 360, 190
GetForm.BorderStyle = 3 ' Resizable
GetForm.FormPosition = 4 ' Screen Center
GetForm.SavePositionName = "RatePlayedSong_Form"
GetForm.Caption = "Rate Previously Played Song"
Set SDB.Objects("RatePlayedSong_Form") = GetForm
Set lblTit = SDB.UI.NewLabel(GetForm)
lblTit.Caption = "Title: " & PreviousSong.Title
lblTit.Common.Left = 10
lblTit.Common.Top = 14
' Initialize a new named label object, so we can refer to it later
Set SDB.Objects("RatePlayedSong_Form_lblTit") = lblTit
Set lblArt = SDB.UI.NewLabel(GetForm)
lblArt.Caption = "Artist: " & PreviousSong.ArtistName
lblArt.Common.Left = 10
lblArt.Common.Top = lblTit.Common.Top + lblTit.Common.Height +7
' same as above
Set SDB.Objects("RatePlayedSong_Form_lblArt") = lblArt
Dim i, btnPcnt
For i = 0 To 10
Set btnPcnt = SDB.UI.NewButton(GetForm)
btnPcnt.Caption = BtnCapt(i)
btnPcnt.Common.MinHeight = i
btnPcnt.Common.Height = bheight
btnPcnt.Common.Width = bwidth
btnPcnt.Common.Top = lblArt.Common.Top + lblArt.Common.Height + 10 + (i MOD 2)*bheight
btnPcnt.Common.Left = 50 + i*(bwidth - bwidth/2 + 5)
btnPcnt.ModalResult = 3
Script.RegisterEvent btnPcnt.Common, "OnClick", "RateButton_OnClick"
Next
Dim btnrepl : Set btnrepl = SDB.UI.NewButton(GetForm)
btnrepl.Caption = "Replay Song"
btnrepl.Common.SetRect GetForm.Common.Width/2 - 155, lblArt.Common.Top + lblArt.Common.Height + 10 + 2*bheight + 10 + 5, 150, bheight
btnrepl.Default = True
btnrepl.ModalResult = 1
Script.RegisterEvent btnrepl.Common, "OnClick", "ReplaySong_OnClick"
Dim btnCancel : Set btnCancel = SDB.UI.NewButton(GetForm)
btnCancel.Caption = "Cancel Changes"
btnCancel.Common.SetRect GetForm.Common.Width/2 + 5, Btnrepl.Common.Top, 150, bheight
btnCancel.Cancel = True
btnCancel.ModalResult = 2
Else
' this bit is for when the form appears for not the first time
' capture the named label objects in lblTit and lblArt and update their content
Set lblTit = SDB.Objects("RatePlayedSong_Form_lblTit")
lblTit.Caption = "Title: " & PreviousSong.Title
Set lblArt = SDB.Objects("RatePlayedSong_Form_lblArt")
lblArt.Caption = "Artist: " & PreviousSong.ArtistName
End If
End Function
Sub RateButton_OnClick(RateButton)
PreviousSong.Rating = 100 - 10 * RateButton.Common.MinHeight
PreviousSong.UpdateDB
End Sub
Sub MI_OnClick(MI)
MI.Checked = Not MI.Checked
SDB.IniFile.BoolValue("RatePlayedSong", "Enabled") = MI.Checked
End Sub
'Add Replay Song Script
Sub ReplaySong_OnClick(ReplaySong)
Rpl = 1
SDB.Player.Previous
End Sub
Re: Is it possible..
Replay isnt working, its only closing script window and song remains stopped
Re: Is it possible..
Hi, is it possible to customize this script so that it keeps playing a song until the song gets a rate? I've been tinkering with the script with no luck.