Page 1 of 1

Just List Artists 1.1 [MM2+3]

Posted: Wed Sep 20, 2006 2:55 pm
by trixmoto
As requested here, this script lists all of the artists from your list of visible (or selected) tracks, in a simple text file.

If you want to print an alphabetical list of all your artists then click on the Artists node, and then the Artist column to sort, before running the report.

The installer is available from my website.

Code: Select all

'
' MediaMonkey Script
'
' NAME: JustListArtists 1.1
'
' AUTHOR: trixmoto (http://trixmoto.net)
' DATE : 20/03/2008
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini 
'          Don't forget to remove comments (') and set the order appropriately
'
' [JustListArtists]
' FileName=JustListArtists.vbs
' ProcName=JustListArtists
' Order=2
' DisplayName=Just List Artists
' Description=Just List Artists
' Language=VBScript
' ScriptType=1
'
' Fixes: Made compatible with MM3
'

Option Explicit

Sub JustListArtists 

  Dim list : Set list = SDB.CurrentSongList
  If list.Count = 0 Then
    Call SDB.MessageBox(SDB.Localize("Select tracks to be exported, please."), mtError, Array(mbOk))
    Exit Sub
  End If
  If SDB.VersionHi < 3 Then
    Set list = list.Artists
  End If  
  
  Dim fso : Set fso = SDB.Tools.FileSystem
  Dim path : path = Script.ScriptPath&".txt"
  Dim fout : Set fout = fso.CreateTextFile(path,True) 
  Dim dic : Set dic = CreateObject("Scripting.Dictionary")
  
  Dim Progress : Set Progress = SDB.Progress 
  If SDB.VersionHi < 3 Then
    Progress.MaxValue = list.Count
  Else
    Progress.MaxValue = list.Count*2
  End If
  Progress.Text = SDB.Localize("Exporting...")

  Dim i,j,itm,arr
  For i = 0 To list.Count-1 
    Set itm = list.Item(i) 
    If SDB.VersionHi < 3 Then
      If itm.ID > 0 Then 
        Call fout.WriteLine(itm.Name)
      End If
    Else
      arr = Split(itm.ArtistName,";")
      For j = 0 To UBound(arr)
        dic.Item(Trim(arr(j))) = ""
      Next
    End If
    
    Progress.Increase
    SDB.ProcessMessages
    If Progress.Terminate Then 
      Exit For 
    End If 
  Next 
  
  If SDB.VersionHi > 2 Then
    arr = dic.Keys
    Call SortArray(arr)
    Progress.MaxValue = list.Count+dic.Count
    For i = 0 To UBound(arr)
      Call fout.WriteLine(arr(i))
      Progress.Increase
      SDB.ProcessMessages
      If Progress.Terminate Then 
        Exit For 
      End If 
    Next      
  End If

  fout.Close 
  If Not Progress.Terminate Then 
    Dim WShell : Set WShell = CreateObject("WScript.Shell")
    i = WShell.Run(Chr(34)&path&Chr(34),1,0)
  End If 
End Sub 

Sub SortArray(arr)
  Call QuickSort(arr,LBound(arr),UBound(arr))
End Sub

Sub QuickSort(vec,loBound,hiBound)
  Dim pivot,loSwap,hiSwap,temp

  If hiBound - loBound = 1 Then
    If Vec(loBound) > Vec(hiBound) Then
      temp = Vec(loBound)
      Vec(loBound) = Vec(hiBound)
      Vec(hiBound) = temp
    End If
  End If

  pivot = Vec(Int((loBound + hiBound) / 2))
  Vec(Int((loBound + hiBound) / 2)) = Vec(loBound)
  Vec(loBound) = pivot
  loSwap = loBound + 1
  hiSwap = hiBound
  
  Do
    While loSwap < hiSwap And Vec(loSwap) <= pivot
      loSwap = loSwap + 1
    WEnd
    While Vec(hiSwap) > pivot
      hiSwap = hiSwap - 1
    WEnd
    If loSwap < hiSwap then
      temp = Vec(loSwap)
      Vec(loSwap) = Vec(hiSwap)
      Vec(hiSwap) = temp
    End If
  Loop While loSwap < hiSwap
  
  Vec(loBound) = Vec(hiSwap)
  Vec(hiSwap) = pivot
  
  If loBound < (hiSwap - 1) Then 
    Call QuickSort(vec,loBound,hiSwap-1)
  End If
  If hiSwap + 1 < hibound Then 
    Call QuickSort(vec,hiSwap+1,hiBound)
  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("JustListArtists","Filename") = "JustListArtists.vbs"
    inif.StringValue("JustListArtists","Procname") = "JustListArtists"
    inif.StringValue("JustListArtists","Order") = "2"
    inif.StringValue("JustListArtists","DisplayName") = "Just List Artists"
    inif.StringValue("JustListArtists","Description") = "Just List Artists"
    inif.StringValue("JustListArtists","Language") = "VBScript"
    inif.StringValue("JustListArtists","ScriptType") = "1"
    SDB.RefreshScriptItems
  End If
End Sub

Request

Posted: Fri Feb 02, 2007 5:02 am
by Kos
Is it possible to expand this script just a little bit? I very much would like a report with Artist, album and perhaps year....

Kos

Posted: Fri Feb 02, 2007 8:53 am
by trixmoto
The idea of this script is that it just lists the artists in your collection. Maybe my Just List Albums will be more useful to you.

Tried that as well...

Posted: Fri Feb 02, 2007 10:08 am
by Kos
but no.... I need a list (alphabetically) like this - people tend to remember artists more than album title (the individual song title is not important):


AC/DC Highway to hell 19xx
AC/DC Back in Black 19xx
Blondie Greatest hits 19xx
etc.

Kos

Posted: Thu Mar 20, 2008 3:08 pm
by trixmoto
New version (1.1) is now available to download from my website. I have made it compatible with MM3.

Posted: Tue Apr 15, 2008 10:44 am
by sommo
Thanking you!
Is there anything you cant do!?

Re: Just List Artists 1.1 [MM2+3]

Posted: Tue Jan 06, 2009 8:06 pm
by nynaevelan
TM:

I get the following error when trying to run JLA in 3.1.0.1208:

Image

Nyn

Re: Just List Artists 1.1 [MM2+3]

Posted: Wed Jan 07, 2009 4:40 am
by trixmoto
The only reason I can guess this would be happening is if the "ArtistName" property is not returning any values - which would be a bug the developers would need to fix. I'll investigate further when I get a chance though.

Re: Just List Artists 1.1 [MM2+3]

Posted: Wed Jan 07, 2009 5:23 am
by nynaevelan
TM:

I think we can chalk this up to user error, I must have selected something weird, or nothing at all because it is working perfectly now. Sorry. :oops:

Nyn

Re: Just List Artists 1.1 [MM2+3]

Posted: Wed Jan 07, 2009 9:18 am
by trixmoto
Hmm, strange. :-?

Re: Just List Artists 1.1 [MM2+3]

Posted: Tue Mar 23, 2010 4:43 pm
by hurtaxis
Is there any possible way to create a list with a comma and a space in between the artists instead of a new line?

Re: Just List Artists 1.1 [MM2+3]

Posted: Wed Mar 24, 2010 4:58 am
by trixmoto
You could do this by opening "JustListArtists.vbs" in a text editor and replacing line 55...

Code: Select all

Call fout.WriteLine(itm.Name)
...with...

Code: Select all

Call fout.Write(itm.Name&", ")
...and line 76...

Code: Select all

Call fout.WriteLine(arr(i))
...with...

Code: Select all

Call fout.Write(arr(i)&", ")