Need help with report script...
Need help with report script...
I am not that good with HTML and would like to have the reports display the total song length for all songs in the report.
Any help would be appreciated.
thanks,
Brian A.
Any help would be appreciated.
thanks,
Brian A.
Better to Burn out than to fade away....
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
Code: Select all
... see below ...
Last edited by onkel_enno on Mon Aug 29, 2005 1:07 am, edited 1 time in total.
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
onkel_enno,
What do you use for programming?
BTW I do not know about you but sometimes solving some scripting problem looks like taking a nap from my regular jobs and problems (and keep me in shape).
What do you use for programming?
BTW I do not know about you but sometimes solving some scripting problem looks like taking a nap from my regular jobs and problems (and keep me in shape).
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
How to attach PICTURE/SCREENSHOTS to forum posts
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
How to attach PICTURE/SCREENSHOTS to forum posts
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
Core App yes. Other parts as I know are in MSVC and C. Plugins I've made are also in Delphi.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
How to attach PICTURE/SCREENSHOTS to forum posts
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
How to attach PICTURE/SCREENSHOTS to forum posts
Getting overflow error
Onkel,
The code works great when I selct only a few songs but I get an overflow error when I select the 309 songs I want to list. Total time is over 14 hours.
Brian A.
The code works great when I selct only a few songs but I get an overflow error when I select the 309 songs I want to list. Total time is over 14 hours.
Brian A.
Better to Burn out than to fade away....
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
Topic Moved
I have to move this post since it definetely belongs under the Scripts and Components Section.
Please pay attention where you post (wbss26) since posting under the corect section makes life easier for everyone....
Please pay attention where you post (wbss26) since posting under the corect section makes life easier for everyone....
Re: Topic Moved
psyxonova,psyxonova wrote:I have to move this post since it definetely belongs under the Scripts and Components Section.
Nothing to do with this topic; I notice that you've been added as a moderator to most groups but I must of missed the introduction. I'd like to extend my appreciation to you for taking on this role.
From a user's point of view, I hope this means the Jiri has more time to focus on MM development. Thanks again!
--
Alan
-
- Posts: 2153
- Joined: Fri Jan 14, 2005 1:45 am
- Location: Germany
- Contact:
That should work for every collection (I hope):
The Main Changes are these Lines:
Code: Select all
Sub ExportHTML
' initialize export
Call InitExport( ".htm", "HTML (*.htm)|*.htm|All files (*.*)|*.*", _
"LastExportHTMLDir")
if fullfile="" then
Exit Sub
end if
' Create the output file
Dim fout
Set fout = fso.CreateTextFile( fullfile, True)
' Write header line
fout.WriteLine "<html>"
fout.WriteLine "<head><title>" & SDB.Localize("MediaMonkey Track List") & "</title>"
' Code to format the document
fout.WriteLine "<style type=text/css>"
fout.WriteLine "body{font-family:'Verdana',sans-serif; background-color:#FFFFFF; font-size:9pt; color:#000000;}"
fout.WriteLine "H1{font-family:'Verdana',sans-serif; font-size:13pt; font-weight:bold; color:#AAAAAA; text-aligh:left}"
fout.WriteLine "P{font-family:'Verdana',sans-serif; font-size:9pt; color:#000000;}"
fout.WriteLine "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;}"
fout.WriteLine "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;}"
fout.Writeline "TD.dark{background-color:#EEEEEE}"
fout.WriteLine "</style>"
fout.WriteLine "</head><body>"
fout.WriteLine "<a href='http://www.mediamonkey.com'><h1>" & SDB.Localize("MediaMonkey Track List")&"</h1></a>"
' Headers of table
fout.WriteLine "<table cellpadding=4 cellspacing=0>"
fout.WriteLine "<tr align=left>"
fout.WriteLine " <th id=dark>#</th>"
fout.WriteLine " <th>" & SDB.Localize("Artist") & "</th>"
fout.WriteLine " <th id=dark>" & SDB.Localize("Title") & "</th>"
fout.WriteLine " <th>" & SDB.Localize("Length") & "</th>"
fout.WriteLine " <th id=dark>" & SDB.Localize("Album") & "</th>"
fout.WriteLine " <th>" & SDB.Localize("Track #") & "</th>"
fout.WriteLine " <th id=dark>" & SDB.Localize("Year") & "</th>"
fout.WriteLine " <th>" & SDB.Localize("Genre") & "</th>"
fout.WriteLine " <th id=dark>" & SDB.Localize("Rating") & "</th>"
fout.WriteLine " <th>" & SDB.Localize("Bitrate") & "</th>"
fout.WriteLine " <th id=dark>" & SDB.Localize("Media") & "</th>"
fout.WriteLine "</tr>"
' Use progress to notify user about the current action
Dim Progress
Set Progress = SDB.Progress
Progress.Text = SDB.Localize("Exporting...")
' Iterate through the list and export all songs
Progress.MaxValue = list.count
Dim SongsLength
Dim i, itm
for i=0 to list.count-1
Set itm = list.Item(i)
Dim bitrate
bitrate = itm.bitrate
if bitrate>0 then
bitrate = CStr(Round( bitrate/1000))
else
bitrate = " "
end if
Dim year
year = itm.year
if year<=0 then
year = " "
else
year = CStr( year)
end if
' Add space to empty fields, so table is displayed correctly (Cell borders do not show up for empty cells)
Dim artistname
artistname = MapXML(itm.ArtistName)
if artistname="" then
artistname = " "
end if
Dim songtitle
songtitle = MapXML(itm.title)
if songtitle="" then
songtitle = " "
end if
Dim albumname
albumname = MapXML(itm.AlbumName)
if albumname="" then
albumname = " "
end if
Dim songlength
songlength = itm.SongLengthString
SongsLength = SongsLength + itm.SongLength
if songlength="" then
songlength = " "
end if
Dim songgenre
songgenre = MapXML(itm.Genre)
if songgenre="" then
songgenre = " "
end if
Dim trackorder
trackorder = itm.TrackOrder
if trackorder="" then
trackorder = " "
elseif trackorder = "0" then
trackorder = " "
end if
' These are added to get some decent display, all the others haven't, this script is just to demonstrate all the available options
Dim rating
Dim ratingCal
rating = itm.Rating
Select Case rating
Case ""
ratingCal = " "
Case -1
ratingCal = " "
Case 100
ratingCal = 5
Case 90
ratingCal = 4.5
Case 80
ratingCal = 4
Case 70
ratingCal = 3.5
Case 60
ratingCal = 3
Case 50
ratingCal = 2.5
Case 40
ratingCal = 2
Case 30
ratingCal = 1.5
Case 20
ratingCal = 1
Case 10
ratingCal = 0.5
Case 0
ratingCal = 0
Case Else
ratingCal = " "
End Select
Dim medialabel
medialabel = MapXML(itm.MediaLabel)
if medialabel="" then
medialabel = " "
end if
' Body of the table
fout.WriteLine "<tr><td align=right class=dark>"&i+1&"</td><td>"&artistname&"</td><td class=dark>"&songtitle _
&"</td><td align=right>"&songlength&"</td><td class=dark>"&albumname _
&"</td><td align=right>"&trackorder&"</td><td align=right class=dark>"&Year _
&"</td><td>"&songgenre&"</td><td class=Dark>"&ratingCal&"</td><td align=right>"&bitrate _
&"</td><td align=right class=Dark>"&medialabel&"</td></tr>"
Progress.Value = i+1
if Progress.Terminate then
Exit For
end if
next
Dim Seconds
Dim Mins
Dim Hours
Seconds = Fix(SongsLength / 1000)
Mins = Fix(Seconds / 60)
Seconds = Seconds mod 60
Hours = Fix(Mins / 60)
Mins = Mins mod 60
Dim strTime
strTime = Hours & ":" & Right("0" & Mins, 2) & ":" & Right("0" & Seconds, 2)
' Write some code to finish html document
fout.WriteLine "</table><p/><table width=100%><tr>"
fout.WriteLine "<td style='border-bottom-width:0px'><b>"&SDB.Localize("Total Tracks:")&" </b>"&i&"</td>"
fout.WriteLine "<td style='border-bottom-width:0px'><b>"&SDB.Localize("Total time:")&" </b>" & strTime & "</td>"
fout.WriteLine "<td align=right style='border-bottom-width:0px'>Generated by <a href='http://www.mediamonkey.com'>MediaMonkey</a></td>"
fout.WriteLine "</tr></table></body></html>"
' Close the output file and finish
fout.Close
' Was it successfull?
Dim ok
if Progress.Terminate then
ok = False
else
ok = True
end if
' hide progress
Set Progress = Nothing
FinishExport( ok)
End Sub
Code: Select all
songlength = itm.SongLengthString
Dim Seconds
Dim Mins
Dim Hours
Seconds = Fix(SongsLength / 1000)
Mins = Fix(Seconds / 60)
Seconds = Seconds mod 60
Hours = Fix(Mins / 60)
Mins = Mins mod 60
Dim strTime
strTime = Hours & ":" & Right("0" & Mins, 2) & ":" & Right("0" & Seconds, 2)
fout.WriteLine "<td style='border-bottom-width:0px'><b>"&SDB.Localize("Total time:")&" </b>" & strTime & "</td>"