Auto Rating of Songs & Radio Announcer v5.02 [Script]

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo » Fri Apr 06, 2007 10:25 am

It's a bit tight there in the Option Sheet for sliders.

At the moment I have a version being compatible with both MM2.4+ and MM3 so I'll just clean that one up a bit, and most likely post it here after some testing.

In this version you can set the delay in milliseconds like

Code: Select all

Set RSN=SDB.CreateTimer(1200)
Changing 1200 to 5000 will make it rate the song at 5 seconds instead of 1.2 seconds.

Ops... just realized I misread your first post.. Delay for the Announcing part.... yes, why not, can add a timer for that too. Especially handy for MM3 that have build-in cross fading maybe. Will have to try that out too.

An alternative is maybe to try out the 'Pause While Speaking'.... but that might be a bit 'rough'.. Will add that timer..

Added: Might as well put the announcer in a separate option sheet, that allow more options with the speaking part. I'd like to finalize a RSS reader thingy I played with before, that allow breaks in the music for a bit of news reading.
Image

Psyker7
Posts: 254
Joined: Sat Mar 03, 2007 8:00 am

Post by Psyker7 » Fri Apr 06, 2007 6:40 pm

O,o
Your song ends.... "And in breaking news: ...."

That would be quite amusing.

Great script btw, started using it a few months ago, mainly for the reducing rating when I skip a song, and the rating on first play.

Keep it up =)

DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo » Sat Apr 07, 2007 12:46 am

Nice with some inspiration, thank you. :)

I have this MM2.4+ and MM3 version under testing and if anyone should feel bothered testing it, it is pasted in below.

If tested as a replacement for v5.02 in MM2.4+, the section [AutoRateSongs] in the MediaMonkey.ini file will be messed up... so I think at this point it is best to just use it as a test together with MM3 Alpha. A final step is to create an install routine that translate the .ini settings, and that part is not done yet. Another thing is that the AutoRateSongsOptionSheet.vbs is not in use with this version.

I'm not sure if this version works 100% in all situations... it's just here if anyone should feel in an experimental mood. The Delay for the Radio Announcer is in this version.

Two scripts.
1. Scripts\Auto\AutoRateSongs.vbs
2. Scripts\RadioAnnouncer.vbs

ToDo:
Give full control of when a song is considered played or not.
Install script that translate settings.
RSS Reader section that reads news. (done, but not in script yet)
Test everything properly.

TEST 2 submittet, a couple of bug fixes

Code: Select all

'-----------------------------------------------------------------------------------------
'\Program Files\MediaMonkey\Scripts\Auto\AutoRateSongs.vbs
' TEST 2
'-----------------------------------------------------------------------------------------
Private Const M_0="Auto Rating"
Private Const M_1="Radio Announcer"
Private Const M_2="Turn both off for  5 minutes"
Private Const M_3="Turn both off for 15 minutes"
Private Const M_4="Turn both off for 30 minutes"

Private Const O  ="AutoRateSongs"
Private Const T  ="AutoRateSongsPSTimer"
Private Const L  ="AutoRateSongsSMTimer"
Private Const P  ="AutoRateSongsPLTimer"
Private Const R  ="AutoRateSongsRSTimer"
Select Case SDB.VersionHi
       Case 2
            strIDPlayed = "Played.IdPlay"
       Case Else
            strIDPlayed = "Played.IDPlayed"
End Select   
'-------------------------------------------------------------------------------------
Sub OnStartup
    CreateGUI
    Set Start=SDB.CreateTimer(500)
    Script.RegisterEvent Start,"OnTimer","StartWhenReady"
    End Sub
Sub StartWhenReady(Tmr)
    If  Not SDB.isRunning Then Exit Sub
    Script.UnRegisterEvents Tmr
    RefreshObject
    SetTimers
    StopTimers
    Script.RegisterEvent SDB, "OnPlay"  , "SongStartPlaying"
    Script.RegisterEvent SDB, "OnPause" , "SongPaused"
    Script.RegisterEvent SDB, "OnStop"  , "SongStopped"
    Script.RegisterEvent SDB, "OnSeek"  , "SongStopped"
    If SDB.Player.isPlaying Then SongStartPlaying
End Sub
'-------------------------------------------------------------------------------------
Sub SongStartPlaying
    StopTimers
    Set Mem=SDB.Objects(O)
    If  Mem.Item(10) And Mem.Item(2)>0 Then SDB.Objects(R).Enabled=True
    If  Mem.Item(11) Then RadioAnnouncer Mem.Item(12),Mem.Item(9),Mem.Item(50)
    SDB.Objects(L).Interval=Mem.Item(46)
    SDB.Objects(L).Enabled=True
    End Sub
Sub SongPlaying(Tmr)
    Set Mem=SDB.Objects(O)
        Mem.Item(0)=SDB.Player.PlayBackTime
        Mem.Item(1)=SDB.Player.CurrentSongIndex
        Mem.Item(2)=SDB.Player.CurrentSong.ID
    End Sub
Sub SongPaused
    If SDB.Player.isPaused Then
       StopTimers
    Else
       StartTimers
    End If
    End Sub
Sub SongStopped
    StopTimers
    SDB.Objects(O).Item(2)=Empty
    End Sub
Sub PlayListEnded(Tmr)
    Tmr.Enabled=False
    StopTimers
    If Not SDB.Player.isPlaying Then
        SDB.Objects(O).Item(0)=SDB.Player.CurrentSong.SongLength
        RateSong
    End If
