Auto/Cover Scripts

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Auto/Cover Scripts

Postby onkel_Enno » Tue Mar 29, 2005 12:25 am

The One which shows where the Album Art is stored (in Tag or in Extra-File):

See below:
http://www.mediamonkey.com/forum/viewto ... 7858#17858
onkel_Enno
 

Postby Guest » Tue Mar 29, 2005 12:26 am

The One which shows the Number of Album Arts
Code: Select all
Option Explicit

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'               Language Constants (ger)
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
const strCount = "Anzahl Covers"
const strUnknown = "unbekannt"

const strMyRoot = "Cover-Check" 'Caption
const strMyRootNode = "MyRootCoverNode" 'Object name

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'               Startup Function
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Sub onStartUp
  Dim Tree
  Set Tree = SDB.MainTree
  Dim myRootNode
  Dim NewTreeNode

  'Find existing Node
  set myRootNode = SDB.Objects(strMyRootNode)
  if myRootNode is nothing then
     'Create Root-Node if not existing
     Set myRootNode = Tree.CreateNode
     MyRootNode.Caption = strMyRoot
     MyRootNode.IconIndex = 23
     MyRootNode.UseScript = Script.ScriptPath
    Tree.AddNode Tree.Node_Playlists, MyRootNode, 1
    'Store CustomNodeRoot so it's available for manipulation later
    SDB.Objects(strMyRootNode) = MyRootNode
    myRootNode.hasChildren = True
  end if

  Set myRootNode = Tree.CreateNode
  MyRootNode.Caption = strCount
  MyRootNode.IconIndex = 23
  MyRootNode.UseScript = Script.ScriptPath
  MyRootNode.onFillChildren = "AddCount"
  Tree.AddNode SDB.Objects(strMyRootNode), MyRootNode, 3
  myRootNode.hasChildren = True
End Sub

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'               Creating Artist-Nodes
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Sub AddCount(Node)
   Dim Tree
   Set Tree = Sdb.MainTree
   Dim SQLStatement
   Dim DataSet
   Dim NewNode

   Node.HasChildren = False   ' To delete all old children

   SQLStatement = "Select a.b FROM (SELECT Covers.IDSong, Count(Covers.ID) AS b FROM Songs LEFT JOIN Covers ON Songs.ID=Covers.IDSong GROUP BY Covers.IDSong) AS a GROUP BY a.b"

   Set DataSet = SDB.Database.OpenSQL(SQLStatement)

   While Not DataSet.EOF
      Set newNode = Tree.CreateNode
      NewNode.Caption = DataSet.StringByIndex(0) & " Cover" 'Caption Artist
      NewNode.CustomData = DataSet.StringByIndex(0) 'Counter Covers
      NewNode.IconIndex = 28
      NewNode.UseScript = Script.ScriptPath
      NewNode.onFillChildren = "AddArtists"
      NewNode.onFillTracksFunct = "FillCountCovers"

      'Adding the Node to the Tree as last Child of the Node
      Tree.AddNode Node, NewNode, 3

      NewNode.hasChildren = True

      DataSet.Next
   Wend
End Sub

Sub AddArtists(Node)
   Dim Tree
   Set Tree = Sdb.MainTree
   Dim SQLStatement
   Dim DataSet
   Dim NewNode

   Node.HasChildren = False   ' To delete all old children

   SQLStatement = "Select a.ID, a.Artist FROM (SELECT Artists.ID, Artists.Artist FROM ((Songs INNER JOIN Albums ON Songs.IDAlbum = Albums.ID) INNER JOIN Artists ON Albums.IDArtist = Artists.ID) LEFT JOIN Covers ON Songs.ID = Covers.IDSong GROUP BY Artists.ID, Artists.Artist, Albums.ID, Songs.ID HAVING Count(Covers.ID)=" & Node.CustomData & ") AS a GROUP BY a.ID, a.Artist ORDER BY a.Artist"

   Set DataSet = SDB.Database.OpenSQL(SQLStatement)

   While Not DataSet.EOF
      Set newNode = Tree.CreateNode
      if DataSet.StringByIndex(1)="" then
         NewNode.Caption = strUnknown
      else
         NewNode.Caption = DataSet.StringByIndex(1) 'Caption Artist
      end if
      NewNode.CustomDataID = DataSet.StringByIndex(0) 'Key IDArtist
      NewNode.CustomData = Node.CustomData
      NewNode.IconIndex = 0
      NewNode.UseScript = Script.ScriptPath
      NewNode.onFillChildren = "AddAlbums"
      NewNode.onFillTracksFunct = "FillArtistCovers"

      'Adding the Node to the Tree as last Child of the Node
      Tree.AddNode Node, NewNode, 3

      NewNode.hasChildren = True

      DataSet.Next
   Wend
