Weekly Top 40 Songs Report v1.10 [Script]

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

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

Weekly Top 40 Songs Report v1.10 [Script]

Post by DiddeLeeDoo »

Top 40 songs report on a weekly basis.

After installation you'll get a new item in the File - Create Reports menu called Weekly Top 40

Changelog
1.00 - 1.01 : Rewrote parts of the code to make it faster...
1.01 - 1.02 : Further attention to detail, and better handling of special characters, blanks etc.
1.02 - 1.10 : Week selector integrated.

Install Script Open zip, and just double click the install file.

Script will be copied to \Program Files\MediaMonkey\Scripts\WeeklyTop40.vbs and use the Scripts.ini file

Credits go to TheRocket and Jiri who made the Stats.vbs script in the first place. Using that as a base made it easy to do this report segment.
Last edited by DiddeLeeDoo on Mon Mar 05, 2007 4:22 am, edited 7 times in total.
Image
paulmt
Posts: 1170
Joined: Tue Jul 18, 2006 6:06 pm

Post by paulmt »

Very nice report layout. I like it.
Is the number following the song name in ( ) the number of plays?

Some things I would like to see if possible...

1. Option to save as a Playlist

2. Top 40 played 3, 6, 12 month's ago – possibly from time stamp? (always nice to go back and see what you were listening to)

3. Selectable number of songs, e.g. Top 100, Top 200 etc

DiddeLeeDoo you are one of the more prolific scripters on this forum. I for one am very grateful for the work you do which adds so much to my listening pleasure and functional use of MM. Please keep it up :-)
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

TheRocket & Jiri did the hard part of creating as far as gather from the heading of the Stats.vbs script

Doesn't seem like there is any active Thread about the Stats script in this MediaMonkey forum.

I wonder if it would be just as well to do a node grouped into every week in the MediaMonkey history, as you then can do whatever with the songs too.
Image
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Just a bump to say the code has been updated to be a whole lot faster.
It's on screen now almost before hitting the menu here... ;)
Image
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Bump to say the week selector is now a part of the script. Goes all the way back to the first day in the current play history.
Image
Bex
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Post by Bex »

Cool script!
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Sgrom
Posts: 84
Joined: Sat Sep 02, 2006 5:59 am

Post by Sgrom »

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

Post by DiddeLeeDoo »

Hopefully just a temporary fault somewhere on the net. Seems to be alright now.
Image
Kit

Post by Kit »

This script is awesome ... it would be really great if you could also get it to create the playlist of the top 40 :P
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Thanks Kit,

I suppose to do more with this one, but available spare time have been a bit limited over the last couple of weeks. Will get on to it when time allow.
Image
salamat
Posts: 23
Joined: Sun Aug 20, 2006 3:32 am
Location: Philippines

Post by salamat »

DiddeLeeDoo!

This script is great, but......there is something strange.....I installed it before, and it worked. I was able to write a top 40 report, and so fare so good. But then I had to uninstal and reinstal MM again, due to a crash, and when I tried to download this script again, and reinstal it, I have this error #424; Object required: "Wscript"......I tried everything possible, but to no avail..... did you change something in the script last weeks? I mean, since it worked before for me????

Yes, I have this wscript in the system folder, but can this file have been corrupted?l

BTW, it's always very helpful for us newbies to have a helpfile with all the instalation tips and guides, or even better, a instalation program to setup everything and make shure everthing is done right.....

This is the way I did it; Downloaded the zipfile to the script\autofolder, unzipped, and it ended up in a subfolder called MediaMonkey_weekly top 40...v.110 folder, tried to doubleclik it from there, it didn't work, so i moved it to the auto folder, and doubleclikked it again, but still no new top 40 report in the file\create report menu.....maybe I did somthing wrong? That's why we need a detailed guide to make shure we do every detail the way it's suppose to be done......Don't remember how I did it in the first place to make it work......;-)

Salamat kaayo! (Means; Thank you very much (or a lot) in the Philippines)
And keep up your good work!!!! It's amazing how much improvement you and your fellow scripters are doing for MM!!!!!
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

Hi Salamat,
Thanks for putting a big smile on my face. G'day from down here.! The global nature of this forum is good fun.

Sounds like one of the programs on your machine have put the scripting engine out of tune.

You could try this to see if that helps

Do the Windows Start button and find- 'Run' and write

CScript //H:WScript

and hit OK

This should reset your scripting system to defaults.

These self-install scripts I do rely on that your scripting system is normal.

All that you need to do with these, is simply double clicking it from anywhere. It is enough just to open the zip file and double click the file from within the zip file. No need to extract it to anywhere.

If you happen to have the install file in the MediaMonkey folders, you are most likely best off by taking the install file away from there.

Nothing have changed with the script over the last couple of weeks. In fact, work prevent me from focusing on scripting at the moment, but I hope to get some time at the end of the week.
Image
salamat
Posts: 23
Joined: Sun Aug 20, 2006 3:32 am
Location: Philippines

Post by salamat »

OK, I tried your advice, runned the CScript //H:WScript, moved the zip file to another folder and doubleclicked, and MM started up normaly, but could not find the script anywhere in MM

When I search c:\ for the installed script, nothing is found ether. So it seems like there is something wrong here. Any ideea?
DiddeLeeDoo
Posts: 1017
Joined: Wed Mar 01, 2006 1:09 am
Location: In a jungle down under
Contact:

Post by DiddeLeeDoo »

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="&nbsp;"
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
Image
rovingcowboy
Posts: 14163
Joined: Sat Oct 25, 2003 7:57 am
Location: (Texas)
Contact:

Post by rovingcowboy »

not sure about the missing script you have trouble with.

but wscript is also needing turned on more then likely one of the ms
updates turned it off?

there is ways to do it in the tools internt options of the explorer.

but i can not remember how.

you can also get the tweaking program from majorgeeks.com in the freeware section it is called xteq or go to xteq.com and get the free version from their site.

but there is a way to turn on the wscript in there.

if that wscript being off is your trouble that is what i would try and do.

if your having other issues with the computer i don't know.

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 A51 5G Android ) 6. amd a8-5600 apu 3.60ghz mm version 4 windows 7 pro bought from computer store.
Post Reply