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

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Postby Teknojnky » Wed Jan 23, 2008 4:02 pm

Thanks Bex & Trix, it did not even dawn on me that the database fields were different than the object properties.. I will have to keep that in mind!
Teknojnky
 
Posts: 5508
Joined: Tue Sep 06, 2005 11:01 pm

Postby Teknojnky » Wed Jan 23, 2008 9:42 pm

Hmmm more questions...

I seem to be able to save the tracklist to an object, and I seem to be able to determine if the object exists, but I'm getting a type mismatch when trying to send the object back to the track list..

Code: Select all
  Dim List, Tracks, Artist
  Set Artist = SDB.Objects(ArtistNode.Caption)
  Set Tracks = SDB.MainTracksWindow

  If Artist is Nothing Then
    logme "Tracklist not cached, going to query last.fm"
    Artist = ArtistNode.Caption

    Set StatusBar = SDB.Progress

    StatusBar.Text = "Fill Artist Node: "

    If LoadXML(ArtistNode.Caption, "TopTracks") Then 'queryies last.fm returns xmldoc of top tracks'
      logme "OnFillArtistNode(): LoadXML returned true"

        Dim ele,TrackTitle

        For Each ele In xmlDoc.getElementsByTagName("name")
           TrackTitle = ele.ChildNodes.Item(0).Text
           'If debug then msgbox ("Top Track " & count & ": " & TrackTitle)
           logme "   xmlDoc tracktitle: " & TrackTitle
           StatusBar.Text = "Matching " & Artist & " - " & TrackTitle
           StatusBar.Increase

        Dim Iter, Qry, TrackListQ

        Qry = "Artist LIKE '%" & CorrectST(Artist) & _
          "' AND SongTitle LIKE '%" & _
          CorrectST(TrackTitle) &"'"

        Set Iter = SDB.Database.QuerySongs(Qry)
        SDB.ProcessMessages
        Do While Not Iter.EOF
          SDB.ProcessMessages
          logme " Query Match Loop entered with AvoidDupes: " & AvoidDupes
          StatusBar.Increase
         
          Tracks.AddTrack (Iter.Item)
          SDB.ProcessMessages
          If AvoidDupes Then 'add only first result'
            Exit Do
          End If
          SDB.ProcessMessages
          Iter.Next
          SDB.ProcessMessages
        Loop
        logme " Query Match Loop exited"
           SDB.ProcessMessages
        If StatusBar.Terminate Then
          Exit For
        End If
        Next

  '     For Each Item In TrackListQ

      Tracks.FinishAdding
      Set SDB.Objects(Artist) = Tracks
    Else
      logme "FillArtistNode(): LoadXML returned false"
      msgbox ("LastFM did not return with data")
    End If

    StatusBar.Text = "Fill Artist Node: Finished"
'   msgbox ("FillArtistNode(): finished")
  Else
    logme " Using Cached Tracklist"
    msgbox ("Using Cached list")
'     Set Tracks = SDB.Objects(Artist)
    For Each Item In SDB.Objects(Artist)
      Tracks.AddTrack = SDB.Objects(Artist).Item
    Next
   
  End If


I've tried directly setting the object to the tracklist:
Set Tracks = SDB.Objects(Artist)

That didn't work, so I tried to setup a loop to read the items of the object (I may be falsely assuming that the tracklist has items before and after being placed into the object):

For Each Item In SDB.Objects(Artist)
Tracks.AddTrack = SDB.Objects(Artist).Item
Next

I'm pretty sure using the sdb.objects is the best way to 'cache' the track list, I don't really want be creating temporary playlists in the playlist node..

But I don't understand why I'm getting the type mismatch..
Teknojnky
 
Posts: 5508
Joined: Tue Sep 06, 2005 11:01 pm

Postby trixmoto » Thu Jan 24, 2008 4:32 am

You seem to have some confusion here with the "Artist" variable. First it's an object...
Code: Select all
Set Artist = SDB.Objects(ArtistNode.Caption)
...then if that's "Nothing" then you set it to a string...
Code: Select all
Artist = ArtistNode.Caption
...and use that string to save the songlist...
Code: Select all
Set SDB.Objects(Artist) = Tracks
...however you're then using an object to retrieve an object, when it should be a string...
Code: Select all
Set Tracks = SDB.Objects(Artist)

Basically, you need to have "oArtist" when it's an object and "sArtist" when it's a string and make sure you're using the right one at the right time! :)
Check out my scripts at trixmoto.net and subscribe to my RSS feed for updates.
Also check out my Uniface blog.
Get a free Dropbox account! :o

Image
trixmoto
 
Posts: 9703
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK

Postby Teknojnky » Thu Jan 24, 2008 12:23 pm

Ok I think your right.

What I was trying to accomplish was having a dynamically named 'object' to use as 'cached' track list... so if the tracklist object existed for that particular artist, then it would use it, otherwise it would query last.fm for the xml data and then add the tracks to the tracklist.

I will have to think some more on it.
Teknojnky
 
Posts: 5508
Joined: Tue Sep 06, 2005 11:01 pm

Postby RedX » Thu Jan 24, 2008 8:37 pm

Teknojnky wrote:
Code: Select all

Function DecToUtf(d)
   Dim b : b = DecToBin(d)
   Dim a : a = "110"&Left(b,5)
   b = "10"&Mid(b,6)
   DecToUtf = "%"&BinToHex(a)&"%"&BinToHex(b)
End Function



