Missing Album Art 2.0 [MM2+3]
Posted: Mon Jul 03, 2006 7:31 am
This script creates a node under Files To Edit called Missing Album Art. This node is populated with all the tracks which have external artwork and the files do not exist.
To populate this node you need to run the report with the same name. It will take several minutes to populate, depending on the size of your library - which is why it is run in the background.
The installer can be downloaded directly from my website. Enjoy!
To populate this node you need to run the report with the same name. It will take several minutes to populate, depending on the size of your library - which is why it is run in the background.
The installer can be downloaded directly from my website. Enjoy!
Code: Select all
'
' MediaMonkey Script
'
' NAME: MissingAlbumArt 2.0
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 17/08/2008
'
' INSTALL: Copy to Scripts\Auto directory and add the following to Scripts.ini
' Don't forget to remove comments (') and set the order appropriately'
'
' [MissingAlbumArt]
' FileName=Auto\MissingAlbumArt.vbs
' ProcName=MissingAlbumArt
' Order=10
' DisplayName=Missing Album Art
' Description=Populates Missing Album Art node
' Language=VBScript
' ScriptType=1
'
Option Explicit
Sub onStartUp()
'create node and add to tree
Dim tree : Set tree = SDB.MainTree
Dim node : Set node = tree.CreateNode
node.Caption = "Missing Album Art"
node.IconIndex = 55
node.UseScript = Script.ScriptPath
node.OnFillTracksFunct = "ShowMissing"
node.SortCriteria = 2
Call tree.AddNode(tree.Node_FilestoEdit,node,3)
Set SDB.Objects("MissingAlbumArtNode") = node
End Sub
Sub ShowMissing(node)
'check for list
Dim list : Set list = SDB.Objects("MissingAlbumArtList")
If list Is Nothing Then
'warn node not yet populated
Call SDB.MessageBox("MissingAlbumArt: You need to select 'File|Create Reports|Missing Album Art' from the menu before this node will be populated.",mtInformation,Array(mbOk))
Else
'add list to main window
Dim trax : Set trax = SDB.MainTracksWindow
Dim i : i = 0
For i = 0 To list.Count-1
Call trax.AddTrack(list.Item(i))
SDB.ProcessMessages
Next
'finish off
trax.FinishAdding
End If
End Sub
Sub MissingAlbumArt
'reset list
Set SDB.Objects("MissingAlbumArtList") = Nothing
Dim list : Set list = SDB.NewSongList
Dim fso : Set fso = SDB.Tools.FileSystem
'create progress bar
Dim prog : Set prog = SDB.Progress
prog.Value = 0
Dim iter : Set iter = SDB.Database.OpenSQL("SELECT Count(*) AS SongCount FROM Songs")
prog.MaxValue = iter.ValueByName("SongCount")
prog.Text = "MissingAlbumArt: Initialising..."
'loop through tracks
Dim i : i = 0
Dim j : j = 0
Set iter = SDB.Database.QuerySongs("")
Do While Not iter.EOF
'update progress bar
prog.Increase
prog.Text = "MissingAlbumArt: Checking track "&prog.Value&"/"&prog.MaxValue&" (found: "&j&")..."
SDB.ProcessMessages
'check for artwork
Dim art : Set art = iter.Item.AlbumArt
If Not (art Is Nothing) Then
'loop through track artwork
For i = 0 To art.Count-1
'check for linked artwork
If art.Item(i).ItemStorage = 1 Then
'check if file exists
If Not fso.FileExists(art.Item(i).PicturePath) Then
'add track to list
list.Add(iter.Item)
j = j + 1
End If
End If
Next
End If
'check next track
If prog.Terminate Then
Exit Do
Else
iter.Next
End If
Loop
'finish off
Set prog = Nothing
Set SDB.Objects("MissingAlbumArtList") = list
Dim res : res = SDB.MessageBox("MissingAlbumArt: Do you want to see the results now?",mtConfirmation,Array(mbYes,mbNo))
If res = mrYes Then
'show node
Dim tree : Set tree = SDB.MainTree
Dim node : Set node = SDB.Objects("MissingAlbumArtNode")
tree.CurrentNode = tree.Node_Library
tree.Node_Library.Expanded = True
tree.CurrentNode = tree.Node_FilestoEdit
tree.Node_FilestoEdit.Expanded = True
tree.CurrentNode = node
End If
End Sub
Sub Install()
Dim inip : inip = SDB.ApplicationPath&"Scripts\Scripts.ini"
Dim inif : Set inif = SDB.Tools.IniFileByPath(inip)
If Not (inif Is Nothing) Then
inif.StringValue("MissingAlbumArt","Filename") = "Auto\MissingAlbumArt.vbs"
inif.StringValue("MissingAlbumArt","Procname") = "MissingAlbumArt"
inif.StringValue("MissingAlbumArt","Order") = "10"
inif.StringValue("MissingAlbumArt","DisplayName") = "Missing Album Art"
inif.StringValue("MissingAlbumArt","Description") = "Populates Missing Album Art node"
inif.StringValue("MissingAlbumArt","Language") = "VBScript"
inif.StringValue("MissingAlbumArt","ScriptType") = "1"
SDB.RefreshScriptItems
End If
Call onStartUp()
End Sub