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

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

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

Postby Teknojnky » Mon Jan 14, 2008 1:43 pm

I'm pleased to release the latest updates to Last.FM Node.

Image

Download Here (tested only with mm 3.1)

If you have problems installing on vista or windows 7, try shutting down MM and then right click the MM shortcut and RUN AS ADMIN, then double click the last.fm MMIP installation file

You can change some of the options @ tools > options > library > last.fm nodes (mouse over the controls to see what they do) to suite your preference.

To add your favorite artists, tags, etc... use the last.fm menu icon on the main toolbar.

To remove them, you will have to shutdown MM and edit the lastfmnode.vbs.ini file in the mm\scripts\auto folder.

Woot! Last.FM Node has been added to Build.Last.FM Go check out all the other last.fm related tools there!

Recent Updates:

* added QuickQueue from last.fm menu, selected tracks will be queried and
each of their similar tracks will be queued (using the queue # in options)

* added dj queue option (queue multiple similar tracks at one time)
* added avoid twofers option (avoid playing 2 songs by the same artist in a row)

* Optimized auto-dj mode retries (hopefully)'
* Last.FM node now indicates what track will be used if you click the root node'
* Misc stuff I've forgotten'

* fixed a couple event errors'
* disabled some unnecessary database transactions'

2009.01.15
* implemented favorites saving and usage (edit/remove not yet functional)'
* favorite nodes are stored in Auto\LastFmNode.vbs.ini'
* added menu and dialog to save favorites to the Last.FM toolbar button/menu'

2008.05.07
* Fixed control names in options sheet
* Fixed dropdown lists in options sheet and added a couple more sorts'
* Partially fixed enable dj mode from option sheet (still works from the toolbar menu)'


2008.05.07
* Updated SQL's to use current filter settings. Useful if you want to prevent
in-accessible or other tracks from being queried'
* Finally implemented preference saving to ini, you no longer need to manually
modify the variables at the top of the script. Options > Library > Last.FM Node (note this does not yet include default/favorite nodes)


2008.04.18
* Updated QueryLibrary() to avoid some case sensitivity and increase speed.
thx to Bex, ZvezanD and chx for the interesting discussion about it
* added check for similar artist exists in library before trying to find their
tracks when similar tracks fails (prevents searching for tracks not in lib)


2008.04.15
* added Order variable to set the preferred sort order when searching for tracks
must be a valid ORDER BY <songfield> sql qualifier, default is sort by bitrate
DESC so the highest bitrate track is used first. Other alternatives might be
Rating DESC, DateAdded ASC/DESC, PlayCounter ASC/DESC, Year ASC/DESC,
or Random(). Sort order only matters when you might have multiple copies
of a track. The previous unspecified behavior appeared to be by songid.
NOTE: if you choose Random(), you might get a repeat play of a track early
because a different version may have been played previously.



2008.04.11

* add db commits before sql iterators to avoid some database errors when multiple scripts are running or tags are being updated in the background


2008.03.05
* updated the sql query with many thanks to Bex for a much much faster and less resource intensive query


2008.02.08
* fixed artist check so that differing case doesn't matter (I noticed NoFX vs NOFX)'
* implemented group tracks/artists, enjoy and don't forget to join "Media Monkey"
* updated most of the last.fm nodes to be more consistent with stuff I learned later
* should use new events instead of old onclick stuff'
* added default variables to customize the prompts to your preferences,
saving options to ini should be coming soon I hope.
* I think I have all functionality I originally envisioned and even some I didn't.
Work soon to start on save/load nodes, optionsheet and whatever optimzations'
* Oh, also added get current play track for fav artist and tags

2008.02.07
* added a real PAINT IT BLACK icon based on image from Spacefish, Thanks!'
* functionalized the dj restrictions (shouldn't really have any discernable effect)
* add qry check for artist before searching artist+title
I am interested in knowing if this is any noticible improvement
especially for smaller libraries (shouldn't search for artists you don't have)
* added check for min rating and size in qry (rating uses 'djminrating' variable)
this affects the regular nodes to keep crappy tracks out, feedback requested'
* misc improvements & logging tweaks/details (be sure to delete log occasionally)'


2008.02.05
' * implemented related artist + random related artist top tracks failover
' if related tracks comes up empty.
' * implemented last chance add random track from library if all else fails'

It's not the most pretty, but it seems to be working OK.. try it out and let me know how it works for you!

2008-02-04:
Minor update to script:
' Recent Updates:
' * implemented artist time limit (keeps artist from repeating within # hours)
' * implemented retry counter, script will now try to find more tracks by temporarily
' loosening restrictions (track/artist repeat timer, turn off dupe avoidance)'

----------------------------------------------------------------------------------

While I still have not finished implentation of save/load, I have added a new feature which I am very excited about and I think you will be too.

Last.FM DJ Mode

When enabled, this will auto-enqueue related tracks based on the 'related tracks' feed from last.fm. This is slightly different from scrobbler dj, where the related artists was chosen then a top track from the related artist was chosen.

Using the related tracks feed is more accurate, but can possibly lead to a potentially smaller pool of tracks to choose from.

To enable DJ mode, select it from the Last.FM icon on the standard toolbar.

In the future, additional modes will be added to fall back on if insufficient usable tracks occurs.

I also tried my hand at a MMIP installation package, download here.

This script is compatible with Mediamonkey 3, older versions are not supported.

Script is still a work in progress, not all features are implemented and errors could occur.

Feedback, bugs, improvement ideas are welcomed.

Thanks go out to Psyxonova, the creator of the ScrobblerDJ script which has been a favorite and inspiration.

Thanks also go out to the Mediamonkey Dev Team and the Community Scripters who make Mediamonkey such a wonderful tool.

---------------------------------------------------------
OK well here is the first somewhat usable release.. there is still lots to do, but the favorite artists node appears to function perfectly (but still no save/load).

Image

Try it out, I'm looking forward to hearing any comments/suggestions!

All Nodes appear to be fully functional, still no save/load yet, I'll start figuring out how to do that soon.




Code: Select all
code removed, use MMIP installer



==================================================
So, I was thinkin what else would be super cool to have in mediamonkey...

An auto-playlist/node of an artist's top tracks based on their top tracks at last.fm...

There are already a few scripts out there that do last.fm related stuff, this would be somewhat of a combination of some of them, but would provide an interesting and dynamic view not really available in mm..

So, a new node could be created "Last.fm" or some such, under this node the user could add various particular/favorite artists, once added and clicked on, the script would dynamically load the artists top tracks that you have in your library.

Now really the most interesting thing that this does differently from other last.fm scripts, is that it simply populates a node tracklist and does not enqueue anything at all. From the resulting tracklist you could enqueue or rate or burn or edit or whatever you wish to do.

To build on the above, even cooler would be the ability to right click one of these artist nodes or tracks and have related artists added as subnodes along with their dynamic track lists matched up between last.fm and your library.

Here's sort of a visual example as how I was thinking...

MM tree nodes
  • Now Playing
  • Library & subnodes
  • Last.fm Artist Dyamic Playlists
    [**] Nine Inch Nails (clicking this node would load Nine Inch Nails Top tracks that you have in your library
    [***] Tool (related sub nodes off of NIN with their resulting top tracks)
    [***] A Perfect Circle
    [****] Tool
    [****] Deftones (related artist sub node of A Perfect Node)
    [****] Nine Inch Nails
    [***] Marilyn Manson

(edit I guess its not possible to multilevel bullets, but hopefully the heirarchy is apparent)

I am sure some limit would have to be made to how deep a set of subnodes you could make, and it might be prudent to filter duplicates within a tree of related artists (so NIN wouldn't appear under a subnode of itself), but hopefully the idea is to be able to a tree of related artists and their applicable top tracks.

To add an artist to the root tree, a context menu could be added 'add to last.fm node' and/or type the artist name into a small input box initiated via script menu or toolbar icon, or better yet just clicking the root node would ask you what artist to add.

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.

Here is a screenshot of how it looks so far.. right now the artist is hard coded into the script, but eventually you will be able to add/remove artists dynamically...

Image
Last edited by Teknojnky on Mon Oct 05, 2009 12:51 pm, edited 42 times in total.
Teknojnky
 
Posts: 5509
Joined: Tue Sep 06, 2005 11:01 pm

Postby Teknojnky » Wed Jan 23, 2008 2:15 am

script too large to post...

download installer
Last edited by Teknojnky on Thu Jan 31, 2008 4:06 pm, edited 8 times in total.
Teknojnky
 
Posts: 5509
Joined: Tue Sep 06, 2005 11:01 pm

Postby drjboulder » Wed Jan 23, 2008 2:55 am

Good luck with this Teckno, this could be very cool!
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 » Wed Jan 23, 2008 1:17 pm

Continuing on, trying to get this simple query to work...

Code: Select all
      Dim Iter, Qry
       Qry = "ArtistName=" & Artist & " AND Title=" & TrackTitle
      Set Iter = SDB.Database.QuerySongs (Qry)
      Do While Not Iter.EOF
        logme "Query Match Loop entered"
        StatusBar.Increase
        Tracks.AddTrack (Iter.Item)
        If AvoidDupes Then 'add only first result'
          Exit Do
        End If
        SDB.ProcessMessages
      Loop


I'm getting error executing SQL "SELECT Songs.* From SONGS WHERE ArtistName=Nine Inch Nails AND Title=Closer"
:near "Inch" : syntax error (1,1)

or if I try to only query the title;

' Qry = "Title=" & TrackTitle

error executing SQL "Select Songs.* FROM Songs WHERE Title = Closer"
: no such column: Closer (1,1)

Which I don't understand, I followed the example in the wiki..
Teknojnky
 
Posts: 5509
Joined: Tue Sep 06, 2005 11:01 pm

Postby Bex » Wed Jan 23, 2008 2:29 pm

When comparing a text-field with 'some text', you must put the 'some text' between apostrophes.
You must also replace any apostrophes in 'some text' with two apostrophes.
Like this:
Code: Select all
Qry = "ArtistName='" & Replace(Artist,"'","''") & "' AND Title='" & Replace(TrackTitle,"'","''") &"'"
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Bex
 
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Postby Teknojnky » Wed Jan 23, 2008 2:39 pm

Ah hah, ok now I see..

I didn't understand what this function was for but now I do..

Code: Select all
Function CorrectSt(inString)
   'logme ">>CorrectSt() has started with parameters " & inString
   CorrectSt = Replace(inString, "'", "''")
   CorrectSt = Replace(inString, """", """""")
   'logme "<<CorrectSt() will return " & CorrectSt & " and exit"
End Function


But I still get sql error no such column: title using

Code: Select all
      Dim Iter, Qry
'       Qry = "Song.ArtistName=" & Artist & " AND Song.Title=" & TrackTitle
'       Qry = "Title = '" & TrackTitle & "'"
      Qry = "ArtistName='" & Replace(Artist,"'","''") & "' AND Title='" & Replace(TrackTitle,"'","''") &"'"
      Set Iter = SDB.Database.QuerySongs (Qry)
      Do While Not Iter.EOF
        logme "Query Match Loop entered"
        StatusBar.Increase
        Tracks.AddTrack (Iter.Item)
        If AvoidDupes Then 'add only first result'
          Exit Do
        End If
        Iter.Next
        SDB.ProcessMessages
      Loop


Title is a songdata property in mm3 or has that changed?

The other errors I get after the sql error:

field not found in result C:\sources\mediamonkeyrelease\mp3datab\sqlitedb.pas, line 1227
file: lastfmnode.vbs, line 154, column 6 (which refers to the Set Iter line above)
Teknojnky
 
Posts: 5509
Joined: Tue Sep 06, 2005 11:01 pm

Postby Bex » Wed Jan 23, 2008 2:47 pm

The CorrectSt Function is wrong. It should be:
Code: Select all
Function CorrectSt(inString)
   'logme ">>CorrectSt() has started with parameters " & inString
   CorrectSt = Replace(inString, "'", "''")
   CorrectSt = Replace(CorrectSt, """", """""")
   'logme "<<CorrectSt() will return " & CorrectSt & " and exit"
End Function

But I don't understand the use of this part:
Code: Select all
CorrectSt = Replace(CorrectSt, """", """""")

So I would actually remove it.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Bex
 
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Postby Teknojnky » Wed Jan 23, 2008 2:58 pm

Ok but I wasn't even using CorrectSt yet...

the sample query works

Code: Select all
Set Iter = SDB.Database.QuerySongs("SongLength > 60*1000")


but I can't get anything to work with either Title or ArtistName fields..
Teknojnky
 
Posts: 5509
Joined: Tue Sep 06, 2005 11:01 pm

Postby Bex » Wed Jan 23, 2008 3:37 pm

Ok, I should have thought of checking the fieldnames in the first post. ArtistName and Title don't exist. They should be Artist and SongTitle:
Code: Select all
Qry = "Artist='" & Replace(Artist,"'","''") & "' AND SongTitle='" & Replace(TrackTitle,"'","''") &"'"
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Bex
 
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Postby Teknojnky » Wed Jan 23, 2008 3:39 pm

I am wondering if this is a bug..

Title does not appear to be valid, but the following worked..

Set Iter = SDB.Database.QuerySongs ( "Artist LIKE '%Nine Inch Nails'")
Set Iter = SDB.Database.QuerySongs ( "Album LIKE '%Nine Inch Nails'")


doesn't work
Set Iter = SDB.Database.QuerySongs ( "ArtistName LIKE '%Nine Inch Nails'")
Set Iter = SDB.Database.QuerySongs ( "Title LIKE '%Closer'")
Set Iter = SDB.Database.QuerySongs ( "AlbumName LIKE '%Nine Inch Nails'")


I don't see any property that returns Title other than Title...
Teknojnky
 
Posts: 5509
Joined: Tue Sep 06, 2005 11:01 pm

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

Bex wrote:Ok, I should have thought of checking the fieldnames in the first post. ArtistName and Title don't exist. They should be Artist and SongTitle:
Code: Select all
Qry = "Artist='" & Replace(Artist,"'","''") & "' AND SongTitle='" & Replace(TrackTitle,"'","''") &"'"



Ok we just both realized this :)

But, SongTitle DOES work, however I don't see it @ http://www.mediamonkey.com/wiki/index.php/SDBSongData

nor is 'SongTitle' anywhere else within the scripting wiki..

http://www.mediamonkey.com/wiki/index.p ... ext=Search

Strange no?
Teknojnky
 
Posts: 5509
Joined: Tue Sep 06, 2005 11:01 pm

Postby Teknojnky » Wed Jan 23, 2008 3:49 pm

HOLY **** IT WORKS!

(well just basic functionality! but its a start!)

Updating code above..

Now I gotta figure out how to store the artist names and add/remove them dynamically to the tree.
Last edited by Teknojnky on Wed Jan 23, 2008 3:50 pm, edited 1 time in total.
Teknojnky
 
Posts: 5509
Joined: Tue Sep 06, 2005 11:01 pm

Postby Bex » Wed Jan 23, 2008 3:50 pm

Then the wiki is wrong. I just found out how to update the wiki the other day (really easy) so I'll fix it.

Btw, you can use my SQL-Viewer script to see all Tables and Field names. It reads directly from the database so it's always correct.

Edit: What am I talking about?
The link you provided displays the Songdata object and all its members where the name of the title correctly is named Title.
However, that's not the same thing as the field name in Table Songs in SQL-Database. In there the name is SongTitle.

The Wiki lacks info about database Field Names. It's only contians Table Names. I'll try to add Field names when I get the time.
Last edited by Bex on Wed Jan 23, 2008 3:56 pm, edited 1 time in total.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Bex
 
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Postby trixmoto » Wed Jan 23, 2008 3:52 pm

When you are querying the database you are looking at tables and fields, not objects and properties - the names are often different in MM. The wiki section is here, but the fields are not listed yet...

http://www.mediamonkey.com/wiki/index.p ... _structure
Download my scripts at trixmoto.net. If you're interested, check out my Uniface blog.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.

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

Postby Bex » Wed Jan 23, 2008 3:57 pm

I'm a slow typer so you bet me Trixi!
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!

All My Scripts
Bex
 
Posts: 6316
Joined: Fri May 21, 2004 5:44 am
Location: Sweden

Next

Return to Need Help with Addons?

Who is online

Users browsing this forum: No registered users and 6 guests