End Sub
'-------------------------------------------------------------------------------------
Sub ReadSong(Tmr)
    SDB.Objects(L).Enabled=False
    Set Mem=SDB.Objects(O)
    If   SDB.Player.CurrentSong Is Nothing Or _
         SDB.Player.CurrentSong.ID < 1     Then
         
    Else
         StartTimers
         SID=SDB.Player.CurrentSong.ID
         SQL="SELECT Count(Played.IDSong),Max("&strIDPlayed&") "&_
             "From Played WHERE Played.IDSong="&SID
         Set QRY=SDB.Database.OpenSQL(SQL)
             x=CInt(QRY.ValueByIndex(0))
             y=QRY.ValueByIndex(1)
             If x=0 Then y=0
             Mem.Item(3)=x
             Mem.Item(4)=y
    End If
End Sub 
'-------------------------------------------------------------------------------------
Sub RateSongNow(Tmr)
    Tmr.Enabled=False
    RateSong
End Sub

Sub RateSong
    Set Mem=SDB.Objects(O)
    Set dbT=SDB.Player.CurrentPlaylist
    On  Error Resume Next
    Set Sng=dbT.Item(Mem.Item(1))
    If  Error<>0 Then
    On  Error Goto 0
        EmptyMem
        Exit Sub
    End If
    If  Not Sng.ID=Mem.Item(2)                    Or _
        Mem.Item(48) > Sng.SongLength             Or _
        Mem.Item(13) And Sng.Mood&Sng.Occasion>"" Then
        EmptyMem
        Exit Sub
    End If
    CurRate=Sng.Rating
    
    NR=-2

    If     Mem.Item(0)<=(Sng.SongLength*Mem.Item(47))          Then   ' Skipped
                 If     CurRate=0                              Then
                 ElseIf CurRate>0 And Mem.Item(0)>Mem.Item(49) Then
                 ElseIf CurRate<0                              Then
          NR=Mem.Item(44)
                 ElseIf Mem.Item(45)>0 Then
                        If   CurRate<=Mem.Item(45) Then
          NR=0
                        Else   
          NR=CurRate-Mem.Item(45)
                        End If
                 End If
    Else                                                          ' Played
                 CalRate=cRate(Mem.Item(4),Mem.Item(2),Mem.Item(40),Mem.Item(19))
                 
                 If CurRate<0 Then                                ' Unrated
                          If CalRate>Mem.Item(43) Then
          NR=CalRate
                          Else
          NR=Mem.Item(43)
                          End If
                 ElseIf Mem.Item(03)=0 Then                       ' Unplayed
      
                        
                        If     CurRate=>Mem.Item(44) And CurRate<Mem.Item(43) Then
                                   If CalRate>Mem.Item(43) Then
          NR=CalRate
                                   Else
          NR=Mem.Item(43)
                                   End If
                        ElseIf CurRate>=Mem.Item(43) Then
                                   If CalRate>CurRate Then 
          NR=CalRate
                                   End If
                        Else 
          NR=Recovery(CurRate)
                        End If
      
                 
                 
                 ElseIf CurRate>=0 And CurRate<Mem.Item(44) Then ' Rated low 
          NR=Recovery(CurRate)
                 ElseIf CalRate>CurRate Then                     ' Unchanged
          NR=CalRate
                 End If
    End If
    
    EmptyMem
    
    If NR>-2 Then 
       Sng.Rating=NR
       Sng.UpdateDB
    End If
End Sub

Function Recovery(PRR)
         If PRR Mod 20=0 Then
             Recovery= PRR+20
         ElseIf PRR Mod 20=10 Then
             Recovery= PRR+10
         Else 
             PRR=PRR+24
             Recovery=PRR-(PRR Mod 20)
        End If
    End Function   

Sub EmptyMem
    Set Mem=SDB.Objects(O)
    For i = 0 To 8:Mem.Item(i)=Empty:Next 
End Sub

'------------------------------------------------------------------------------------- 
Sub UpdatePlayed(SID)
    If SID<1 Then Exit Sub
    SDB.Database.ExecSQL("INSERT INTO Played (IDSong,PlayDate) "&_
                         "VALUES ("&SID&","&CDbl(Now)&")")
End Sub
'------------------------------------------------------------------------------------- 
Function cRate(LastPos,SID,rType,cDays)
    If  rType=1 Then 
        CurPos=SDB.Database.OpenSQL("Select Max("&strIDPlayed&") From Played").ValueByIndex(0)
        If LastPos>0 Then
           cRate=RepeatPlayRate(CurPos-LastPos)
        Else
           cRate=-1
        End If
    Else  
        SQL="SELECT Count(Played.IDSong) FROM Played WHERE Played.IDSong = "&SID&_
            " AND Played.PlayDate >= "&CDbl(Now)-cDays
        cRate=PlayCountRate(CInt(SDB.Database.OpenSQL(SQL).ValueByIndex(0)))
    End If     
End Function

Function isCounted(SID,WAS)
         SQL="SELECT Count(Played.IDSong) FROM Played WHERE Played.IDSong = "& SID
         isCounted=CInt(SDB.Database.OpenSQL(SQL).ValueByIndex(0))
         If isCounted=WAS Then isCounted=0
End Function


