by DiddeLeeDoo » Wed Oct 04, 2006 12:14 am
Here's the manual run down of what the installer does, and after restarting MediaMonkey you should find Weekly Top 40 under
File - Create Report - Weekly Top 40
You may want to check if the installer file have done it already.
1. Make sure you have this section in your \MediaMonkey\Scripts\Scripts.ini
Code: Select all
[WeeklyTop40]
FileName=WeeklyTop40.vbs
ProcName=ShowStats
Order=5
DisplayName=&Weekly Top 40
Description=Library Statistics Report
Language=VBScript
ScriptType=1
2.
Copies this script to \MediaMonkey\Scripts\WeeklyTop40.vbs (not the \auto folder)
Code: Select all
'----------------------------------------------------------------------
'\Program Files\MediaMonkey\Scripts\WeeklyTop40.vbs
'
' Version: 1.1
' Date: 2 September 2006
' Based on the Stats.vbs Script: Script branch by DiddeLeeDoo
'----------------------------------------------------------------------
Private SOn
Sub ShowStats
Wdt=640
Set Frm=SDB.UI.NewForm
Frm.Common.SetRect 50,50,Wdt,400
Frm.Common.MinWidth=200
Frm.Common.MinHeight=150
Frm.FormPosition=4
Frm.Caption=SDB.Localize("Weekly Top 40")
Frm.StayOnTop=True
Frm.SavePositionName="Weekly Top 40"
Set Fot=SDB.UI.NewPanel(Frm)
Fot.Common.Align=2
Fot.Common.Height=35
Set Ddo=SDB.UI.NewDropDown(Fot)
Ddo.Style=2
Ddo.Common.SetRect Wdt-500,6,150,24
Ddo.Common.Anchors=4+8
Ddo.Common.ControlName="Ddo"
x=DateDiff("w",SDB.Database.OpenSQL("Select First(PlayDate) from Played").StringByIndex(0),Date)
For i = 0 To x-1
Ddo.AddItem FormatDateTime((Date-DatePart("w",date)+1)-(7*i),1)
Next
Ddo.ItemIndex=0
Ddo.UseScript = Script.ScriptPath
Ddo.OnSelectFunc="DoWeek"
Set Btn=SDB.UI.NewButton(Fot)
Btn.Caption=SDB.Localize("&Save as...")
Btn.Common.SetRect Wdt-255,6,150,24
Btn.Common.Anchors=4+8
Btn.UseScript=Script.ScriptPath
Btn.OnClickFunc="SaveAs"
Set Btn=SDB.UI.NewButton(Fot)
Btn.Caption=SDB.Localize("&Close")
Btn.Common.SetRect Wdt-100,6,85,24
Btn.Common.Anchors=4+8
Btn.UseScript=Script.ScriptPath
Btn.OnClickFunc="OnClose"
Set Sxp=SDB.UI.NewActiveX(Frm,"Shell.Explorer")
Sxp.Common.Align=5
Sxp.Common.ControlName="Web"
Set Rpt=Sxp.Interf.Document
Rpt.Write Content(False,0)
Rpt.Close
SDB.Objects("WeeklyTop40")=Frm
Frm.Common.Visible=True
End Sub
Function DoWeek(Ddo)
Set Doc=SDB.Objects("WeeklyTop40").Common.ChildControl("Web").Interf.Document
Doc.Write Content(False,Ddo.ItemIndex)
Doc.Close
End Function
Sub OnClose(Btn)
SDB.Objects("WeeklyTop40").Common.Visible=False
SDB.Objects("WeeklyTop40")=Nothing
End Sub
Sub SaveAS(Btn)
x=SDB.Objects("WeeklyTop40").Common.ChildControl("Ddo").ItemIndex
With SDB.CommonDialog
.DefaultExt="html"
.Filter="HTML (*.htm)|*.htm|All files (*.*)|*.*"
.Title=SDB.Localize("Exporting...")
.InitDir=SDB.IniFile.StringValue("Scripts", "LastExportStatsDir")
.ShowSave
bSv=.Ok
xTo=.FileName
End With
If bSv Then With SDB.Tools.FileSystem.CreateTextFile(xTo,True):.Write Content(True,x):.Close:End With
End Sub
Function Content(bEx,w)
Set Doc=New Page
Doc.Add "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">"
Doc.Add "<html>"
Doc.Add " <head>"
Doc.Add " <title>"
Doc.Add " "&SDB.Localize("Weekly Top 40")
Doc.Add " </title>"
Doc.Add " <base href=""file:///" &Home& """>"
Doc.Add " </head>"
Doc.Add " <STYLE TYPE=text/css>"
Doc.Add " body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}"
Doc.Add " H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:Center}"
Doc.Add " P{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000;}"
Doc.Add " TH{font-family:'Verdana',sans-serif; font-size:10pt; font-weight:bold; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}"
Doc.Add " TD{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}"
Doc.Add " TR.dark{background-color:#EEEEEE}"
Doc.Add " TR.aleft TH{text-align:left}"
Doc.Add " </STYLE>"
Doc.Add " <body>"
Doc.Add " <H1>"
Doc.Add " "&SDB.Localize("Weekly Top 40")
Doc.Add " </H1>"
Doc.Add " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">"
Doc.Add " <tr>"
Doc.Add " <th colspan=""5"">"
Doc.Add " "&FormatDateTime((Date-DatePart("w",date)+1)-(7*w),1)
Doc.Add " </th>"
Doc.Add " </tr>"
Doc.Add " <tr class=""aleft"">"
Doc.Add " <th>" & "#" & "</th>"
Doc.Add " <th>" & SDB.Localize("Rating") & "</th>"
Doc.Add " <th>" & SDB.Localize("Song") & "</th>"
Doc.Add " <th>" & SDB.Localize("Artist") & "</th>"
Doc.Add " <th>" & SDB.Localize("Album") & "</th>"
Doc.Add " </tr>" :Set dbT=SDB.Database.OpenSQL(SQL(w)) :For i=1 To 40 :If dbT.EOF Then Exit For
Doc.Add " <tr" & Style() & ">"
Doc.Add " <td>" & i &"</td>"
Doc.Add " <td>" & ShowRating(dbT.StringByName("Rating"),bEx) & "</td>"
Doc.Add " <td>" & MapXML(dbT.StringByName("SongTitle"))&" <font size=-2>("&dbT.StringByName("CountOfIdPlay")&")</font></td>"
Doc.Add " <td>" & MapXML(dbT.StringByName("Artist"))&"</td>"
Doc.Add " <td>" & MapXML(dbT.StringByName("Album")) &"</td>"
Doc.Add " </tr>": dbT.Next :Next
Doc.Add " </table>"
Doc.Add " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">"
Doc.Add " <tr>"
Doc.Add " <td style='border-bottom-width:0px'>"
Doc.Add " "&SDB.Localize("Generated by ") & "<a href='http://www.mediamonkey.com'>MediaMonkey</a>" & SDB.Localize(" on ") & MapXML(FormatDateTime(date(), vbLongDate)) & " " & SDB.Localize("at") & " " & MapXml(FormatDateTime(time(), vbLongTime))
Doc.Add " </td>"
Doc.Add " </tr>"
Doc.Add " </table>"
Doc.Add " </body>"
Doc.Add "</html>"
Content=Doc.Content
End Function
Function Home
Tmp=SDB.ApplicationPath&"Scripts\"
Tmp=Replace(Tmp, " ", "%20")
Tmp=Replace(Tmp, "\", "/")
Home=Tmp
End Function
Function MapXML(strX)
stX=Replace(strX, "&", "&")
stX=Replace(strX, "<", "<")
stX=Replace(strX, ">", ">")
i=1
While i<=Len(stX)
If (AscW(Mid(stX,i,1))>127) Then stX=Mid(stX,1,i-1)+"&#"+CStr(AscW(Mid(stX,i,1)))+";"+Mid(stX,i+1,Len(stX))
i=i+1
Wend
If strX="" Then strX=" "
MapXML=strX
End Function
Function ShowRating(RDe, bEx)
If RDe=-1 Then
ShowRating=" "
ElseIf RDe=0 Then
If Not bEx Then
ShowRating="<img border=""0"" src=""bomb.png"" width=""10"" height=""11"">"
Else
ShowRating="0"
End If
Else
For a=20 To RDe Step 20
If Not bEx Then
ShowRating=ShowRating & "<img border=""0"" src=""star.png"" width=""10"" height=""11"">"
Else
ShowRating=ShowRating & "*"
End If
Next
End If
If (RDe Mod 20) >=10 Then
If Not bEx Then
ShowRating=ShowRating & "<img border=""0"" src=""half-star.png"" width=""10"" height=""11"">"
Else
ShowRating=ShowRating & "'"
End If
End If
End Function
Class Page
Dim ATable,AddRows,Row
Private Sub Class_Initialize()
AddRows=50:Row=0:ReDim ATable(AddRows)
End Sub
Public Sub Add(Line)
If Row > UBound(ATable) Then ReDim Preserve ATable(UBound(ATable)+AddRows)
ATable(Row)=Line:Row=Row+1
End Sub
Public Function Content
Content=Join(ATable,vbNewLine)
End Function
End Class
Function SQL(w)
SQL="SELECT Count(Played.IdPlay) AS CountOfIdPlay, Songs.Rating, Songs.SongTitle, Artists.Artist, Albums.Album "&_
"FROM ((Songs INNER JOIN Artists ON Songs.IDArtist=Artists.ID) INNER JOIN Albums ON Songs.IDAlbum=Albums.ID) INNER JOIN Played ON Songs.ID=Played.IdSong "&_
"GROUP BY Year(PlayDate), DatePart('ww',PlayDate), Songs.Rating, Songs.SongTitle, Artists.Artist, Albums.Album "&_
"HAVING (((DatePart('ww',PlayDate))=DatePart('ww',Now())-"&w&"-1)) "&_
"ORDER BY Year(Played.PlayDate) DESC , DatePart('ww',Played.PlayDate) DESC , Count(Played.IdPlay) DESC , Songs.Rating DESC "
End Function
Function Style
SOn=Not SOn:If SOn Then Style="" Else Style=" class=""Dark""" End If
End Function
Here's the manual run down of what the installer does, and after restarting MediaMonkey you should find Weekly Top 40 under
File - Create Report - Weekly Top 40
You may want to check if the installer file have done it already.
1. Make sure you have this section in your \MediaMonkey\Scripts\Scripts.ini
[code][WeeklyTop40]
FileName=WeeklyTop40.vbs
ProcName=ShowStats
Order=5
DisplayName=&Weekly Top 40
Description=Library Statistics Report
Language=VBScript
ScriptType=1[/code]
2.
Copies this script to \MediaMonkey\Scripts\WeeklyTop40.vbs (not the \auto folder)
[code]'----------------------------------------------------------------------
'\Program Files\MediaMonkey\Scripts\WeeklyTop40.vbs
'
' Version: 1.1
' Date: 2 September 2006
' Based on the Stats.vbs Script: Script branch by DiddeLeeDoo
'----------------------------------------------------------------------
Private SOn
Sub ShowStats
Wdt=640
Set Frm=SDB.UI.NewForm
Frm.Common.SetRect 50,50,Wdt,400
Frm.Common.MinWidth=200
Frm.Common.MinHeight=150
Frm.FormPosition=4
Frm.Caption=SDB.Localize("Weekly Top 40")
Frm.StayOnTop=True
Frm.SavePositionName="Weekly Top 40"
Set Fot=SDB.UI.NewPanel(Frm)
Fot.Common.Align=2
Fot.Common.Height=35
Set Ddo=SDB.UI.NewDropDown(Fot)
Ddo.Style=2
Ddo.Common.SetRect Wdt-500,6,150,24
Ddo.Common.Anchors=4+8
Ddo.Common.ControlName="Ddo"
x=DateDiff("w",SDB.Database.OpenSQL("Select First(PlayDate) from Played").StringByIndex(0),Date)
For i = 0 To x-1
Ddo.AddItem FormatDateTime((Date-DatePart("w",date)+1)-(7*i),1)
Next
Ddo.ItemIndex=0
Ddo.UseScript = Script.ScriptPath
Ddo.OnSelectFunc="DoWeek"
Set Btn=SDB.UI.NewButton(Fot)
Btn.Caption=SDB.Localize("&Save as...")
Btn.Common.SetRect Wdt-255,6,150,24
Btn.Common.Anchors=4+8
Btn.UseScript=Script.ScriptPath
Btn.OnClickFunc="SaveAs"
Set Btn=SDB.UI.NewButton(Fot)
Btn.Caption=SDB.Localize("&Close")
Btn.Common.SetRect Wdt-100,6,85,24
Btn.Common.Anchors=4+8
Btn.UseScript=Script.ScriptPath
Btn.OnClickFunc="OnClose"
Set Sxp=SDB.UI.NewActiveX(Frm,"Shell.Explorer")
Sxp.Common.Align=5
Sxp.Common.ControlName="Web"
Set Rpt=Sxp.Interf.Document
Rpt.Write Content(False,0)
Rpt.Close
SDB.Objects("WeeklyTop40")=Frm
Frm.Common.Visible=True
End Sub
Function DoWeek(Ddo)
Set Doc=SDB.Objects("WeeklyTop40").Common.ChildControl("Web").Interf.Document
Doc.Write Content(False,Ddo.ItemIndex)
Doc.Close
End Function
Sub OnClose(Btn)
SDB.Objects("WeeklyTop40").Common.Visible=False
SDB.Objects("WeeklyTop40")=Nothing
End Sub
Sub SaveAS(Btn)
x=SDB.Objects("WeeklyTop40").Common.ChildControl("Ddo").ItemIndex
With SDB.CommonDialog
.DefaultExt="html"
.Filter="HTML (*.htm)|*.htm|All files (*.*)|*.*"
.Title=SDB.Localize("Exporting...")
.InitDir=SDB.IniFile.StringValue("Scripts", "LastExportStatsDir")
.ShowSave
bSv=.Ok
xTo=.FileName
End With
If bSv Then With SDB.Tools.FileSystem.CreateTextFile(xTo,True):.Write Content(True,x):.Close:End With
End Sub
Function Content(bEx,w)
Set Doc=New Page
Doc.Add "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">"
Doc.Add "<html>"
Doc.Add " <head>"
Doc.Add " <title>"
Doc.Add " "&SDB.Localize("Weekly Top 40")
Doc.Add " </title>"
Doc.Add " <base href=""file:///" &Home& """>"
Doc.Add " </head>"
Doc.Add " <STYLE TYPE=text/css>"
Doc.Add " body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}"
Doc.Add " H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-align:Center}"
Doc.Add " P{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000;}"
Doc.Add " TH{font-family:'Verdana',sans-serif; font-size:10pt; font-weight:bold; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:3px;}"
Doc.Add " TD{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000; border-color:#000000; border-style: solid; border-left-width:0px; border-right-width:0px; border-top-width:0px; border-bottom-width:1px;}"
Doc.Add " TR.dark{background-color:#EEEEEE}"
Doc.Add " TR.aleft TH{text-align:left}"
Doc.Add " </STYLE>"
Doc.Add " <body>"
Doc.Add " <H1>"
Doc.Add " "&SDB.Localize("Weekly Top 40")
Doc.Add " </H1>"
Doc.Add " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">"
Doc.Add " <tr>"
Doc.Add " <th colspan=""5"">"
Doc.Add " "&FormatDateTime((Date-DatePart("w",date)+1)-(7*w),1)
Doc.Add " </th>"
Doc.Add " </tr>"
Doc.Add " <tr class=""aleft"">"
Doc.Add " <th>" & "#" & "</th>"
Doc.Add " <th>" & SDB.Localize("Rating") & "</th>"
Doc.Add " <th>" & SDB.Localize("Song") & "</th>"
Doc.Add " <th>" & SDB.Localize("Artist") & "</th>"
Doc.Add " <th>" & SDB.Localize("Album") & "</th>"
Doc.Add " </tr>" :Set dbT=SDB.Database.OpenSQL(SQL(w)) :For i=1 To 40 :If dbT.EOF Then Exit For
Doc.Add " <tr" & Style() & ">"
Doc.Add " <td>" & i &"</td>"
Doc.Add " <td>" & ShowRating(dbT.StringByName("Rating"),bEx) & "</td>"
Doc.Add " <td>" & MapXML(dbT.StringByName("SongTitle"))&" <font size=-2>("&dbT.StringByName("CountOfIdPlay")&")</font></td>"
Doc.Add " <td>" & MapXML(dbT.StringByName("Artist"))&"</td>"
Doc.Add " <td>" & MapXML(dbT.StringByName("Album")) &"</td>"
Doc.Add " </tr>": dbT.Next :Next
Doc.Add " </table>"
Doc.Add " <table border=""0"" cellspacing=""0"" cellpadding=""4"" width=""100%"">"
Doc.Add " <tr>"
Doc.Add " <td style='border-bottom-width:0px'>"
Doc.Add " "&SDB.Localize("Generated by ") & "<a href='http://www.mediamonkey.com'>MediaMonkey</a>" & SDB.Localize(" on ") & MapXML(FormatDateTime(date(), vbLongDate)) & " " & SDB.Localize("at") & " " & MapXml(FormatDateTime(time(), vbLongTime))
Doc.Add " </td>"
Doc.Add " </tr>"
Doc.Add " </table>"
Doc.Add " </body>"
Doc.Add "</html>"
Content=Doc.Content
End Function
Function Home
Tmp=SDB.ApplicationPath&"Scripts\"
Tmp=Replace(Tmp, " ", "%20")
Tmp=Replace(Tmp, "\", "/")
Home=Tmp
End Function
Function MapXML(strX)
stX=Replace(strX, "&", "&")
stX=Replace(strX, "<", "<")
stX=Replace(strX, ">", ">")
i=1
While i<=Len(stX)
If (AscW(Mid(stX,i,1))>127) Then stX=Mid(stX,1,i-1)+"&#"+CStr(AscW(Mid(stX,i,1)))+";"+Mid(stX,i+1,Len(stX))
i=i+1
Wend
If strX="" Then strX=" "
MapXML=strX
End Function
Function ShowRating(RDe, bEx)
If RDe=-1 Then
ShowRating=" "
ElseIf RDe=0 Then
If Not bEx Then
ShowRating="<img border=""0"" src=""bomb.png"" width=""10"" height=""11"">"
Else
ShowRating="0"
End If
Else
For a=20 To RDe Step 20
If Not bEx Then
ShowRating=ShowRating & "<img border=""0"" src=""star.png"" width=""10"" height=""11"">"
Else
ShowRating=ShowRating & "*"
End If
Next
End If
If (RDe Mod 20) >=10 Then
If Not bEx Then
ShowRating=ShowRating & "<img border=""0"" src=""half-star.png"" width=""10"" height=""11"">"
Else
ShowRating=ShowRating & "'"
End If
End If
End Function
Class Page
Dim ATable,AddRows,Row
Private Sub Class_Initialize()
AddRows=50:Row=0:ReDim ATable(AddRows)
End Sub
Public Sub Add(Line)
If Row > UBound(ATable) Then ReDim Preserve ATable(UBound(ATable)+AddRows)
ATable(Row)=Line:Row=Row+1
End Sub
Public Function Content
Content=Join(ATable,vbNewLine)
End Function
End Class
Function SQL(w)
SQL="SELECT Count(Played.IdPlay) AS CountOfIdPlay, Songs.Rating, Songs.SongTitle, Artists.Artist, Albums.Album "&_
"FROM ((Songs INNER JOIN Artists ON Songs.IDArtist=Artists.ID) INNER JOIN Albums ON Songs.IDAlbum=Albums.ID) INNER JOIN Played ON Songs.ID=Played.IdSong "&_
"GROUP BY Year(PlayDate), DatePart('ww',PlayDate), Songs.Rating, Songs.SongTitle, Artists.Artist, Albums.Album "&_
"HAVING (((DatePart('ww',PlayDate))=DatePart('ww',Now())-"&w&"-1)) "&_
"ORDER BY Year(Played.PlayDate) DESC , DatePart('ww',Played.PlayDate) DESC , Count(Played.IdPlay) DESC , Songs.Rating DESC "
End Function
Function Style
SOn=Not SOn:If SOn Then Style="" Else Style=" class=""Dark""" End If
End Function
[/code]