End Sub

Sub AddAlbums(Node)
   Dim Tree
   Set Tree = Sdb.MainTree
   Dim SQLStatement
   Dim DataSet
   Dim NewNode

   Node.HasChildren = False   ' To delete all old children

   SQLStatement = "SELECT a.ID, a.Year, a.Album FROM (SELECT Albums.ID, Albums.Album, Songs.Year FROM (Songs INNER JOIN Albums ON Songs.IDAlbum = Albums.ID) LEFT JOIN Covers ON Songs.ID = Covers.IDSong GROUP BY Albums.ID, Albums.Album, Songs.ID, Songs.Year, Albums.IDArtist HAVING Albums.IDArtist=" & Node.CustomDataID & " AND Count(Covers.ID)=" & Node.CustomData &") AS a GROUP BY a.ID, a.Album, a.Year ORDER BY a.Year, a.Album"

   Set DataSet = SDB.Database.OpenSQL(SQLStatement)

   While Not DataSet.EOF
      Set newNode = Tree.CreateNode
      NewNode.Caption = DataSet.StringByIndex(1) & " " & DataSet.StringByIndex(2) 'Caption Year and Album
      NewNode.CustomDataID = DataSet.StringByIndex(0) 'Key IDArtist
      NewNode.CustomData = Node.CustomData
      NewNode.IconIndex = 16
      NewNode.UseScript = Script.ScriptPath
      NewNode.onFillTracksFunct = "FillAlbumCovers"

      'Adding the Node to the Tree as last Child of the Node
      Tree.AddNode Node, NewNode, 3

      NewNode.hasChildren = False

      DataSet.Next
   Wend
End Sub

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'               Selecting Songs
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Sub FillCountCovers(Node) 'for root -> all Songs which have # Covers
   'needs too much time

   'Dim Tracks
   'Dim SQL

   'SQL = "SELECT Songs.ID FROM (Songs LEFT JOIN Covers ON Songs.ID = Covers.IDSong) GROUP BY Songs.ID HAVING Count(Covers.ID)=" & Node.CustomData

   'Set Tracks = SDB.MainTracksWindow
   'Tracks.AddTracksFromQuery("And Songs.ID In (" + SQL + ")")
   'Tracks.FinishAdding
End Sub

Sub FillArtistCovers(Node) 'for Artists -> all Songs which have # Covers
   Dim Tracks
   Dim SQL

   SQL = "SELECT Songs.ID FROM (Songs LEFT JOIN Covers ON Songs.ID=Covers.IDSong) INNER JOIN Albums ON Albums.ID=Songs.IDAlbum WHERE Albums.IDArtist=" & Node.CustomDataID & " GROUP BY Songs.ID HAVING Count(Covers.ID)=" & Node.CustomData

   Set Tracks = SDB.MainTracksWindow
   Tracks.AddTracksFromQuery("And Songs.ID In (" + SQL + ")")
   Tracks.FinishAdding
End Sub

Sub FillAlbumCovers(Node) 'for Albums -> all Songs which have # Covers
   Dim Tracks
   Dim SQL

   SQL = "SELECT Songs.ID FROM Songs LEFT JOIN Covers ON Songs.ID = Covers.IDSong GROUP BY Songs.ID, Songs.IDAlbum HAVING Songs.IDAlbum=" & Node.CustomDataID & " AND Count(Covers.ID)=" & Node.CustomData

   Set Tracks = SDB.MainTracksWindow
   Tracks.AddTracksFromQuery("And Songs.ID In (" + SQL + ")")
   Tracks.FinishAdding
End Sub
Guest
 

Postby onkel_enno » Tue Mar 29, 2005 12:29 am