'-------------------------------------------------------------------------------------
Sub StartTimers
    Set Mem=SDB.Objects(O)
    x=SDB.Objects(O).Item(46)-SDB.Player.PlaybackTime
    If x>0 Then 
       SDB.Objects(L).Interval=x
       SDB.Objects(L).Enabled=True
       Exit Sub
    Else
       SDB.Objects(L).Enabled=False
       SDB.Objects(T).Enabled=True
    End If 

    If SDB.Player.CurrentPlaylist.Count-1=SDB.Player.CurrentSongIndex Then
       SDB.Objects(P).Interval=SDB.Player.CurrentSongLength-SDB.Player.PlaybackTime+1500
       SDB.Objects(P).Enabled=True
    End If
    End Sub    
Sub StopTimers
    SDB.Objects(T).Enabled=False
    SDB.Objects(L).Enabled=False
    SDB.Objects(P).Enabled=False
    End Sub 
Sub SetTimers
    Set CST=SDB.CreateTimer(500)
        Script.RegisterEvent CST, "OnTimer", "SongPlaying"
        SDB.Objects(T)=CST
    Set RCS=SDB.CreateTimer(1000)
        Script.RegisterEvent RCS, "OnTimer", "ReadSong"
        SDB.Objects(L)=RCS
    Set PLE=SDB.CreateTimer(1000)
        Script.RegisterEvent PLE, "OnTimer", "PlayListEnded"
        SDB.Objects(P)=PLE  
    Set RSN=SDB.CreateTimer(1200)
        Script.RegisterEvent RSN, "OnTimer", "RateSongNow"
        SDB.Objects(R)=RSN