This needs to be corrected to
Code: Select all
Function DecToUtf(d)
   Dim b : b = DecToBin(d)
   Dim a : a = "110"&Left(b,5)
   b = "10"&Mid(b,6)
//THIS LINE
   DecToUtf = BinToHex(a)&"%"&BinToHex(b)
End Function



or else you are not able to enqueue artists with non ASCII chars ;-)

Regards,
Red

PS: I like the idie of this script
RedX
 
Posts: 366
Joined: Wed Dec 27, 2006 10:32 am
Location: Germany

Postby Teknojnky » Thu Jan 24, 2008 9:28 pm

Thanks for the correction Red!

I think once I get this ball rolling, this script is gonna be awesome...

here is a little bit of a teaser of stuff yet to come..


Image
Teknojnky
 
Posts: 5508
Joined: Tue Sep 06, 2005 11:01 pm

Postby Teknojnky » Thu Jan 24, 2008 11:43 pm

Code updated, see first post, a usable artist tree so far, but alot more work to be done.. try it out and let me know what you think!
Teknojnky
 
Posts: 5508
Joined: Tue Sep 06, 2005 11:01 pm

Postby RedX » Fri Jan 25, 2008 4:48 am

Teknojnky wrote:Code updated, see first post, a usable artist tree so far,


You have the secure your code againts parallel queuing last.fm servers!
Try this out to see what i mean:
1) Add an artist
2) click on any other node
3) click on the artist name node again
4) repeat as many times as you wish ( recommend about 7) then you'll see what i mean ;-)

Plus hen the list is empty i get prompted to enter an artist name, but after there is initially an artist there i can't add any more.
As it seems none of the pop up windows work?

Nice script,
Red
RedX
 
Posts: 366
Joined: Wed Dec 27, 2006 10:32 am
Location: Germany

Postby drjboulder » Fri Jan 25, 2008 5:22 am

Teknojnky wrote:I don't really have the time to research and make this script, tho it could probly done by combining code from several of the existing scripts, so I'm just putting the idea out there in case anyone else see's the usefulness and has the time/ability to take the idea and run with it.


I thought you said that you did not have time to develop this script.... 8)

Will you be be packaging this in an MMIP once everything is sussed out?

I am going to give it a go with what you have written. Will report back any problems.

Very nice work, Tekno! :P
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...
drjboulder
 
Posts: 1119
Joined: Mon Apr 09, 2007 12:03 am
Location: Boulder, Colorado, USA

Postby drjboulder » Fri Jan 25, 2008 5:52 am

UM...................

WOW

Without even playing around with it beyond entering one artists' name, I gotta say I am blown away by the possibilities of this!

Good thing you did not have the time to work on it... 8)

What do I do with the icon package, if I DL it?
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...
drjboulder
 
Posts: 1119
Joined: Mon Apr 09, 2007 12:03 am
Location: Boulder, Colorado, USA

Postby Teknojnky » Fri Jan 25, 2008 9:00 am

Just place either icon in the script\auto folder.

Eventually, yea I'll figure out how to make MMIP package, still a long way to go... I have a couple more ideas I haven't even added yet that I will keep a surprise until I can see if its doable..

Regarding the parallel queries, yea thats pretty cool... if you notice the actual xml goes super fast, its the matching up to your library that takes some time.. on my library (~900gig) it take ~1-2 seconds per track... I am not sure if that can be sped up with a better/more efficient query or if that is simply because of the size of the library to query.

Also, once I get the 'cache' figured out, it wil only download an artist once per session (with a context menu to manually refresh).

Glad you enjoy it, I think its pretty freakin cool myself. :o 8) :lol:

Edit: also, to add a new artist, you gotta collapse then expand the artist tree again... I will need to get the 'add artist node' context working and the save/load and it will be alot better.

I made a minor update where the artist input box is prepopulated with a default (you can still type whatever you want) if you just want to play around.
Teknojnky
 
Posts: 5508
Joined: Tue Sep 06, 2005 11:01 pm

Postby aidan_cage » Fri Jan 25, 2008 3:43 pm

this all looks and sounds really cool
this functionality is super interesting
I'm going to go ahead and give it a spin
PEACE

Edit: woah. cool.. THANKS
aidan_cage
 
Posts: 291
Joined: Mon Dec 11, 2006 9:45 pm

Postby Teknojnky » Fri Jan 25, 2008 4:52 pm

Another small update, did quite a bit of re-arranging code but I think I have the basics down now..

You can now collapse a node to clear it. (I had a several dozen deep tree and no way to clear it without restarting lol)

You can expand the related artists without selecting/loading the parent artist node.

I've yet to work on tags/user charts, but hopefully I will get some time this weekend, otherwise it may be next week.
Teknojnky
 
Posts: 5508
Joined: Tue Sep 06, 2005 11:01 pm

Postby callmetom » Fri Jan 25, 2008 7:45 pm

Nice - very nice work !!

Hope you get time to make some improvments !!

Keep up the good work !
My Specs:
Windows XP / SP2
Always latest MM version
Sorry for my sometimes bad english (-:
callmetom
 
Posts: 90
Joined: Sun Jul 15, 2007 12:18 pm

Whoa!

Postby CWuestefeld » Fri Jan 25, 2008 9:48 pm

:o Whoa! This is fantastic!

Good idea, and it looks to be pretty well executed so far. Please keep up the good work.
CWuestefeld
 
Posts: 7
Joined: Thu Jan 18, 2007 9:13 pm

PreviousNext

Return to Need Help with Addons?

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 13 guests