(Damn, I wasn't Logged in)

The One which shows the Album-Art-Type:

See below:
http://www.mediamonkey.com/forum/viewto ... 7858#17858
Last edited by onkel_enno on Thu Jan 26, 2006 6:07 am, edited 1 time in total.
SansaMonkey - for SanDisk Sansa and Rockbox Users

Please no PMs for Questions which should be asked in the Forum. Thx
onkel_enno
 
Posts: 2139
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany

Postby onkel_enno » Tue May 03, 2005 2:03 am

Since MagicNodes 1.3 The CoverType and the Cover-Storage can be seen with the following Nodes: (examples)
Code: Select all
Cover-Type|show tracks:no\<Cover Type>\<artist>\<album|sort by:Max(Year)>
Cover-Storage|show tracks:no\<Cover Storage>\<artist>\<album|sort by:Max(Year)>


Thanks to Pablo. http://www.mediamonkey.com/forum/viewtopic.php?t=3358

Here is another Script which searches for inaccessable Cover-Arts (linked Files).
Create a DeadCoverLinks.vbs in the MediaMonkey\Script-Folder with the following content:
Code: Select all
Option Explicit

Sub OnStartUp()
   
   Dim FSO
   Dim SDB
   Dim Progress
   Set FSO = CreateObject("Scripting.FileSystemObject")
   Set SDB = CreateObject( "SongsDB.SDBApplication")
   Set Progress = SDB.Progress
   
   const SQLSelect = "SELECT Songs.ID, Medias.DriveLetter, Songs.SongPath, Covers.CoverPath, Artists.Artist, Songs.SongTitle"
   const SQLFrom   = "FROM Artists RIGHT JOIN ((Medias INNER JOIN Songs ON Medias.IDMedia = Songs.IDMedia) INNER JOIN Covers ON Songs.ID = Covers.IDSong) ON Artists.ID = Songs.IDArtist"
   const SQLWhere  = "WHERE Covers.CoverStorage=1"
   
   Dim Drive
   Dim Path
   Dim Cover
   Dim RecordSet
   Dim DeadLinks
   
   SDB.MainTree.CurrentNode = SDB.MainTree.Node_MyComputer 'to get sure that no other Titles are displayed
   SDB.MainTree.CurrentNode = SDB.MainTree.Node_Library
   
   Set RecordSet = SDB.DataBase.OpenSQL("Select Count(*) " & SQLFrom & " " & SQLWhere)
   Progress.MaxValue = RecordSet.ValueByIndex(0)
   Progress.Value = 0
   
   Set RecordSet = SDB.DataBase.OpenSQL(SQLSelect & " " & SQLFrom & " " & SQLWhere)
   Do While not RecordSet.EoF
      Progress.Text = SDB.Localize("Current song") & ": " & RecordSet.StringByName("Artist") & " - " & RecordSet.StringByName("SongTitle")
      if mid(RecordSet.StringByName("CoverPath"), 2, 1) =":" then
         Cover = RecordSet.StringByName("CoverPath")
      else
         Drive = Chr(RecordSet.ValueByName("DriveLetter") + 65)
         Path = FSO.GetFile(Drive & RecordSet.StringByName("SongPath")).ParentFolder
         Cover = Path & "\" & RecordSet.StringByName("CoverPath")
      end if
      if not FSO.FileExists(Cover) then
         DeadLinks = DeadLinks & RecordSet.StringByName("ID") & ", "
      end if
      RecordSet.Next
      Progress.Increase
      
      if Progress.Terminate then
        Exit Do
      end if
   Loop
   
   if Len(DeadLinks)>2 then
      DeadLinks = Left(DeadLinks, Len(DeadLinks)-2)
      Dim Tracks
      Set Tracks = SDB.MainTracksWindow
      Tracks.AddTracksFromQuery("And Songs.ID In (" + DeadLinks + ")")
      Tracks.FinishAdding
      Set Tracks = Nothing
   end if
   
   Set RecordSet = Nothing
   Set FSO = Nothing
   Set SDB = Nothing
   Set Progress = Nothing
end Sub



and add this Section to the Script.ini:
Code: Select all
[DeadCoverLinks]
FileName=DeadCoverLinks.vbs
ProcName=OnStartUp
Order=6
DisplayName=Not accessable Covers
Description=Shows all Tracks, which Cover's are not accessable
Language=VBScript
ScriptType=0


No guarantee at all :lol:
SansaMonkey - for SanDisk Sansa and Rockbox Users

Please no PMs for Questions which should be asked in the Forum. Thx
onkel_enno
 
Posts: 2139
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany


Return to Need Help with Addons?

Who is online

Users browsing this forum: No registered users and 10 guests