Here is a script to create an Album Artists Node

Post a reply

Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

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

Topic review
   

Expand view Topic review: Here is a script to create an Album Artists Node

by trixmoto » Thu Sep 08, 2005 4:21 am

I'm sure I'll learn to use Magic Nodes properly soon, but for now this script does the job. Cheers!

by onkel_enno » Thu Sep 08, 2005 3:53 am

trixmoto wrote:I now use Magic Nodes and agree it is great. I still use this script though because it uses the Artist icon and puts the node in the right place.
Same things can be done with MagicNodes.
KeyWords: "icon:" and "child of:"

by trixmoto » Thu Sep 08, 2005 3:48 am

I now use Magic Nodes and agree it is great. I still use this script though because it uses the Artist icon and puts the node in the right place.

by rk » Wed Sep 07, 2005 5:39 am

Yes, try Magic Nodes! It is highly flexible!

Re: Thanks

by onkel_enno » Wed Sep 07, 2005 5:35 am

trixmoto wrote:This is excellent, thank you!
You can also use Magic Nodes for things like that.

Thanks

by trixmoto » Wed Sep 07, 2005 5:25 am

This is excellent, thank you!

Here is a script to create an Album Artists Node

by jmaver » Fri Jan 21, 2005 10:42 am

Code: Select all

' Adds an album artist field
'

Sub OnStartup
  Dim Tree
  Set Tree = SDB.MainTree

  Dim AlbArtNode
  Set AlbArtNode= Tree.CreateNode
  AlbArtNode.Caption = "Album Artists"
  AlbArtNode.IconIndex = 0
  AlbArtNode.UseScript = Script.ScriptPath
  AlbArtNode.OnFillChildren = "FillAlbumArtists"

  Tree.AddNode Tree.Node_Library, AlbArtNode, 2
  AlbArtNode.HasChildren = true
End Sub

Sub FillAlbumArtists(Node)
  Node.HasChildren = false
 Dim Tree, Iter
  Set Tree = SDB.MainTree
  Set Iter = SDB.Database.OpenSQL( "SELECT DISTINCT Artists.Artist, Artists.ID FROM (Albums INNER JOIN Artists ON Albums.IDArtist = Artists.ID) WHERE Albums.IDArtist <> 0 ORDER BY Artists.Artist" ) 

  While Not Iter.EOF
    Set NewNode = Tree.CreateNode
    NewNode.Caption = Iter.StringByIndex(0)
    NewNode.CustomData = Iter.ValueByIndex(1)
    NewNode.IconIndex = 0
    NewNode.UseScript = Script.ScriptPath
    NewNode.OnFillChildren = "FillAlbums"
    NewNode.OnFillTracksFunct = "FillArtistTracks"
    Tree.AddNode Node, NewNode, 3     '  Add as the last child
    NewNode.HasChildren = true
    Iter.Next
  WEnd
End Sub

Sub FillAlbums(Node)
  'Node.CustomData contains Artists.ID
  Node.HasChildren = false
 
  Set Tree = SDB.MainTree
  Set Iter = SDB.Database.OpenSQL( "SELECT Albums.Album, Albums.ID FROM Albums WHERE Albums.IDArtist= " & Node.CustomData & " Order BY Album")

  While Not Iter.EOF
    Set NewNode = Tree.CreateNode
    NewNode.Caption = Iter.StringByIndex(0)
    NewNode.CustomData = Iter.ValueByIndex(1)
    NewNode.IconIndex = 16
    NewNode.UseScript = Script.ScriptPath
    NewNode.OnFillTracksFunct = "FillTracks"
    Tree.AddNode Node, NewNode, 3     '  Add as the last child
    Iter.Next
  WEnd
End Sub

Sub FillArtistTracks( Node)
  'Node.CustomData contains Artists.ID
  Set Trcks = SDB.MainTracksWindow

  Trcks.AddTracksFromQuery( "and Songs.ID in (SELECT Songs.ID FROM Songs,Albums WHERE Songs.IDAlbum=Albums.ID AND Albums.IDArtist="& Node.CustomData & ")")
  Trcks.FinishAdding
End Sub

Sub FillTracks( Node)
  'Node.CustomData contains Albums.ID
  Set Trcks = SDB.MainTracksWindow

  Trcks.AddTracksFromQuery( "and Songs.ID in (SELECT ID FROM Songs WHERE IDAlbum="& Node.CustomData & ")")
  Trcks.FinishAdding
End Sub

Top