Export Artist-Album List to HTML

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Export Artist-Album List to HTML

correction

by AlanB » Mon Feb 23, 2004 6:06 pm

OK, so I couldn't try it, so it didn't work. But it was close. This I have tried and it does work...

You would need to use .Artist.Name instead of .ArtistName
and .Name instead of .AlbumName.
Hence the appropriate part of your script becomes...

' Add space to empty fields, so table is displayed correctly (Cell borders do not show up for empty cells)
Dim artistname
artistname = itm.Artist.Name
if artistname="" then
artistname = "& n b s p"
end if

Dim albumname
albumname = itm.Name
if albumname="" then
albumname = "& n b s p"
end if

note... remove spaces from "& n b s p"

If I have copied that in correctly, the script should now run (mine does).

Good luck, AlanB

a suggestion

by AlanB » Mon Feb 23, 2004 7:25 am

I did it using Access, but a script solution would be better (but I am still learning here also).

Since you haven't received an answer from anyone more knowlegable, I offer my suggestion.
Refereing to the idl already mentioned at
http://www.songs-db.com/Songs-DB.idl

I suspect that you are trying to access the wrong member property. All the previous scripts have obtained a song list and hence rely on the interfaces ISDBSongList and hence .Item yields a ISDBSongData (i.e. .ArtistName, AlbumName etc). However, you have used the ISDBSongList .Albums member to obtain an album list, hence the .Item property will yield a ISDBAlbum instead, hence you need to consider its members.

I this is correct, then you would need to use .Artist instead of .ArtistName and .Name instead of .AlbumName.

I hope this is correct, in which case it might help.


AlanB

Not sure

by Lowlander » Fri Feb 20, 2004 3:29 pm

My first guess is that the connection with MM has an error. But I can't verify your code right now.

You might want to use this code which can be found on the page I previously mentioned. It might get close to your desired results.
http://www.songs-db.com/forum/viewtopic.php?p=2395#2395

Export Artist-Album list to HTML

by Frodo56us » Fri Feb 20, 2004 3:14 pm

I've looked at those, but I must be too dense to make a lot of sense out of them. I am totally new to writing scripts.

I've created two seperate vbscripts, one for exporting all my songs to HTML which works fine. However the one for the Artist/Albums doesn't work. Really these are just edited versions of the HTML section of the original. Here is the offending script:

Option Explicit ' report undefined variables, ...

' function for quoting strings
Function QStr( astr)
QStr = chr(34) & astr & chr(34)
End Function

Dim list ' list of albums to be exported
Dim res ' results of dialogs calls
Dim fullfile ' fully specified output file name
Dim fso ' FileSystemObject

' SDB variable is connected to MediaMonkey application object

Sub InitExport( ext, filter, iniDirValue)
fullfile = ""

' Get a list of albums to be exported
Set list = SDB.SelectedSongList.Albums
If list.count=0 Then
Set list = SDB.AllVisibleSongList.Albums
End If

If list.count=0 Then
res = SDB.MessageBox( "Select Albums to be exported, please.", mtError, Array(mbOk))
Exit Sub
End If

' Open inifile and get last used directory
Dim iniF
Set iniF = SDB.IniFile

' Create common dialog and ask where to save the file
Dim dlg
Set dlg = SDB.CommonDialog
dlg.DefaultExt=ext
dlg.Filter=filter
dlg.Flags=cdlOFNOverwritePrompt + cdlOFNHideReadOnly
dlg.InitDir = iniF.StringValue( "Scripts", iniDirValue)
dlg.ShowSave

if Not dlg.Ok Then
Exit Sub ' if cancel was pressed, exit
End If

' Get the selected filename
fullfile = dlg.FileName

' Connect to the FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")

' Write selected directory to the ini file
iniF.StringValue( "Scripts", iniDirValue) = fullfile
End Sub

Sub FinishExport( ok)
On Error Resume Next

' remove the output file if terminated
if not Ok then
fso.DeleteFile( fullfile)
end if

