Script idea: auto download album art

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Teknojnky
Posts: 5524
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Script idea: auto download album art

Post by Teknojnky » Mon Jan 30, 2006 3:00 pm

Is there any existing scripts which can auto download album art as a track plays (only if album art does not exist).

Ideally it would be able to search multiple sources and (optionally) get user confirmation before adding it.

A quick search did not seem to find me anything relevant.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Mon Jan 30, 2006 3:18 pm

Well it's not an easy request. Finding a source is probably the hardest part (well, interfacing with it is the hardest part) - got any ideas for a source?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Teknojnky
Posts: 5524
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky » Mon Jan 30, 2006 4:08 pm

Well,

Google

Amazon

Last.fm

Allmusic

Musicbrainz

just to name a few, obviously would need to fine tune the appropriate url search format for each, then its just a matter of displaying any results and giving a thumbs up/down/yes/no button or simply letting the user click a picture and have it added as the chosen album art.

MCSmarties
Posts: 248
Joined: Tue Dec 06, 2005 8:01 pm

Post by MCSmarties » Mon Jan 30, 2006 6:41 pm

If find that the amazon plugin gets it wrong regularly so I'm not sure I'd want to get album art that doesn't match each time I play a song...

I have started adding a customized "album art not available" image for all tracks where I just _can't_ find the correct album art for.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Tue Jan 31, 2006 11:02 am

Well MusicBrainz uses Amazon album art images, so does that rule that out as well?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Teknojnky
Posts: 5524
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky » Tue Jan 31, 2006 11:23 am

Musicbrainz is actively moderated, I would think it would have a very high accuracy for both album art and track listings.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Tue Jan 31, 2006 11:44 am

Actually Last.Fm uses quite a lot of amazon images as well.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Wed Feb 01, 2006 6:57 am

I now have a working concept which uses Last.Fm to find album art and with my music it is fairly reliable. At the moment it just displays the art in a window though. What were you hoping this script would do with the image?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

judas
Posts: 572
Joined: Thu Jun 02, 2005 11:26 pm
Location: Bogotá, Colombia

Post by judas » Wed Feb 01, 2006 9:00 am

Teknjnky would like to:
auto download album art as a track plays (only if album art does not exist).
...i think he refers to auto-saving the image to the song tag?

:-)


judas.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Wed Feb 01, 2006 10:34 am

Well at the moment there are not methods for adding album art to tags. I guess the only choices at the moment are "save to album folder" or "save to central album art folder". I guess I could just give both options! :)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

trooper95
Posts: 24
Joined: Tue Aug 16, 2005 8:15 pm
Location: Philadelphia, PA

Post by trooper95 » Wed Feb 01, 2006 10:59 am

Speaking for myself and my own personal preference, I save album art to its corresponding Album folder with the file name of "folder.jpg".
I'm sure evryone does it slightly different or uses a different file name.
There are probably people who have folders of music not organized that way, ie., 1 folder with 100 songs of all different artists. That would present a problem me thinks.

Maybe 2 options: store in centralized folder with all album art -or- as mentioned above, in corresponding Album folder.

Just my 2 cents. Regardless, such a script would be awesome.

As a side suggestion: Can this work without incorporating the "Now Playing" option??

Thanks trixmoto for your work on this.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Wed Feb 01, 2006 11:26 am

What do you mean about not incorporating Now Playing? Just doing it in batch for all the selected songs?
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Wed Feb 01, 2006 11:32 am

Here is the concept code! It simply displays the best matching result Last.fm has to offer, whenever a track starts playing. If you want the image, you can right click on it and select "save as". Please comment on how you want this to work, and I'll do my best to provide.

Code: Select all

