by some1 » Tue Jul 17, 2007 4:02 pm
Thanks, but I dont use MagicNode (tbh, not sure why...Will download it, after posting this!)
Anyway, I did a scrpit for it, (which Ive rush, and I dont believe I will ever update it!), anyway, here it is....
Code: Select all
' _ _
' (_) |
' __ ___| |___ ___ _ __
' \ \ /\ / / | / __|/ _ \| '_ \
' \ V V /| | \__ \ (_) | | | |
' \_/\_/ |_|_|___/\___/|_| |_|
'
' *************************************************
' * Program : [MediaMonkey v2.5] FindTheSmallAlbum *
' * Ver : 0.1 *
' * Date : 17/07/2007 *
' * Author : Wilson *
' * Purpose : Script for MM to find missing track *
' *************************************************
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
'Install from scrpit:
' 1) Find the "Auto" Folder ("Mediamonkey\Scripts\Auto") . Right click --> create a new/blank text file.
' 2) Name it FindTheSmallAlbum.vbs
' Make sure its a VBS file, i.e. the file isn't named FindTheMissing.vbs.txt. If this was done correctly, then the icon should of changed
' If it did NOT then, To always display all filenames with extension in explorer, do this:
' 1.). In explorer, go to Tools->Folder Options->View Tab
' 2.) Uncheck "hide file extensions for known file types"
' 3) Copy all this code into the file and save it.
' 4) (Re)start MediaMonkey
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
'Version History/Change Log:
' v0.1 (17/07/07)
' * Had the Idea.
' * First Release to public (MM forumss).
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
'ToDos:
' * List all albums (but it then cant read Node.CustomData)
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
'WishList:
' * Rename this, and add in [FindTheMissing] Songs, to [FindThe]Missing Songs, [FindThe] ShortAlbums
' * Do other album functions (tho its been done before in "Tagging Inconsistencies")
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
' Authors Notes:
' * Should it be "albums with 4 tracks" or "albums with 4 tracks OR LESS"?
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
' Global Variables and Declarations
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
Function albumCaption(artist, album)
albumCaption = album & " - " & artist
'<---Different sorting methods ---- >
' albumCaption = artist & " - " & album
' albumCaption = album & " - " & artist
' albumCaption = album
End Function
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
' Startup Function (when the first is first run, when MM starts)
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
Sub onStartUp
Dim Tree, Iter
Dim sql
Dim Node
Set Node= SDB.MainTree.createNode
Node.Caption = "[FindThe] ShortAlbums"
Node.IconIndex = 40
Node.UseScript = Script.ScriptPath
Script.RegisterEvent node, "OnFillChildren", "ListAlbums"
SDB.MainTree.AddNode SDB.MainTree.Node_FilesToEdit, Node, 2
Node.hasChildren = True
End Sub
Sub ListAlbums(Node)
Dim Tree : Set Tree = SDB.MainTree
Dim Subnode1 : Set Subnode1 = Tree.CreateNode
Subnode1.Caption = "1 track in the album"
Subnode1.IconIndex = 49
Subnode1.CustomNodeID = 1
SubNode1.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode1, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode1, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode1, 3
Subnode1.HasChildren = True
Dim Subnode2 : Set Subnode2 = Tree.CreateNode
Subnode2.Caption = "2 tracks in the album"
Subnode2.IconIndex = 49
Subnode2.CustomNodeID = 2
SubNode2.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode2, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode2, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode2, 3
Subnode2.HasChildren = True
Dim Subnode3 : Set Subnode3 = Tree.CreateNode
Subnode3.Caption = "3 tracks in the album"
Subnode3.IconIndex = 49
Subnode3.CustomNodeID = 3
SubNode3.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode3, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode3, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode3, 3
Subnode3.HasChildren = True
Dim Subnode4 : Set Subnode4 = Tree.CreateNode
Subnode4.Caption = "4 tracks in the album"
Subnode4.IconIndex = 49
Subnode4.CustomNodeID = 4
SubNode4.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode4, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode4, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode4, 3
Subnode4.HasChildren = True
Dim Subnode5 : Set Subnode5 = Tree.CreateNode
Subnode5.Caption = "5 tracks in the album"
Subnode5.IconIndex = 49
Subnode5.CustomNodeID = 5
SubNode5.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode5, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode5, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode5, 3
Subnode5.HasChildren = True
End Sub
sub showalbums(node)
dim x : x = Node.CustomNodeID
Dim sql, Iter, subroot, albumId
Node.hasChildren = False
sql = "SELECT album, albums.id, artist, COUNT(*) AS NumTracks, MAX(songs.songorder)+1 AS MaxTracks "&_
"FROM songs, albums, artists "&_
"WHERE songs.IDAlbum = albums.id AND artists.id = albums.idartist "&_
"GROUP BY artist, album, albums.id "&_
"HAVING COUNT(*) <= "& x &" AND "&_
"COUNT(*) >= "& x &" AND "&_
"album <> '' AND "&_
"MAX(songs.songorder)+1 <> " & x & " "&_
"ORDER BY album, artist"
'<---Different sorting methods ---- >
'"ORDER BY (MAX(songs.songorder)-COUNT(*))"
'"ORDER BY artist, album"
'"ORDER BY album,artist"
'<--- unsure mod to code --->
'"MAX(songs.songorder)+1 <> " & x & " "&_
'"MAX(songs.songorder) < " & x & " "&_
Dim captionTable, caption
Set captionTable = CreateObject("Scripting.Dictionary")
Set Iter = SDB.Database.OpenSQL(sql)
Do Until Iter.EOF
Dim customData
customData = Iter.StringByIndex(0)&"@@"&Iter.StringByIndex(1)
caption = albumCaption(Iter.StringByIndex(2),Iter.StringByIndex(0))&_
" ("&Iter.StringByIndex(3)&"/"&Iter.StringByIndex(4)&")"
captionTable.add caption, customData
Set subRoot = SDB.MainTree.createNode
subRoot.Caption = caption
subRoot.IconIndex = 16
subRoot.UseScript = Script.ScriptPath
subRoot.OnFillTracksFunct = "showTracks"
subRoot.customData = customData
subRoot.sortCriteria = 0
subRoot.sortGroup = 0
subRoot.hasChildren = False
SDB.MainTree.AddNode Node, subRoot, 3
Iter.Next
Loop
End Sub
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
' Gets the tracks from the albums
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
Sub showTracks(Node)
Dim sql, songlist, SplitCustomData, name, albumId
SplitCustomData = Split(Node.CustomData,"@@")
name = SplitCustomData(0)
albumId = SplitCustomData(1)
sql = "SELECT Songs.Id, Songs.SongOrder FROM Songs "&_
"WHERE songs.idAlbum = "&albumId&" "&_
"ORDER BY Songs.SongOrder"
Dim Iter, id, track, song, songTable, Tracks
Set songTable = CreateObject("Scripting.Dictionary")
Set Iter = SDB.Database.OpenSQL(sql)
Set Tracks = SDB.MainTracksWindow
Dim bDuplicates
bDuplicates = false
Do Until Iter.EOF
id = Iter.StringByIndex(0)
track = Iter.StringByIndex(1) + 1
If songTable.Exists(track) Then
bDuplicates = true
End If
'songTable.add track, id <<< ??? what does this do?
Tracks.AddTracksFromQuery("AND Songs.ID = "&id)
Iter.Next
Loop
If bDuplicates Then ' <<< does this work!?
SDB.MessageBox "Duplicate track numbers exist for this album. Please correct.", mtWarning, Array(mbOk)
End If
Tracks.FinishAdding
End Sub
Thanks, but I dont use MagicNode (tbh, not sure why...Will download it, after posting this!)
Anyway, I did a scrpit for it, (which Ive rush, and I dont believe I will ever update it!), anyway, here it is....
[code]' _ _
' (_) |
' __ ___| |___ ___ _ __
' \ \ /\ / / | / __|/ _ \| '_ \
' \ V V /| | \__ \ (_) | | | |
' \_/\_/ |_|_|___/\___/|_| |_|
'
' *************************************************
' * Program : [MediaMonkey v2.5] FindTheSmallAlbum *
' * Ver : 0.1 *
' * Date : 17/07/2007 *
' * Author : Wilson *
' * Purpose : Script for MM to find missing track *
' *************************************************
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
'Install from scrpit:
' 1) Find the "Auto" Folder ("Mediamonkey\Scripts\Auto") . Right click --> create a new/blank text file.
' 2) Name it FindTheSmallAlbum.vbs
' Make sure its a VBS file, i.e. the file isn't named FindTheMissing.vbs.txt. If this was done correctly, then the icon should of changed
' If it did NOT then, To always display all filenames with extension in explorer, do this:
' 1.). In explorer, go to Tools->Folder Options->View Tab
' 2.) Uncheck "hide file extensions for known file types"
' 3) Copy all this code into the file and save it.
' 4) (Re)start MediaMonkey
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
'Version History/Change Log:
' v0.1 (17/07/07)
' * Had the Idea.
' * First Release to public (MM forumss).
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
'ToDos:
' * List all albums (but it then cant read Node.CustomData)
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
'WishList:
' * Rename this, and add in [FindTheMissing] Songs, to [FindThe]Missing Songs, [FindThe] ShortAlbums
' * Do other album functions (tho its been done before in "Tagging Inconsistencies")
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
' Authors Notes:
' * Should it be "albums with 4 tracks" or "albums with 4 tracks OR LESS"?
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
' Global Variables and Declarations
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
Function albumCaption(artist, album)
albumCaption = album & " - " & artist
'<---Different sorting methods ---- >
' albumCaption = artist & " - " & album
' albumCaption = album & " - " & artist
' albumCaption = album
End Function
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
' Startup Function (when the first is first run, when MM starts)
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
Sub onStartUp
Dim Tree, Iter
Dim sql
Dim Node
Set Node= SDB.MainTree.createNode
Node.Caption = "[FindThe] ShortAlbums"
Node.IconIndex = 40
Node.UseScript = Script.ScriptPath
Script.RegisterEvent node, "OnFillChildren", "ListAlbums"
SDB.MainTree.AddNode SDB.MainTree.Node_FilesToEdit, Node, 2
Node.hasChildren = True
End Sub
Sub ListAlbums(Node)
Dim Tree : Set Tree = SDB.MainTree
Dim Subnode1 : Set Subnode1 = Tree.CreateNode
Subnode1.Caption = "1 track in the album"
Subnode1.IconIndex = 49
Subnode1.CustomNodeID = 1
SubNode1.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode1, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode1, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode1, 3
Subnode1.HasChildren = True
Dim Subnode2 : Set Subnode2 = Tree.CreateNode
Subnode2.Caption = "2 tracks in the album"
Subnode2.IconIndex = 49
Subnode2.CustomNodeID = 2
SubNode2.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode2, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode2, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode2, 3
Subnode2.HasChildren = True
Dim Subnode3 : Set Subnode3 = Tree.CreateNode
Subnode3.Caption = "3 tracks in the album"
Subnode3.IconIndex = 49
Subnode3.CustomNodeID = 3
SubNode3.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode3, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode3, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode3, 3
Subnode3.HasChildren = True
Dim Subnode4 : Set Subnode4 = Tree.CreateNode
Subnode4.Caption = "4 tracks in the album"
Subnode4.IconIndex = 49
Subnode4.CustomNodeID = 4
SubNode4.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode4, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode4, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode4, 3
Subnode4.HasChildren = True
Dim Subnode5 : Set Subnode5 = Tree.CreateNode
Subnode5.Caption = "5 tracks in the album"
Subnode5.IconIndex = 49
Subnode5.CustomNodeID = 5
SubNode5.UseScript = Script.ScriptPath
Script.RegisterEvent Subnode5, "OnFillChildren", "showalbums"
Script.RegisterEvent Subnode5, "OnFillTracks", "showalbums"
Tree.AddNode Node, Subnode5, 3
Subnode5.HasChildren = True
End Sub
sub showalbums(node)
dim x : x = Node.CustomNodeID
Dim sql, Iter, subroot, albumId
Node.hasChildren = False
sql = "SELECT album, albums.id, artist, COUNT(*) AS NumTracks, MAX(songs.songorder)+1 AS MaxTracks "&_
"FROM songs, albums, artists "&_
"WHERE songs.IDAlbum = albums.id AND artists.id = albums.idartist "&_
"GROUP BY artist, album, albums.id "&_
"HAVING COUNT(*) <= "& x &" AND "&_
"COUNT(*) >= "& x &" AND "&_
"album <> '' AND "&_
"MAX(songs.songorder)+1 <> " & x & " "&_
"ORDER BY album, artist"
'<---Different sorting methods ---- >
'"ORDER BY (MAX(songs.songorder)-COUNT(*))"
'"ORDER BY artist, album"
'"ORDER BY album,artist"
'<--- unsure mod to code --->
'"MAX(songs.songorder)+1 <> " & x & " "&_
'"MAX(songs.songorder) < " & x & " "&_
Dim captionTable, caption
Set captionTable = CreateObject("Scripting.Dictionary")
Set Iter = SDB.Database.OpenSQL(sql)
Do Until Iter.EOF
Dim customData
customData = Iter.StringByIndex(0)&"@@"&Iter.StringByIndex(1)
caption = albumCaption(Iter.StringByIndex(2),Iter.StringByIndex(0))&_
" ("&Iter.StringByIndex(3)&"/"&Iter.StringByIndex(4)&")"
captionTable.add caption, customData
Set subRoot = SDB.MainTree.createNode
subRoot.Caption = caption
subRoot.IconIndex = 16
subRoot.UseScript = Script.ScriptPath
subRoot.OnFillTracksFunct = "showTracks"
subRoot.customData = customData
subRoot.sortCriteria = 0
subRoot.sortGroup = 0
subRoot.hasChildren = False
SDB.MainTree.AddNode Node, subRoot, 3
Iter.Next
Loop
End Sub
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
' Gets the tracks from the albums
'//////////////////////////////////////////////////////////////////////////////////////////////////////////////'
Sub showTracks(Node)
Dim sql, songlist, SplitCustomData, name, albumId
SplitCustomData = Split(Node.CustomData,"@@")
name = SplitCustomData(0)
albumId = SplitCustomData(1)
sql = "SELECT Songs.Id, Songs.SongOrder FROM Songs "&_
"WHERE songs.idAlbum = "&albumId&" "&_
"ORDER BY Songs.SongOrder"
Dim Iter, id, track, song, songTable, Tracks
Set songTable = CreateObject("Scripting.Dictionary")
Set Iter = SDB.Database.OpenSQL(sql)
Set Tracks = SDB.MainTracksWindow
Dim bDuplicates
bDuplicates = false
Do Until Iter.EOF
id = Iter.StringByIndex(0)
track = Iter.StringByIndex(1) + 1
If songTable.Exists(track) Then
bDuplicates = true
End If
'songTable.add track, id <<< ??? what does this do?
Tracks.AddTracksFromQuery("AND Songs.ID = "&id)
Iter.Next
Loop
If bDuplicates Then ' <<< does this work!?
SDB.MessageBox "Duplicate track numbers exist for this album. Please correct.", mtWarning, Array(mbOk)
End If
Tracks.FinishAdding
End Sub[/code]