Last.FM Node: dynamic node based on last.fm 2020.04.19 [MM3][MM4]

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

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

Post by Teknojnky »

I am gonna need some help from some of the XML guru's..

In the past I went by some ms articles to figure out how to load and parse some xml for 'toptracks' script, and that works fine for a few of the last.fm feeds, however there are some that don't use the same structure and I am having difficulties figuring out how/which properties/methods to use for the xmldoc object..

For example:

Code: Select all

  		For Each Ele In LastFMXML.getElementsByTagName("name")
  			TrackTitle = Ele.ChildNodes.Item(0).Text
this xml code extracts the track title based on the 'name' element from the following feeds:

artist/similar.xml

Code: Select all

  <?xml version="1.0" encoding="UTF-8" ?> 
- <similarartists artist="Metallica" streamable="1" picture="http://userserve-ak.last.fm/serve/160/199543.jpg" mbid="65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab">
- <artist>
  <name>Iron Maiden</name> 
  <mbid>ca891d65-d9b0-4258-89f7-e6ba29d83767</mbid> 
  <match>100</match> 
  <url>http://www.last.fm/music/Iron+Maiden</url> 
  <image_small>http://userserve-ak.last.fm/serve/50/243479.jpg</image_small> 
  <image>http://userserve-ak.last.fm/serve/160/243479.jpg</image> 
  <streamable>1</streamable> 
  </artist>
- <artist>
  <name>Megadeth</name> 
  <mbid>a9044915-8be3-4c7e-b11f-9e2d2ea0a91e</mbid> 
  <match>97.69</match> 
  <url>http://www.last.fm/music/Megadeth</url> 
  <image_small>http://userserve-ak.last.fm/serve/50/369941.jpg</image_small> 
  <image>http://userserve-ak.last.fm/serve/160/369941.jpg</image> 
  <streamable>1</streamable> 
  </artist>
artist/toptracks.xml

Code: Select all

  <?xml version="1.0" encoding="UTF-8" ?> 
- <mostknowntracks artist="Metallica">
- <track>
  <name>Nothing Else Matters</name> 
  <mbid /> 
  <reach>80023</reach> 
  <url>http://www.last.fm/music/Metallica/_/Nothing+Else+Matters</url> 
  </track>
- <track>
  <name>Enter Sandman</name> 
  <mbid /> 
  <reach>77111</reach> 
  <url>http://www.last.fm/music/Metallica/_/Enter+Sandman</url> 
  </track>
- <track>
  <name>One</name> 
  <mbid /> 
  <reach>66629</reach> 
  <url>http://www.last.fm/music/Metallica/_/One</url> 
  </track>
However other important feeds use a different structure and I can't figure out the proper way to extract the needed fields.. namely 'track name' and 'artist name'..

tag/toptracks.xml

Code: Select all

  <?xml version="1.0" encoding="UTF-8" ?> 
- <tag tag="rock" count="1598230">
- <track name="Once Upon a Time" count="1077" streamable="no">
- <artist name="Frank Zappa">
  <mbid>e20747e7-55a4-452e-8766-7b985585082d</mbid> 
  <url>http://www.last.fm/music/Frank+Zappa</url> 
  </artist>
  <url>http://www.last.fm/music/Frank+Zappa/_/Once+Upon+a+Time</url> 
  <thumbnail>http://ec1.images-amazon.com/images/P/B0000009TN.01._SCMZZZZZZZ_.jpg</thumbnail> 
  <image>http://ec1.images-amazon.com/images/P/B0000009TN.01._SCMZZZZZZZ_.jpg</image> 
  </track>
- <track name="Painting the Town Blue" count="862" streamable="no">
- <artist name="X">
  <mbid>ddd553d4-977e-416c-8f57-e4b72c0fc746</mbid> 
  <url>http://www.last.fm/music/X</url> 
  </artist>
  <url>http://www.last.fm/music/X/_/Painting+the+Town+Blue</url> 
  <thumbnail>http://images.amazon.com/images/P/B000005IRQ.01._SCMZZZZZZZ_.jpg</thumbnail> 
  <image>http://images.amazon.com/images/P/B000005IRQ.01._SCMZZZZZZZ_.jpg</image> 
  </track>
similar tracks is again different where artist/name and track/name are different elements.

track/similartracks.xml

Code: Select all

  <?xml version="1.0" encoding="UTF-8" ?> 
- <similartracks>
- <track>
- <artist>
  <name>Iron Maiden</name> 
  <url>http://www.last.fm/music/Iron+Maiden</url> 
  </artist>
  <name>Run to the Hills</name> 
  <match>24.84</match> 
  <url>http://www.last.fm/music/Iron+Maiden/_/Run+to+the+Hills</url> 
  <streamable>1</streamable> 
  </track>
