View Single Post
Old 18th February 2006, 19:44   #330
MarquisEXB
Junior Member
 
Join Date: May 2005
Posts: 23
Oh and if you want a script that will give you X number of albums, without repeating the same artist, use this script.

You'll want to edit this section, it should be relatively self explanatory. The genres are comma seperated, and each one will give you Genre Begins 'XXX'. Year will give me a year between today & 1977.

PHP Code:
genres=cSTR(InputBox("Genre(s) BEGINS with... ?","GENRES","alt,new,punk,lo,hip-r,ska"))
Randomize
ranYear 
int(rnd()*datediff("yyyy"#01-01-1977#, now())) + 1977
years=cSTR(INputBox("Year? [ex: > 2000) -- or > 1995 AND Year < 2000]","YEAR","year >= " ranYear))
ratings cSTR(InputBox("Ratings?","Rating","rating > 1 "))
Extra=cSTR(INputBox("Extra? [ex: & (lastplay < [3 weeks ago] OR playcount < 1)","EXTRA","(lastplay < [3 weeks ago] OR playcount < 1)")) 
playlist_1_Albums_Random.vbs

PHP Code:
on error resume next
Randomize

'dim i,j,Dict1,tracks,num,idxs 

TheQuery=getMLQquery("type=0 &! (album ISEMPTY)")
msgbox TheQuery

mlq = medialibrary.runqueryarray(TheQuery)

Set Dict1 = CreateObject("Scripting.dictionary") 
Dict1.CompareMode = BinaryCompare 

i = 0
AllAlbums="" ' 
string that contains all album names

for each track in mlq 
if instr(AllAlbums,ucase(track.album)) = 0 then
    i 

    AllAlbums
=AllAlbums&vbcrlfucase(track.album)
    
Dict1(ucase(track.artist))=Dict1(ucase(track.artist)) & vbcrlf _
         CStr
(i) & asc(178) & ucase(track.album)
end if
next 

itms 
Dict1.Items 
numArt
=ubound(itms)+

num 
CInt(InputBox("Albums: " vbcrlf 
        
"Artists: " numArt vbcrlf 
         
"Choose the # of albums","#","3")) 

if 
numart>=num then 

do while (tracks<num

safe 

        
do 
                
safe=safe+
            Randomize 
                RandArtist 
Int(numArt*Rnd' This is the artist 
        loop until (safe > 10000) or (instr(AllArtists,RandArtist & ";")=0) 

        AllArtists=AllArtists & RandArtist & ";" 
        '
msgbox AllArtists vbcrlf "-" itms(rand

        
arrSong Split(itms(RandArtist ), vbcrlf
        
Randomize 
        TheAlbum 
split(arrSong(int(ubound(arrSong)*RND +1)),asc(178) )(1)
            
        
InsertAlbum theAlbum

        tracks
=tracks+
Loop 
else 
msgbox "Too many songs" 
end if 

quit 

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 
''''''''''''''''''''''''''''' FUNCTIONS
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 

function InsertAlbum(thealbum)

mlq2 = medialibrary.runqueryarray("album = """ + thealbum + """")
Set Dict2 = CreateObject("Scripting.dictionary") 
Dict2.CompareMode = BinaryCompare 

i = 0
min=1000000
max=0

This section is to sort by track number.

for 
each song in mlq2
    i
=i+1
    theTrack
=song.track
    Dict1
(theTrack)=i
    
if theTrack<min then
        min
=theTrack
    end 
if
    if 
theTrack>Max then
        max
=theTrack
    end 
if
next

for zmin to max
    
if len(dict1(z)) > 0 then
        mlq2
(dict1(z)).enqueue
    end 
if
next 'z

 set sep = LoadItem("X:-- " & thealbum  & " (" & ubound(mlq2) & ") --------------------------")
 sep.insert(playlist.count)

mlq2=""
end function

private function getMLQquery(strInitial)
This asks the user some questions so that 
' you can choose music as you see fit.

dim genres,years,ratings,extra

genres=cSTR(InputBox("Genre(s) BEGINS with... ?","GENRES","alt,new,punk,lo,hip-r,ska"))
Randomize
ranYear = int(rnd()*datediff("yyyy", #01-01-1977#, now())) + 1977
years=cSTR(INputBox("Year? [ex: > 2000) -- or > 1995 AND Year < 2000]","YEAR","year >= " & ranYear))
ratings = cSTR(InputBox("Ratings?","Rating","rating > 1 "))
Extra=cSTR(INputBox("Extra? [ex: & (lastplay < [3 weeks ago] OR playcount < 1)","EXTRA","(lastplay < [3 weeks ago] OR playcount < 1)"))

if len(extra) > 0 then
    extra = " & (" & extra & ") "
end if

if len(ratings) > 0 then
    ratings = " & (" & ratings & ") "
end if

if len(years) > 0 then
    years = " & (" & years & ") "
end if

if len(genres) > 0 then

genre=split(genres,",")

if ubound(genre) >0 then
genreline="&  ("
    for each onegenre in genre
        genreline=genreline & " genre begins """ & onegenre & """ OR "
    next
genreline = genreline & " Genre begins "" QQQ "") "
else
genreline="& GENRE BEGINS """ + genre(0) +""""

end if
else
genreline=""
end if

GetMLQquery= strInitial &ratings & genreline & years &extra
end function 
MarquisEXB is offline   Reply With Quote