'
' MediaMonkey Script
'
' NAME: LastFmArtFinder 1.0
'
' AUTHOR: trixmoto (http://trix.dork.com)
' DATE : 01/02/2006
'
' INSTALL: Copy to Scripts directory and add the following to Scripts.ini 
'          Don't forget to remove comments (') and set the order appropriately
'
' [LastFmArtFinder]
' FileName=LastFmArtFinder.vbs
' ProcName=LastFmArtFinder
' Order=27
' DisplayName=Last.Fm Art Finder
' Description=Find album art from Last.fm
' Language=VBScript
' ScriptType=2 
'

Option Explicit
Dim IE,url,img

Sub LastFmArtFinder

  Dim Form,WB
  Dim song,artist,album
    
  'setup search
  Set song = SDB.Player.CurrentSong
  artist = mapname(song.ArtistName)
  album = mapname(song.AlbumName)
  url = "http://www.last.fm/explore/search.php?q="&artist&"+"&album&"&m=albums"
  img = 0

  'create form    
  Set Form = SDB.UI.NewForm
  Form.Common.SetRect 100, 100, 600, 400
  Form.BorderStyle  = 2
  Form.FormPosition = 4
  Form.Caption = "Last.fm Art Finder"
  Form.Common.Visible = True
  SDB.Objects("ArtFinder") = Form
  
  'create web component
  Set WB = SDB.UI.NewActiveX(Form, "Shell.Explorer") 
  WB.Common.Align = 5
  WB.Common.ControlName = "WB" 
  Set IE = WB.Interf
  SDB.Objects("WBIE") = IE
  
  'perform initial search
  Search()
        
End Sub
 
Function Search
  
  Dim wsh,cmd,src,list,i
  Search = False
  
  'wait for page to load
  IE.Navigate url
  cmd = SDB.ApplicationPath&"Scripts\LastFmArtFinder2.vbs"
  If SDB.Tools.FileSystem.FileExists(cmd) Then
    Set wsh = CreateObject("WScript.Shell")
    i = wsh.Run("wscript "&Chr(34)&cmd&Chr(34), 1, 1)
    Set wsh = Nothing
  End If
 
  'find image
  Set list = IE.Document.Images
  For i = 0 to list.Length-1
    src = list.Item(i).src
    If UCase(Right(src,4)) = ".JPG" Then
      ShowResult(mapurl(src))
      Search = True
      Exit Function
    End If
  Next
  
  'error if no image found
End Function

Function ShowResult(src)

  Dim doc
  
  Set doc = IE.Document
  doc.Write "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">"&vbcrlf
  doc.Write "<html>"&vbcrlf 
  doc.Write "  <head>"&vbcrlf
  doc.Write "    <title>"&vbcrlf
  doc.Write "      Last.fm Art Finder"&vbcrlf
  doc.Write "    </title>"&vbcrlf
  doc.Write "  </head>"&vbcrlf 
  doc.Write "  <body>"&vbcrlf
  doc.Write "    <img src="""&src&""" align=left>"&vbcrlf
  
  
  
  doc.Write "  </body>"&vbcrlf
  doc.Write "</html>"&vbcrlf
  doc.Close
  
End Function

Function saveimage(src,dest)
  Dim HTTP,Stream
  Set HTTP = CreateObject("Microsoft.XMLHTTP")
  HTTP.open "GET", src, False
  HTTP.send
  Set Stream = CreateObject("adodb.stream")
  Stream.type = 1 'binary
  Stream.open
  Stream.write HTTP.responseBody
  Stream.savetofile dest, 1 'ifnotexist, overwrite=2
  Set Stream = nothing
  Set HTTP = nothing
  saveimage = True
End Function
 
Function mapname(name)
  Dim i,c,l
  mapname = ""
  For i = 1 to Len(name)
    c = Asc(Mid(name,i))
    l = Len(mapname)
    If c > 32 Then
      If c < 48 Then
        mapname = mapname&"%"&CStr(Hex(c))
      Else
        If c > 57 Then
          If c < 65 Then
            mapname = mapname&"%"&CStr(Hex(c))
          Else
            If c > 90 Then
              If c < 97 Then
                mapname = mapname&"%"&CStr(Hex(c))
              Else
                If c > 122 Then
                  If c < 127 Then
                    mapname = mapname&"%"&CStr(Hex(c))
                  End If
                End If
              End If
            End If
          End If
        End If
      End If
    End If
    If l = Len(mapname) Then 
      mapname = mapname&Chr(c)
    End If
  Next
  mapname = Replace(mapname," ","+")
End Function
 
Function mapurl(url)
  url = Replace(url,"50x50","300x300")
  url = Replace(url,"THUMB","LZZZZ")
  mapurl = url
End Function 
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Post by trixmoto » Wed Feb 01, 2006 11:34 am

You will also need this code saved as "LastFmArtFinder2.vbs" in your Scripts folder.

Code: Select all

'
' MediaMonkey Script
'
' NAME: LastFmArtFinder 1.0
'
' AUTHOR: trixmoto (http://trix.dork.com)
' DATE : 01/02/2006
'
' INSTALL: Helper script for 'LastFmArtFinder.vbs'
'          Needs to be in '{MM}\Scripts\'
'

Set SDB = CreateObject("SongsDB.SDBApplication")
Set IE = SDB.Objects("WBIE")
Do While IE.ReadyState <> 4
  WScript.Sleep 500
Loop
Set IE = Nothing
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

Teknojnky
Posts: 5524
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky » Wed Feb 01, 2006 1:02 pm

judas wrote:Teknjnky would like to:
auto download album art as a track plays (only if album art does not exist).
...i think he refers to auto-saving the image to the song tag?

:-)


judas.

Right, Ideally the script could use whatever common options are, save to tag, save to albumart.jpg, save to a specific folder, etc.

The only option I am concerned about is, saving to the id3 tags so that MM will display them on the album art viewer!

:)

I will check out the script with great anticipation!

Post Reply