' Notify user that it was successful
if ok then
res = SDB.MessageBox( "Export was completed successfully.", mtInformation, Array(mbOk))
else
res = SDB.MessageBox( "Export was terminated.", mtInformation, Array(mbOk))
end if
End Sub

Sub HTMLAlbumList
' 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>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>MediaMonkey Track List</H1></a>"

' Headers of table
fout.WriteLine "<TABLE CELLPADDING=4 CELLSPACING=0>"
fout.WriteLine "<tr>"
fout.WriteLine " <th ID=dark>#</th>"
fout.WriteLine " <th>Artist</th>"
fout.WriteLine " <th ID=dark>Album</th>"
fout.WriteLine "</tr>"

' Use progress to notify user about the current action
Dim Progress
Set Progress = SDB.Progress
Progress.Text = "Exporting to a HTML file..."

' Iterate through the list and export all songs
Progress.MaxValue = list.count
Dim i, itm
for i=0 to list.count-1
Set itm = list.Item(i)

' Add space to empty fields, so table is displayed correctly (Cell borders do not show up for empty cells)
Dim artistname
artistname = itm.ArtistName
if artistname="" then
artistname = "&"
end if

Dim albumname
albumname = itm.AlbumName
if albumname="" then
albumname = "&"
end if

' Body of the table
fout.WriteLine "<tr><td align=right class=dark>"&i+1 _
&"</TD><TD>"&artistname _
&"</td><td class=dark>"&albumname _
&"</td></tr>"
Progress.Value = i+1
if Progress.Terminate then
Exit For
end if
next

' Write some code to finish html document
fout.WriteLine "</table><p/><table width=100%><tr>"
fout.WriteLine "<td style='border-bottom-width:0px'><B>Total Tracks: </B>"&i&"</td> <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


Which gives me the following error:

Error #438 - Microsoft VBScript Runtime Error
Object doesn't support this property or method: 'itm.artistname'
File "C:\Program Files\MediaMonkey\Scripts\HTMLAlbumList.vbs",
Line: 122, Column: 4


Think anyone more knowledgable than me can take a look at my code and see what I am doing wrong?

Frodo

Check these out

by Lowlander » Fri Feb 20, 2004 12:14 pm

Export Artist-Album List to HTML

by Frodo56us » Fri Feb 20, 2004 12:10 pm

Argh, that part works, but now I'm getting other errors from the script. It doesn't like where I've tried to dim the Year and Album stuff. I'll look at the xml portion of the original script and see what it's doing.

Frodo

Export Artist-Album List to HTML

by Frodo56us » Fri Feb 20, 2004 12:10 pm

Argh, that part works, but now I'm getting other errors from the script. It doesn't like where I've tried to dim the Year and Album stuff. I'll look at the xml portion of the original script and see what it's doing.

Frodo

by jiri » Fri Feb 20, 2004 11:50 am

Yes, should work fine.

Jiri

Export Artist-Album to HTML

by Frodo56us » Fri Feb 20, 2004 11:03 am

Sweet! Do you know if SDB.SelectedSongList.Albums will work as well?

Frodo

by jiri » Fri Feb 20, 2004 2:18 am

You can use SDB.SelectedSongList.Artists to get a list of all artists in the selected list. An example of this is in the XML export script.

Jiri

Export Artist-Album list to HTML

by Frodo56us » Thu Feb 19, 2004 11:59 pm

It doesn't like SDB.SelectedArtists or SelectedAlbums either.

If I use the SelectedSongList like the track export, I get a bunch of redundant entries. Since I am really wanting a list of Albums, I guess I need the object name for the selected albums.

I am new to VBScript, so please bear with me.

Frodo

Export Artist-Album List to HTML

by Frodo56us » Thu Feb 19, 2004 11:47 pm

Anyone know the object name I would use in this type of script to pull the Artist or Album? I tried this:

' Get a list of albums to be exported
Set list = SDB.Artists
If list.count=0 Then
Set list = SDB.Artists
End If


But it didn't work. Said it didn't like that object name. I don't want a list of all the tracks, just a list of the Artists and Albums. Any ideas on how to do this?

Thanks!

Top