End Sub
'-------------------------------------------------------------------------------------
Sub RadioAnnouncer(PWS,PAN,CMD)
    If  SDB.Player.CurrentSong Is Nothing Then Exit Sub
    If  PWS Then SDB.Player.Pause
    Set Sng=SDB.Player.CurrentSong
    With CreateObject("WScript.Shell")
        If     Sng.ArtistName=PAN Then 
               .Run CMD&" """& Sng.Title &""".",0,False
        Else   
               .Run CMD&" """& Sng.ArtistName &", "& Sng.Title &""".",0,False
        End If 
    End With
    SDB.Objects(O).Item(9)=Sng.ArtistName
End Sub  

'-------------------------------------------------------------------------------------
Function Lbl(S,L,T,W,H,N)
    With SDB.UI.NewLabel(S):.Common.SetRect L,T,W,H:.Caption=N:End With
    End Function
Function Drd(S,L,T,W,H,c,A1,A2)
    With SDB.UI.NewDropDown(S):.Common.SetRect L,T,W,H
        .Common.ControlName=c:.AddItem A1:.AddItem A2:.ItemIndex=0
        .UseScript=Script.ScriptPath
        .OnSelectFunc="S40"
      If SDB.IniFile.StringValue(o,"S40")>"" Then .ItemIndex=_
         SDB.IniFile.IntValue(o,"S40")
    End With
    End Function
Function Chk(S,L,T,W,H,c,N,B)
    With SDB.UI.NewCheckBox(S):.Common.SetRect L,T,W,H
         .Common.ControlName=c:.Caption=N:.Checked=B
       If SDB.IniFile.StringValue(o,c)>"" Then _
         .Checked=SDB.IniFile.BoolValue(o,c)
    End With
    End Function
Function Spn(S,L,T,W,H,c,V,N,X)
    With SDB.UI.NewSpinEdit(S):.Common.SetRect L,T,W,H
        .Common.ControlName=c:.MinValue=N:.MaxValue=X:.Value=V
     If SDB.IniFile.StringValue(o,c)>"" Then _
        .Value=SDB.IniFile.IntValue(o,c)
    End With
    End Function
Function Trb(S,L,T,W,H,c,V,N,X)
    With SDB.UI.NewTrackBar(S):.Common.SetRect L,T,W,H
        .Common.ControlName=c:.MinValue=N:.MaxValue=X:.Value=V
        .Common.Hint="Unrated song is also considered 'first play'"
      If SDB.IniFile.StringValue(o,c)>"" Then _
        .Value=SDB.IniFile.IntValue(o,c)
    End With
    End Function
Function DDV(S,L,T,W,H,c)
     Set Ini=SDB.IniFile
    With SDB.UI.NewDropDown(S):.Common.SetRect L,T,W,H
        .Common.ControlName=c:.Style=2
        .UseScript=Script.ScriptPath
        .OnSelectFunc="D10"
      On Error Resume Next
     Set SAPI5=CreateObject("Sapi.SpVoice")
      If SAPI5 Is Nothing Then 
        .AddItem "SAPI5 n.a."
        .ItemIndex=0
         SDB.IniFile.StringValue(o,c)="SAPI5 n.a."
      Else
        For i=0 To SAPI5.GetVoices.Count-1
            .AddItem SAPI5.GetVoices.Item(i).GetAttribute("Name")
        Next
        .ItemIndex=0
         X=Ini.StringValue(o,c)
             If X="" Or X="SAPI5 n.a." Then 
                Ini.StringValue(o,c)=.ItemText(0)
         ElseIf X<>.ItemText(0) Then
                For i=1 To .ItemCount-1
                  If .ItemText(i)=X Then .ItemIndex=i
                Next
         End If
      End If
    End With
    End Function
Function Mnu(S,c,I,N)
    Set Mnu=SDB.UI.AddMenuItem(S,0,0)
        Mnu.Caption=N
        Mnu.UseScript=Script.ScriptPath
        Mnu.OnClickFunc=c
        Mnu.Checked=False
            If I="Obj" Then
               If SDB.Objects(N) Is Nothing Then 
                  SDB.Objects(N)=Mnu
               Else
                  Mnu.Checked=SDB.Objects(N)
               End If
        ElseIf I<>"Non" Then
               If SDB.Objects(o&N) Is Nothing Then 
                  Mnu.Checked=SDB.IniFile.BoolValue(o,I)
                  SDB.Objects(o&N)=Mnu
               Else
                  Mnu.Checked=SDB.Objects(o&N)
               End If
        End If
    End Function
Function PlayCountRate(dbC)
    Set Mem=SDB.Objects(O)
        If Mem.Item(20)>0 And dbC>=Mem.Item(20) Then
           PlayCountRate=100
    ElseIf Mem.Item(21)>0 And dbC>=Mem.Item(21) Then
           PlayCountRate=090
    ElseIf Mem.Item(22)>0 And dbC>=Mem.Item(22) Then
           PlayCountRate=080
    ElseIf Mem.Item(23)>0 And dbC>=Mem.Item(23) Then
           PlayCountRate=070
    ElseIf Mem.Item(24)>0 And dbC>=Mem.Item(24) Then
           PlayCountRate=060
    ElseIf Mem.Item(25)>0 And dbC>=Mem.Item(25) Then
           PlayCountRate=050
    ElseIf Mem.Item(26)>0 And dbC>=Mem.Item(26) Then
           PlayCountRate=040
    ElseIf Mem.Item(27)>0 And dbC>=Mem.Item(27) Then
           PlayCountRate=030
    ElseIf Mem.Item(28)>0 And dbC>=Mem.Item(28) Then
           PlayCountRate=020
    ElseIf Mem.Item(29)>0 And dbC>=Mem.Item(29) Then
           PlayCountRate=010
    Else : PlayCountRate=-1
    End If
    End Function
Function RepeatPlayRate(LP)
    Set Mem=SDB.Objects(O)
    If     Mem.Item(30)>0 And LP<=Mem.Item(30) Then
           RepeatPlayRate=100
    ElseIf Mem.Item(31)>0 And LP<=Mem.Item(31) Then
           RepeatPlayRate=090
    ElseIf Mem.Item(32)>0 And LP<=Mem.Item(32) Then
           RepeatPlayRate=080
    ElseIf Mem.Item(33)>0 And LP<=Mem.Item(33) Then
           RepeatPlayRate=070
    ElseIf Mem.Item(34)>0 And LP<=Mem.Item(34) Then
           RepeatPlayRate=060
    ElseIf Mem.Item(35)>0 And LP<=Mem.Item(35) Then
           RepeatPlayRate=050
    ElseIf Mem.Item(36)>0 And LP<=Mem.Item(36) Then
           RepeatPlayRate=040
    ElseIf Mem.Item(37)>0 And LP<=Mem.Item(37) Then
           RepeatPlayRate=030
    ElseIf Mem.Item(38)>0 And LP<=Mem.Item(38) Then
           RepeatPlayRate=020
    ElseIf Mem.Item(39)>0 And LP<=Mem.Item(39) Then
           RepeatPlayRate=010
    Else:  RepeatPlayRate=-1
    End If 
    End Function
Function SN
    Set Mem=SDB.Objects(O)
           CI=Mem.Item(15)
           WN=Int(DatePart("ww",Now))
        If WN<12 Then
        If CI Then SN="Winter" Else SN="Summer"
    ElseIf WN<25 Then
        If CI Then SN="Spring" Else SN="Autumn"
    ElseIf WN<38 Then
        If CI Then SN="Summer" Else SN="Winter"
    ElseIf WN<51 Then
        If CI Then SN="Autumn" Else SN="Spring"
    Else
        If CI Then SN="Winter" Else SN="Summer"
    End If
    End Function
Function TD
           TN=DatePart("h",Now)
        If TN< 6 Then 
           TD=" night "
    ElseIf TN< 9 Then
           TD=" morning "
    ElseIf TN<17 Then
           TD=" daytime "
    ElseIf TN<19 Then
           TD=" dinner "
    ElseIf TN<24 Then
           TD=" evening "
    End If
    End Function

Function MNo(txt)
    With New RegExp
        .Pattern="\d+"
    MNo=.Execute(txt).item(0)
    End With
    MNo=CInt(MNo)
End Function
   
'-------------------------------------------------------------------------------------
Sub onLoad(Frm)
    Set Rpn=SDB.UI.NewPanel(Frm):Rpn.Common.SetRect 000,000,230,130
    Chk Rpn,010,010,130,20,"C10","Enable Auto Rating",False
    Drd Rpn,010,040,190,20,"S19","Use the Play Count Table","Use the Repeat Play Table"
    Chk Rpn,010,083,220,20,"C14","Time Stamp to Custom2 when upgraded",False
    Chk Rpn,010,103,220,20,"C15","Northern Hemisphere Seasons in Stamp",True
    Chk Rpn,010,063,220,20,"C13","Ignore songs with Mood/Occasion values",False
    Set Rpn=SDB.UI.NewPanel(Frm):Rpn.Common.SetRect 232,000,230,130
    Chk Rpn,010,010,140,20,"C11","Enable Radio Announcer",False
    Chk Rpn,010,103,150,20,"C12","Pause music while speaking",False
    Lbl Rpn,057,064,100,19,"Volume"
    Spn Rpn,095,060,048,20,"S18",0,0,10000
    Lbl Rpn,148,064,100,19,"Delay"
    Spn Rpn,010,060,042,20,"S41",100,0,100
    Lbl Rpn,057,083,100,20,"Speed"
    Spn Rpn,010,080,042,20,"S42",0,-10,10
    DDV Rpn,010,040,170,20,"D10"
    Set Rpn=SDB.UI.NewPanel(Frm):Rpn.Common.SetRect 000,131,230,192
    Lbl Rpn,010,010,150,20,"Rating when fully played first time"
    Trb Rpn,000,030,230,40,"S43",6,0,10
    Lbl Rpn,011,068,020,20,"0":Lbl Rpn,049,068,020,20,"1"
    Lbl Rpn,091,068,020,20,"2":Lbl Rpn,132,068,020,20,"3"
    Lbl Rpn,174,068,020,20,"4":Lbl Rpn,215,068,020,20,"5"
    Lbl Rpn,010,098,150,20,"Rating when skipped at first play"
    Trb Rpn,000,118,230,40,"S44",4,0,10
    Lbl Rpn,011,156,020,20,"0":Lbl Rpn,049,156,020,20,"1"
    Lbl Rpn,091,156,020,20,"2":Lbl Rpn,132,156,020,20,"3"
    Lbl Rpn,174,156,020,20,"4":Lbl Rpn,215,156,020,20,"5"
    Set Rpn=SDB.UI.NewPanel(Frm):Rpn.Common.SetRect 232,131,230,192
    Lbl Rpn,010,010,150,20,"Skip Monitor"
    Lbl Rpn,010,038,150,20,"Start after"
    Spn Rpn,070,035,040,20,"S46", 10,1,50
    Lbl Rpn,115,038,150,20,"seconds play,"
    Lbl Rpn,010,058,150,20,"and stop at"
    Spn Rpn,070,055,040,20,"S47",90,20,96
    Lbl Rpn,115,058,150,20,"% of the song."
    Lbl Rpn,010,078,100,20,"Timeout at"
    Spn Rpn,070,075,040,20,"S49",4,1,90
    Lbl Rpn,115,078,100,20,"minutes."
    Lbl Rpn,010,098,100,20,"Ignore  < "
    Spn Rpn,070,095,040,20,"S48",20,5,90
    Lbl Rpn,115,098,100,20,"second songs."
    Lbl Rpn,010,123,150,20,"Skip Reduction Rate"
    Trb Rpn,110,118,066,40,"S45",1,0,2
    Lbl Rpn,119,156,100,20,"0"
    Lbl Rpn,162,156,100,20,"1"
    End Sub
Sub onLoad1(Frm)
    Lbl Frm,020,023,300,20,"Play Count Rating Table"
    Lbl Frm,020,048,300,20,"Count multi-plays over the last"
    Spn Frm,185,045,040,20,"S19",2,1,1000
    Lbl Frm,230,048,100,20,"days"
    Lbl Frm,020,073,300,20,"Minimum 5.0 Stars when reached"
    Spn Frm,185,070,040,20,"S20",7,0,500
    Lbl Frm,230,073,300,20,"plays"
    Lbl Frm,020,093,300,20,"Minimum 4.5 Stars when reached"
    Spn Frm,185,090,040,20,"S21",5,0,500
    Lbl Frm,230,093,300,20,"plays"
    Lbl Frm,020,113,300,20,"Minimum 4.0 Stars when reached"
    Spn Frm,185,110,040,20,"S22",4,0,500
    Lbl Frm,230,113,300,20,"plays"
    Lbl Frm,020,133,300,20,"Minimum 3.5 Stars when reached"
    Spn Frm,185,130,040,20,"S23",3,0,500
    Lbl Frm,230,133,300,20,"plays"
    Lbl Frm,020,153,300,20,"Minimum 3.0 Stars when reached"
    Spn Frm,185,150,040,20,"S24",2,0,500
    Lbl Frm,230,153,300,20,"plays"
    Lbl Frm,020,173,300,20,"Minimum 2.5 Stars when reached"
    Spn Frm,185,170,040,20,"S25",1,0,500
    Lbl Frm,230,173,300,20,"plays"
    Lbl Frm,020,193,300,20,"Minimum 2.0 Stars when reached"
    Spn Frm,185,190,040,20,"S26",0,0,500
    Lbl Frm,230,193,300,20,"plays"
    Lbl Frm,020,213,300,20,"Minimum 1.5 Stars when reached"
    Spn Frm,185,210,040,20,"S27",0,0,500
    Lbl Frm,230,213,300,20,"plays"
    Lbl Frm,020,233,300,20,"Minimum 1.0 Stars when reached"
    Spn Frm,185,230,040,20,"S28",0,0,500
    Lbl Frm,230,233,300,20,"plays"
    Lbl Frm,020,253,300,20,"Minimum 0.5 Stars when reached"
    Spn Frm,185,250,040,20,"S29",0,0,500
    Lbl Frm,230,253,300,20,"plays"
    End Sub
Sub onLoad2(Frm)
    Lbl Frm,020,023,300,20,"Repeat Play Rating Table"
    Lbl Frm,020,053,300,20,"Minimum 5.0 Stars when repeated within the last"
    Spn Frm,260,050,070,20,"S30",00030,1,999999
    Lbl Frm,336,053,100,20,"plays"
    Lbl Frm,020,073,300,20,"Minimum 4.5 Stars when repeated within the last"
    Spn Frm,260,070,070,20,"S31",01500,0,999999
    Lbl Frm,336,073,100,20,"plays"
    Lbl Frm,020,093,300,20,"Minimum 4.0 Stars when repeated within the last"
    Spn Frm,260,090,070,20,"S32",03250,0,999999
    Lbl Frm,336,093,100,20,"plays"
    Lbl Frm,020,113,300,20,"Minimum 3.5 Stars when repeated within the last"
    Spn Frm,260,110,070,20,"S33",07500,0,999999
    Lbl Frm,336,113,100,20,"plays"
    Lbl Frm,020,133,300,20,"Minimum 3.0 Stars when repeated within the last"
    Spn Frm,260,130,070,20,"S34",15000,0,999999
    Lbl Frm,336,133,100,20,"plays"
    Lbl Frm,020,153,300,20,"Minimum 2.5 Stars when repeated within the last"
    Spn Frm,260,150,070,20,"S35",25000,0,999999
    Lbl Frm,336,153,100,20,"plays"
    Lbl Frm,020,173,300,20,"Minimum 2.0 Stars when repeated within the last"
    Spn Frm,260,170,070,20,"S36",50000,0,9999999
    Lbl Frm,336,173,100,20,"plays"
    Lbl Frm,020,193,300,20,"Minimum 1.5 Stars when repeated within the last"
    Spn Frm,260,190,070,20,"S37",150000,0,9999999
    Lbl Frm,336,193,100,20,"plays"
    Lbl Frm,020,213,300,20,"Minimum 1.0 Stars when repeated within the last"
    Spn Frm,260,210,070,20,"S38",9999999,0,9999999
    Lbl Frm,336,213,100,20,"plays"
    Lbl Frm,020,233,300,20,"Minimum 0.5 Stars when repeated within the last"
    Spn Frm,260,230,070,20,"S39",0,0,9999999
    Lbl Frm,336,233,100,20,"plays"
    End Sub
Sub D10(DD)
    X=DD.ItemIndex:Y=DD.ItemText(X)
    If Y>"" Then SDB.IniFile.StringValue(o,"D10")=Y
    End Sub
Sub S40(DD)
    SDB.IniFile.IntValue(o,"S40")=DD.ItemIndex
    End Sub
Sub onSave(Frm)
    Set Ini=SDB.IniFile:Set Mem=SDB.Objects(O)
    For i=10 To 15:c="C"&i:Ini.BoolValue(o,c)=Frm.Common.ChildControl(c).Checked:Next
    For i=41 To 49:c="S"&i:Ini.IntValue( o,c)=Frm.Common.ChildControl(c).Value:Next
    Ini.IntValue(O,"S18")=Frm.Common.ChildControl("S18").Value
    SDB.Objects(o&M_0).Checked=Frm.Common.ChildControl("C10").Checked
    SDB.Objects(o&M_1).Checked=Frm.Common.ChildControl("C11").Checked
    RefreshObject
    End Sub
Sub onSave1(Frm)
    Set Ini=SDB.IniFile
    For i=19 To 29:c="S"&i:Ini.IntValue(o,c)=Frm.Common.ChildControl(c).Value:Next
    RefreshObject
    End Sub
Sub onSave2(Frm)
    Set Ini=SDB.IniFile
    For i=30 To 39:c="S"&i:Ini.IntValue(o,c)=Frm.Common.ChildControl(c).Value:Next
    RefreshObject
    End Sub
Sub RefreshObject
    Set Ini=SDB.IniFile
    If  SDB.Objects(O) Is Nothing Then _
        SDB.Objects(O)=CreateObject("Scripting.Dictionary")
    Set Mem=SDB.Objects(O)
    For i=10 To 15:c="C"&i:Mem.Item(i)=Ini.BoolValue(o,c)   :Next
    For i=18 To 40:c="S"&i:Mem.Item(i)=Ini.IntValue( o,c)   :Next
    Mem.Item(43)=Ini.IntValue(o,"S43")*10
    Mem.Item(44)=Ini.IntValue(o,"S44")*10
    Mem.Item(45)=Ini.IntValue(o,"S45")*10
    Mem.Item(46)=Ini.IntValue(o,"S46")*1000
    Mem.Item(47)=Ini.IntValue(o,"S47")/100
    Mem.Item(48)=Ini.IntValue(o,"S48")*1000
    Mem.Item(49)=Ini.IntValue(o,"S49")*60000
    Mem.Item(50)="WScript """& SDB.ApplicationPath&"Scripts\RadioAnnouncer.vbs"&_
    """ //B """ &Ini.StringValue(O,"D10")& """ " & Ini.IntValue(O,"S41") & " " &_
    Ini.IntValue(O,"S42") & " " & Abs(Ini.BoolValue(O,"C02")) & " " & Ini.IntValue(O,"S18")
    End Sub
Sub MIN(Obj)
    Set Mem=SDB.Objects(O)
    If Not Obj.Caption=M_2 Then SDB.Objects(M_2).Checked=False
    If Not Obj.Caption=M_3 Then SDB.Objects(M_3).Checked=False
    If Not Obj.Caption=M_4 Then SDB.Objects(M_4).Checked=False
    Obj.Checked=Not Obj.Checked
    If Obj.Checked Then 
       Mem.Item(10)=False
       Mem.Item(11)=False
       Mem.Item(41)=DateAdd("n",MNo(Obj.Caption),Now)
       Set Tmp=SDB.CreateTimer(2000)
       Script.RegisterEvent Tmp,"OnTimer","BackOn"
    Else
       Mem.Item(41)=Empty
       DoBackOn
    End If
    End Sub
Sub ARO(Obj)
    Set Mem=SDB.Objects(O)
        Obj.Checked=Not Obj.Checked
     If Obj.Caption=M_0 Then 
        SDB.IniFile.BoolValue(o,"C10")=Obj.Checked
        Mem.Item(10)=Obj.Checked
        SDB.Objects(o&M_0).Checked=Obj.Checked
     Else
        SDB.IniFile.BoolValue(o,"C11")=Obj.Checked
        Mem.Item(11)=Obj.Checked
        SDB.Objects(o&M_1).Checked=Obj.Checked
     End If
    End Sub
Sub BackOn(Tmp)
    Set Mem=SDB.Objects(O)
        If Mem.Item(41)=Empty Then 
           Script.UnregisterEvents Tmp
    ElseIf Mem.Item(41)<=Now Then
           Script.UnregisterEvents Tmp
           Mem.Item(02)=Empty
           DoBackOn
    End If
    End Sub
Sub DoBackOn
    Set Mem=SDB.Objects(O)
    Mem.Item(10)=SDB.IniFile.BoolValue(o,"C10")
    Mem.Item(11)=SDB.IniFile.BoolValue(o,"C11")    
    SDB.Objects(M_2).Checked=False
    SDB.Objects(M_3).Checked=False
    SDB.Objects(M_4).Checked=False
    End Sub
Sub LRS(a)
    Set Mem=SDB.Objects(O)
    Set dbT=SDB.Player.CurrentSongList
    i=dbT.Count-1: If i=-1 Then Exit Sub
    Do:Set Sng=dbT.Item(i)
    If Sng.Rating>=0 And Sng.Rating<=Mem.Item(44) Then SDB.Player.PlaylistDelete(i)
    i=i-1:Loop While i=>0
    End Sub
Sub CreateGUI
    Set Mar=SDB.UI.AddMenuItemSub(SDB.UI.Menu_TbStandard, 0, 0)
        Mar.IconIndex=64
        Mar.Caption="Auto Rating"
        Mnu Mar,"ARO","C10",M_0
        Mnu Mar,"ARO","C11",M_1
    SDB.UI.AddMenuItemSep Mar,-1,0
        Mnu Mar,"MIN","Obj",M_2
        Mnu Mar,"MIN","Obj",M_3
        Mnu Mar,"MIN","Obj",M_4
    SDB.UI.AddMenuItemSep Mar,-1,0
        Mnu Mar,"LRS","Non","Clear Low Rated Songs from NP"
  i=SDB.UI.AddOptionSheet("Auto Rating",Script.ScriptPath,"onLoad","onSave",-3)
    SDB.UI.AddOptionSheet "Play Count Table",Script.ScriptPath,"onLoad1","onSave1",i
    SDB.UI.AddOptionSheet "Repeat Play Table ",Script.ScriptPath,"onLoad2","onSave2",i
    End Sub    

Code: Select all

'-------------------------------------------------------
'\Program Files\MediaMonkey\Scripts\RadioAnnouncer.vbs
'
'-------------------------------------------------------
 If Not WScript.Arguments.Count=6 Then WScript.Quit
 On Error Resume Next
Set SAP=WScript.CreateObject("SAPI.SpVoice")
 If Err.Number<>0 Then WScript.Quit
    If WScript.Arguments.Item(4)>0 Then
       WScript.Sleep WScript.Arguments.Item(4)
    End If
    Voice="Name="&WScript.Arguments.Item(0)
    SAP.Volume=WScript.Arguments.Item(1)
    SAP.Rate=WScript.Arguments.Item(2)
Set SAP.Voice=SAP.GetVoices(Voice).Item(0)
    SAP.Speak(WScript.Arguments.Item(5))
    SAP.WaitUntilDone(-1)
 If WScript.Arguments.Item(3)=1 Then
    With WScript.CreateObject("SongsDB.SDBApplication")
        If .Player.isPaused Then .Player.Pause
    End With
  End If
WScript.Quit
Image

Guest

Post by Guest » Mon Apr 09, 2007 7:01 am

So far so good for me! The delay works like a champ. Thanks DiddeLeeDoo! i'll be using it all day with both radio and autorate on. i'll report if any issues arise.

Balance.

Guest

Post by Guest » Mon Apr 09, 2007 7:41 am

Just a note to whom ever may use the delay for radio announcer. it is in milliseconds (1000 = 1 second). I don't care either way, milli's will give u more control so I'm happy wit it as is. :)

Balance

Guest

Post by Guest » Mon Apr 09, 2007 1:10 pm

why is there that only one voice can be heard.

Balance

Post by Balance » Wed Apr 11, 2007 8:11 am

You can download more voices off the internet the are called SAPI4 and SAPI5 just google it. some are free some aren't

Balance

Psyker7
Posts: 254
Joined: Sat Mar 03, 2007 8:00 am

Post by Psyker7 » Mon Apr 16, 2007 12:31 am

The script pasted above seems to only rate sporadically....
I can't quite figure out what the conditions have to be for it to rate or not atm >.<

EDIT: Using MM 3.0.0.1026 Alpha

rovingcowboy
Posts: 14153
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy » Mon Apr 16, 2007 3:34 am

thats because mm3 scripting code is not set in stone yet
and diddeleedoo is trying to get it working best he can
with the little known code for mm 3 scripts he has.

when you find an error keep posting it here so he knows
what area the mm 3 needs more scripting for.

he has been busy with house work he told me in an email
had to do coax wire replacement on his entertainment system.

so hes been off the computer for awhile.
guess he is taking a needed beak while the mm 3 script code is being figured out then he will get it adjusted by the first month after mm 3 is released or faster depends on how good a day he has then. 8)
roving cowboy / keith hall. My skins http://www.mediamonkey.com/forum/viewto ... =9&t=16724 for some help check on Monkey's helpful messages at http://www.mediamonkey.com/forum/viewto ... 4008#44008 MY SYSTEMS.1.Jukebox WinXp pro sp 3 version 3.5 gigabyte mb. 281 GHz amd athlon x2 240 built by me.) 2.WinXP pro sp3, vers 2.5.5 and vers 3.5 backup storage, shuttle 32a mb,734 MHz amd athlon put together by me.) 3.Dell demension, winxp pro sp3, mm3.5 spare jukebox.) 4.WinXp pro sp3, vers 3.5, dad's computer bought from computer store. )5. Samsung Galaxy 5 Android 5) 6. Proscan tablet Android 4.3 ) 7. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.

Psyker7
Posts: 254
Joined: Sat Mar 03, 2007 8:00 am

Post by Psyker7 » Mon Apr 16, 2007 4:19 am

Think I figured part of it.
Turning off cross fading seems to help, and if you are running any background processes at the time, like scanning new files it is unreliable.

I realize its an Alpha but thought i'd give the feedback anyway ^.^

Mad Lib
Posts: 23
Joined: Sun Feb 11, 2007 11:53 pm

Can't seem to install!

Post by Mad Lib » Sat Apr 21, 2007 7:19 pm

DL both versions but when I double click the install all what happens is notepad comes up and shows me the script. I've checked the Library in settings but nothing there. Also I've tried placing it in Auto Script folder but still nothing happens. Am I doing something wrong?? PLS HELP.

thx. :)

DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo » Sun Apr 22, 2007 12:09 pm

Hi Mad Lib,

Most likely some sort of protection software have disabled your script system.

You might find this little trick helps.

Start - Run and write
CScript //H:WScript
and hit OK

All it does is to reset the script system to defaults. The effect should hopefully be that a double click should do the install procedure instead of just showing the script content.


Otherwise, there's been little music around here lately. Too much other stuff going on. Have started settling into the music again and hope finish that 'work in progress' script above.
Image

DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo » Sun Apr 22, 2007 12:18 pm

In regards to MM3 Alpha. It might help to have the rating procedure happening a bit later. In the test script it is set to happen 1.2 seconds after a new song start playing. You might want to try 2.0 seconds instead to give MM3 a bit more time.

Code: Select all

Sub SetTimers
    Set CST=SDB.CreateTimer(500)
        Script.RegisterEvent CST, "OnTimer", "SongPlaying"
        SDB.Objects(T)=CST
    Set RCS=SDB.CreateTimer(1000)
        Script.RegisterEvent RCS, "OnTimer", "ReadSong"
        SDB.Objects(L)=RCS
    Set PLE=SDB.CreateTimer(1000)
        Script.RegisterEvent PLE, "OnTimer", "PlayListEnded"
        SDB.Objects(P)=PLE 
    Set RSN=SDB.CreateTimer(1200)
        Script.RegisterEvent RSN, "OnTimer", "RateSongNow"
        SDB.Objects(R)=RSN
End Sub 
That last bit there.

Code: Select all

    Set RSN=SDB.CreateTimer(1200)
        Script.RegisterEvent RSN, "OnTimer", "RateSongNow"
        SDB.Objects(R)=RSN
Changing CreateTimer(1200) to CreateTimer(2000) makes it do the rating thingy two seconds after instead of 1.2 seconds after.

Apart from that, all I can think of is that if the song is not in the database (library) nothing will happen. Also, if the song is 'sampled' by using the Seek bar (song play position bar), the song will not be rated. This is done so that you can sample some songs without having to turn the AutoRating off.
Image

billywizz
Posts: 20
Joined: Fri May 19, 2006 12:53 pm

Post by billywizz » Fri Apr 27, 2007 6:45 am

This isnt working at all for me. Can't install it for some reason. Have read the instuction about enabling C:Script etc but that does nothing. The download apppears to have only a vbs file within the zip. That, placed manually into scripts file does nothing.

Any suggestions?

DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo » Fri Apr 27, 2007 10:44 am

Maybe updating the scripting system on the computer could help.

http://www.mrtech.com/news/messages/4047.html

Otherwise it can be done manually.

The install file contain 3x scripts.
Program Files\MediaMonkey\Scripts\Auto\AutoRateSongs.vbs
Program Files\MediaMonkey\Scripts\Auto\AutoRateSongsOptionSheet.vbs
Program Files\MediaMonkey\Scripts\RadioAnnouncer.vbs

You'll find this info inside the install file, which could be made clearer I guess. ... like File start here, ends here.. that sort of stuff.

Another way might be to drag the install file (script) and drop it over the file c:\Windows\System32\wscript.exe
wscript.exe will then execute the install script, unless there's something in your security system that prevent scripts to execute in general.
Image

Post Reply