by Lowlander » Sun Oct 30, 2005 1:28 pm
This is the script I use to export the album art. It write the images with the album ID which is used by webmonkey.
Add to scripts.ini
Code: Select all
[ExportHTMLAlbumsART]
FileName=AlbumArt.vbs
ProcName=ExportAlbumArt
Order=100
DisplayName=Export Album Art
Description=
Language=VBScript
ScriptType=1
Create AlbumArt.vbs and add
Code: Select all
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' Original script by Jiri
' Modified by Martin Warning
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Option Explicit ' report undefined variables, ...
Dim fso
Dim strSaveToDir
Dim intImgWidth
' Change these values to your needs
strSaveToDir = "C:\Albums_files\"
intImgWidth = 200
Sub ExportAlbumArt
' initialize export
' Get a list of songs to be exported
Dim tracks, albums
Set tracks = SDB.CurrentSongList
' Check if user has selected tracks
Dim res
If tracks.count = 0 Then
res = SDB.MessageBox( SDB.Localize("Select tracks to be exported, please."), mtError, Array(mbOk))
Exit Sub
End If
' Connect to the FileSystemObject
Set fso = SDB.Tools.FileSystem
' Use progress to notify user about the current action
Dim Progress
Set Progress = SDB.Progress
Progress.Text = SDB.Localize("Exporting...")
Set albums = tracks.albums
albums.SortByArtist
fso.CreateFolder( strSaveToDir)
' Iterate through the list and export all songs
Progress.MaxValue = albums.count
Dim i, album, fname, falbum, AAs, AA, image, imagenew, newHeight
for i=0 to albums.count-1
Set album = albums.Item(i)
Set AAs = album.AlbumArt
If not AAs is Nothing Then
If AAs.Count>0 Then
Set AA = AAs.Item(0)
Set Image = AA.Image
If Not (Image Is Nothing) Then
If Image.Width>0 Then
newHeight = intImgWidth * Image.Height / Image.Width
Else
newHeight = 0
End If
Set ImageNew = Image.ConvertFormat( intImgWidth, newHeight, "image/jpeg", 85, -1)
If Not (ImageNew Is Nothing) Then
fname = fso.CorrectFilename(album.id) & ".jpg"
Set falbum = fso.CreateTextFile( strSaveToDir & fname, True)
falbum.WriteData ImageNew.ImageData, ImageNew.ImageDataLen
End If
End If
End If
End If
Progress.Value = i+1
if Progress.Terminate then
Exit For
end if
next
' Was it successfull?
Dim ok
if Progress.Terminate then
ok = False
else
ok = True
end if
' hide progress
Set Progress = Nothing
End Sub
This is the script I use to export the album art. It write the images with the album ID which is used by webmonkey.
[b]Add to scripts.ini[/b]
[code]
[ExportHTMLAlbumsART]
FileName=AlbumArt.vbs
ProcName=ExportAlbumArt
Order=100
DisplayName=Export Album Art
Description=
Language=VBScript
ScriptType=1
[/code]
[b]Create AlbumArt.vbs and add[/b]
[code]
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' Original script by Jiri
' Modified by Martin Warning
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Option Explicit ' report undefined variables, ...
Dim fso
Dim strSaveToDir
Dim intImgWidth
' Change these values to your needs
strSaveToDir = "C:\Albums_files\"
intImgWidth = 200
Sub ExportAlbumArt
' initialize export
' Get a list of songs to be exported
Dim tracks, albums
Set tracks = SDB.CurrentSongList
' Check if user has selected tracks
Dim res
If tracks.count = 0 Then
res = SDB.MessageBox( SDB.Localize("Select tracks to be exported, please."), mtError, Array(mbOk))
Exit Sub
End If
' Connect to the FileSystemObject
Set fso = SDB.Tools.FileSystem
' Use progress to notify user about the current action
Dim Progress
Set Progress = SDB.Progress
Progress.Text = SDB.Localize("Exporting...")
Set albums = tracks.albums
albums.SortByArtist
fso.CreateFolder( strSaveToDir)
' Iterate through the list and export all songs
Progress.MaxValue = albums.count
Dim i, album, fname, falbum, AAs, AA, image, imagenew, newHeight
for i=0 to albums.count-1
Set album = albums.Item(i)
Set AAs = album.AlbumArt
If not AAs is Nothing Then
If AAs.Count>0 Then
Set AA = AAs.Item(0)
Set Image = AA.Image
If Not (Image Is Nothing) Then
If Image.Width>0 Then
newHeight = intImgWidth * Image.Height / Image.Width
Else
newHeight = 0
End If
Set ImageNew = Image.ConvertFormat( intImgWidth, newHeight, "image/jpeg", 85, -1)
If Not (ImageNew Is Nothing) Then
fname = fso.CorrectFilename(album.id) & ".jpg"
Set falbum = fso.CreateTextFile( strSaveToDir & fname, True)
falbum.WriteData ImageNew.ImageData, ImageNew.ImageDataLen
End If
End If
End If
End If
Progress.Value = i+1
if Progress.Terminate then
Exit For
end if
next
' Was it successfull?
Dim ok
if Progress.Terminate then
ok = False
else
ok = True
end if
' hide progress
Set Progress = Nothing
End Sub
[/code]