- <track>
- <artist>
  <name>Iron Maiden</name> 
  <url>http://www.last.fm/music/Iron+Maiden</url> 
  </artist>
  <name>The Number of the Beast</name> 
  <match>22.84</match> 
  <url>http://www.last.fm/music/Iron+Maiden/_/The+Number+of+the+Beast</url> 
  <streamable>1</streamable> 
  </track>

btw the last.fm feeds are listed @ the audioscrobbler site, so you can there is some variance between the structures of the various feeds.. this makes it difficult to have one single function be able to parse them effectively.. most of the types will require a custom parser to extract the relevant fields..

Any help or pointers to good websites would be appreciated... I've been googling around and haven't really found some examples I can use, or been able to get it through my head how to walk the xml to get the needed info.
RedX
Posts: 366
Joined: Wed Dec 27, 2006 10:32 am
Location: Germany

Post by RedX »

search for something like proprerties because that is the name of the tag.
The tag name is artist and a property or value (don't remember) is name with the value Frank Zappa.

Can't help you more atm but hope this helps you to find your way :-)

Regards,
Red
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

woohooo, some headway...

Code: Select all

  Dim ele, node, attr, trackname, artistname, msg, i, trackatt, artistatt

    set ele = loadxml.getelementsbytagname("track")
    set trackatt = ele.item(0).attributes
    'trackname = ele.item(0).nodename 'ok we are at the tracknode'
    trackname = trackatt.getnameditem("name").value
    set artistatt = ele.item(0).childnodes(0).attributes
'     artistname = ele.item(0).childnodes(0).nodename 'ok we are at the artist node'
    artistname = artistatt.getnameditem("name").value
    msg = msgbox("track name>: " & trackname,vbokcancel)
    msg = msgbox("artist name>: " & artistname,vbokcancel)
finally gets me track and artist from

tag/toptracks.xml

!!!

hopefully expect an update with more nodes enabled soon!
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

Ok I got the tag node working, check it out and let me know if theres any problems..

still no save/load yet which sucks, but going to work on finishing up the other nodes first..
cadmanmeg
Posts: 309
Joined: Sun Nov 19, 2006 5:28 am

Post by cadmanmeg »

This seems interesting. Will give it a try and report back anything I see. Thanks Tekno!

Also, will the icon load automatically if also put into the scripts>auto folder?
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

Script updated! All the nodes appear to be fully functional, of course what tracks appear will all depend on your library.

cadmanmeg wrote:This seems interesting. Will give it a try and report back anything I see. Thanks Tekno!

Also, will the icon load automatically if also put into the scripts>auto folder?
Yea, you can use either icon, just put them in the scripts\auto folder with the lastfmnode.vbs file.

The icons are in the top of the script, but here's a handy dandy link you can right click to save as.

Image
drjboulder
Posts: 1119
Joined: Mon Apr 09, 2007 12:03 am
Location: Boulder, Colorado, USA

Post by drjboulder »

Tekno.... You are a bad, bad man! :evil: :evil:

Do you not realize how many hours upon hours of productivity are going to be lost due solely to you writing this script! :lol:

This is amazing!!!
(and very distracting!)
D Rock
Image
MediaMonkeyGoldv3.0.3.1183
Vista Home Basic|4thGen 20GPod
Zune Small Player Skin w/ Aqua 4 Player Mod
Backup | Last FM Node | Scrobbler DJ | TopTracks | StayInSameStyleDJ
RadioDJ | RadioFreeMonkey | PrettyPictures | MiniLyricsEmbedder
LyricsViewer | Lyricator | LyricsPlugin | VisualizationEmbedder | MonkeyRok
RightClickForWeb | WebSearchPanels | WebNodes | MagicNodes | FavoritesNodes
NowPlayingArtNode |AutoRateAccurate | TaggingInconsistencies
AdvancedDuplicateFind&Fix | CaseModify | PlayHistory&Stats | Etc...
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

Thanks for the kind words! Yes it does bring out the addicting side of last.fm and music in general. 8) Tho I do expect after awhile it will wear off somewhat due to last.fm relations don't change very often/quickly.. it will still be a great reference tho when you want to know more about an artist or whatever, or to get a list of tracks you (or your friends) listen to alot in the user nodes.

Frankly I'm amazed I managed to get it all figured out and working so smoothly so far. :o
aidan_cage
Posts: 291
Joined: Mon Dec 11, 2006 9:45 pm

Post by aidan_cage »

