how filter songs by cover art size?

Get answers about using MediaMonkey 4 for Windows.

Moderator: Gurus

jhsmith
Posts: 19
Joined: Mon Jun 20, 2005 3:18 pm

how filter songs by cover art size?

Post by jhsmith »

Just wondering, is there a way to filter songs by cover art size? I mean show only albums with a tagged image lower than 500*500 or any other size? I'm trying to update all my small size cover art, with better quality scans. I think, Trixmoto once mentioned something about a similar script, but i could not find the post. Thanks in advance, all help is appreciated!! :D
Lowlander
Posts: 56589
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Post by Lowlander »

This is not possible with MediaMonkey. It should be possible with scripts, but it might take a lot of processing as image meta-data are not stored in the library.
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

I've done a small Script some time ago. It scan through the Library and shows alls tracks that have Album Arts below the given resolution. (const Resolution)
Maybe it helps:

Code: Select all

'Create a File LowResCover.vbs in MediaMonkey\Scripts
'and add the Following to Scripts.ini

'[LowResCover]
'FileName=LowResCover.vbs
'ProcName=OnStartUp
'Order=6
'DisplayName=Low Resolution Covers
'Description=Shows all Tracks, which Cover's have a low Quality
'Language=VBScript
'ScriptType=0

Option Explicit

const Resolution = 90000 '300x300

Sub OnStartUp()
	
	Dim FSO
	Dim SDB
	Dim objShell
	Dim Progress
	Set FSO = CreateObject("Scripting.FileSystemObject")
	Set SDB = CreateObject( "SongsDB.SDBApplication")
	Set objShell = CreateObject("Shell.Application")
	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 objFile
	Dim objFolder
	Dim objFolderItem
	Dim Drive
	Dim Path
	Dim Cover
	Dim RecordSet
	Dim Width
	Dim Height
	Dim LowRes
	
	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")
	    ElseIf Left(RecordSet.StringByName("CoverPath"), 2) = "\\" Then
	      'Network Path
	      Cover = RecordSet.StringByName("CoverPath")
	    Else
	      On Error Resume Next
	      If Left(RecordSet.StringByName("SongPath"), 2) = "\\" Then
	        'Network Path
	        Path = FSO.GetFile(RecordSet.StringByName("SongPath")).ParentFolder
	      Else
	        Drive = Chr(RecordSet.ValueByName("DriveLetter") + 65)
	        Path = FSO.GetFile(Drive & RecordSet.StringByName("SongPath")).ParentFolder
	      End If
	      On Error GoTo 0
	      
	      Cover = Path & "\" & RecordSet.StringByName("CoverPath")
	    End If
		
		'Check Resolution
		if FSO.FileExists(Cover) then
			Set objFile = FSO.GetFile(Cover)
			Set objFolder = objShell.Namespace(objFile.ParentFolder + "\")
			set objFolderItem = objFolder.ParseName(objFile.Name)
			Width  = objFolder.GetDetailsOf(objFolderItem, 27)
			Height = objFolder.GetDetailsOf(objFolderItem, 28)
			
			if (Right(Width, 5) = "Pixel") and (Right(Height, 5) = "Pixel") then
				Width  = Int(Left(Width,  Len(Width)  - 5))
				Height = Int(Left(Height, Len(Height) - 5))
				if (Width * Height) < Resolution then
					LowRes = LowRes & RecordSet.StringByName("ID") & ", "
				end if
			end if
		end if
		
		RecordSet.Next
		Progress.Increase
		
		if Progress.Terminate then
		  Exit Do
		end if
	Loop
	
	if Len(LowRes)>2 then 
		LowRes = Left(LowRes, Len(LowRes)-2)
		Dim Tracks
		Set Tracks = SDB.MainTracksWindow
		Tracks.AddTracksFromQuery("And Songs.ID In (" + LowRes + ")")
		Tracks.FinishAdding
		Set Tracks = Nothing
	end if
	
	Set RecordSet = Nothing
	Set FSO = Nothing
	Set SDB = Nothing
	Set Progress = Nothing
end Sub
Tip: Save the Result in a Playlist if you don't want to perform the search each time again.
jhsmith
Posts: 19
Joined: Mon Jun 20, 2005 3:18 pm

Post by jhsmith »

thanks guys!

Onkel, I just sent you a PM about the script..

:D
sr383
Posts: 1
Joined: Sat Jul 15, 2006 3:32 pm

Post by sr383 »

I love the idea for this script, but I couldn't make it work. It "seems" to run (and the status bar shows that my library is being scanned), but I don't see any results. Most of my album art is imbedded in the MP3s. Does this script look there?

Thanks,

Stephen
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

The Result is shown, when the Process is finished first. So wait and see.

Checking the album arts attached to the mp3 wasn't possible the time I wrote the script. I'll see if I can improve it.

EDIT:
Here it is:
Now you have to select the Tracks you want to check (maybe the whole library).
After the Process has finished, all Tracks are shown (or not) which have small Album Arts.

Code: Select all

'Create a File LowResCover.vbs in MediaMonkey\Scripts
'and add the Following to Scripts.ini

'[LowResCover]
'FileName=LowResCover.vbs
'ProcName=OnStartUp
'Order=6
'DisplayName=Low Resolution Covers
'Description=Shows all Tracks, which Cover's have a low Quality
'Language=VBScript
'ScriptType=0

Option Explicit

const Resolution = 90000 '300x300

Sub OnStartUp()

	Dim Progress
	Dim Tracklist
	Dim Track
	Dim CoverList
	Dim Cover
	Dim a, b
	Dim LowRes
	
	Set Progress = SDB.Progress
	Set Tracklist = SDB.SelectedSongList 
	Progress.MaxValue = Tracklist.Count-1
	for a = 0 to Tracklist.Count-1
		Set Track = Tracklist.Item(a)
		Progress.Value = a
		Progress.Text = SDB.Localize("Current song") & ": " & Track.ArtistName & " - " & Track.Title

		Set CoverList = Track.AlbumArt 
		for b = 0 to CoverList.Count-1
			Set Cover = Coverlist.Item(b).Image
			if Cover.Height*Cover.Width<=Resolution then
				LowRes = LowRes & Tracklist.Item(a).ID & ", "
				Exit For
			end if
			Set Cover = Nothing
		next
		
		Set CoverList = Nothing
		Set Track = Nothing
	next
	
	SDB.MainTree.CurrentNode = SDB.MainTree.Node_Library
	
	if Len(LowRes)>2 then 
		LowRes = Left(LowRes, Len(LowRes)-2)
		Dim Tracks
		Set Tracks = SDB.MainTracksWindow
		Tracks.AddTracksFromQuery("And Songs.ID In (" + LowRes + ")")
		Tracks.FinishAdding
		Set Tracks = Nothing
	end if
	
	Set Tracklist = Nothing
	Set Progress = Nothing
end Sub
Haaden2
Posts: 23
Joined: Thu Sep 09, 2010 12:03 pm

Re: how filter songs by cover art size?

Post by Haaden2 »

onkel_enno, I've been wanting to identify low res artwork for quite some time and I'm really happy to find your script. However when I run it I get the error:

Image

I am no coder, but do you have an idea what I need to do to get the script working?
Post Reply