The pretty icon does not attach itself to the Last.FM Node :(
I tried the one first linked, and then the one from your post, but i still have a Uranus looking planet as the icon. Help?
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

Ack, I guess I forgot to specify they must be named either LastFMIcon.ICO or LastFMIcon.PNG whichever one you use (they are the same, altho the ICO file is larger).
aidan_cage
Posts: 291
Joined: Mon Dec 11, 2006 9:45 pm

Post by aidan_cage »

Hmm. It seems it should work, but it does not for me--the icon, that is. The script works well, but it seems to not allow MonkeyRok to show the details of the track playing.
I hope you don't mind that I changed the LastFM user name to default to mine :D

I really like being able to listen to my top overall, etc. lists

Thank you, Wizard
now my friend the Tin Man would like a new heart..
and Mr. Scarecrow needs brains... :lol:
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

That is really wierd, here is exactly what it is checking for:

Code: Select all

  If SDB.RegisterIcon ("Scripts\Auto\LastFMIcon.png",1) <> -1 Then
    Node.IconIndex = SDB.RegisterIcon ("Scripts\Auto\LastFMIcon.png",1)
  ElseIf SDB.RegisterIcon ("Scripts\Auto\LastFMIcon.ico",1) <> -1 Then
    Node.IconIndex = SDB.RegisterIcon ("Scripts\Auto\LastFMIcon.ico",1)
  ElseIf SDB.RegisterIcon ("http://cdn.last.fm/matt/nice_favicon.png",1) <> -1 Then 'doesnt work
    Node.IconIndex = SDB.RegisterIcon ("http://cdn.last.fm/matt/nice_favicon.png",1)
  Else
    Node.IconIndex = 37
  End If
the last one with http unfortunately doesnt work, otherwise that would be sweet to use remote icons/images that change dynamically.

Perhaps you have extentions hidden and it saving as some other image type (or the name is mis-spelled).

As far as changing the defaults, not at all, I expect anyone to change them to their preference... that is just a temporary thing until I get auto save/load figured out.

One thing I noticed quite by accident, is that last.fm generally limits the lists to the top 50... however the weekly user chart appears to hold ALL tracks you played in the last week... so it can be quite large and take a while to process.
RedX
Posts: 366
Joined: Wed Dec 27, 2006 10:32 am
Location: Germany

Post by RedX »

Teknojnky wrote:That is really wierd, here is exactly what it is checking for:

Code: Select all

  If SDB.RegisterIcon ("Scripts\Auto\LastFMIcon.png",1) <> -1 Then
    Node.IconIndex = SDB.RegisterIcon ("Scripts\Auto\LastFMIcon.png",1)
  ElseIf SDB.RegisterIcon ("Scripts\Auto\LastFMIcon.ico",1) <> -1 Then
    Node.IconIndex = SDB.RegisterIcon ("Scripts\Auto\LastFMIcon.ico",1)
  ElseIf SDB.RegisterIcon ("http://cdn.last.fm/matt/nice_favicon.png",1) <> -1 Then 'doesnt work
    Node.IconIndex = SDB.RegisterIcon ("http://cdn.last.fm/matt/nice_favicon.png",1)
  Else
    Node.IconIndex = 37
  End If
the last one with http unfortunately doesnt work, otherwise that would be sweet to use remote icons/images that change dynamically.

Perhaps you have extentions hidden and it saving as some other image type (or the name is mis-spelled).

As far as changing the defaults, not at all, I expect anyone to change them to their preference... that is just a temporary thing until I get auto save/load figured out.

One thing I noticed quite by accident, is that last.fm generally limits the lists to the top 50... however the weekly user chart appears to hold ALL tracks you played in the last week... so it can be quite large and take a while to process.
not sure if icon paths are allowed to be relative...
aidan_cage
Posts: 291
Joined: Mon Dec 11, 2006 9:45 pm

3 Cheers

Post by aidan_cage »

thanks for getting back to me. Yeah I looked over that part of the script and was like "This is what it's looking for"
I even copied and pasted directly from the script to the file name
I'm going to have to guess it is just a matter of shutting down and booting up, which I will do later. MonkeyRok seems to work fine for the Fav Tags (which is one of the coolest things I have ever had in music software, btw), so I am wondering if a boot will also correct it for the User Charts Overall section.

Cheers Cheers Cheers

PEACE - Tristan
Teknojnky
Posts: 5537
Joined: Tue Sep 06, 2005 11:01 pm
Contact:

Post by Teknojnky »

RE Icon: actually I just got done testing with each, and only the .ICO file works... the .PNG file does not...

so you will need to save the icon to Scripts\Auto\LastFMIcon.ico

If you 'view source' of any last.fm webpage, you will see where the icon's are there also.
Post Reply