Last.Fm Current Artist Panel Script

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

oldskool73
Posts: 38
Joined: Sat May 27, 2006 3:50 pm
Contact:

Last.Fm Current Artist Panel Script

Post by oldskool73 » Sat May 27, 2006 4:51 pm

Hi all,

only really found MM a few days ago and I'm hooked already, so cool how easy it is to script :)

Anyway, as a first project I created this simple dockable persistant panel to show the Last.fm info page for the artist currently playing.

It's all packaged up nicely and *won't break your MM uninstaller*, hope someone finds it useful.

http://www.dustypixels.com/downloads/me ... yPanel.exe

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Sat May 27, 2006 5:55 pm

Please post your code (too), certainly because you're new here (and we don't trust exe's).

Thanks
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

oldskool73
Posts: 38
Joined: Sat May 27, 2006 3:50 pm
Contact:

Post by oldskool73 » Sat May 27, 2006 5:57 pm

a picture speaks a thousand words...

Image

oldskool73
Posts: 38
Joined: Sat May 27, 2006 3:50 pm
Contact:

Post by oldskool73 » Sat May 27, 2006 6:00 pm

err, ok, will do although I've taken pains to code it in a way that works nicely with the installer (which I'm about to write about in another post) so I'll have to tweak he code back a bit, gimme a while... :)

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Sat May 27, 2006 6:03 pm

Hmm, just post the code of the "auto" script file?
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

oldskool73
Posts: 38
Joined: Sat May 27, 2006 3:50 pm
Contact:

Post by oldskool73 » Sat May 27, 2006 6:14 pm

ok, for all you wary folk out there, the zip version is here...

http://www.dustypixels.com/downloads/me ... nstall.zip

...just bung all three of the files into your {MM install dir}/Scripts/Auto folder and restart MM.

Only problem I've noticed so far is Last.fm's layout looks pretty crap in a small window :)

oldskool73
Posts: 38
Joined: Sat May 27, 2006 3:50 pm
Contact:

Post by oldskool73 » Sat May 27, 2006 6:30 pm

...and here's all the code if you wanna cut'n'paste into your own file and save in the 'Scripts\Auto\' folder... (you'll miss out on my cool icons though!)

Code: Select all

Dim lfm_menu, lfm_button, lfm_Panel, lfm_Browser, lfm_BrowserDoc, lfm_CurrentArtist
Dim lfm_onIconIndex, lfm_offIconIndex, lfm_installPath

Sub OnStartup
  Set UI = SDB.UI

  lfm_installPath = "Scripts\Auto"

  lfm_onIconIndex  = SDB.RegisterIcon(lfm_installPath + "\last.fm.on.ico", 0)
  lfm_offIconIndex = SDB.RegisterIcon(lfm_installPath + "\last.fm.off.ico", 0)
  
  ' Create panel
  Set lfm_Panel = UI.NewDockablePersistentPanel("LastFmDPP")
  if lfm_Panel.IsNew then
    lfm_Panel.DockedTo = 2
    lfm_Panel.Common.Width = 250
    lfm_Panel.Common.Visible = true
  end if
  lfm_Panel.Caption = "Last.Fm"
  Script.RegisterEvent lfm_Panel, "OnClose", "lfm_PanelClose"

  ' Create a web browser component
  Set lfm_Browser = UI.NewActiveX( lfm_Panel, "Shell.Explorer")
  lfm_Browser.Common.Align = 5      ' Fill all client rectangle
  lfm_Browser.Common.ControlName = "lfm_Browser"
  
  ' Add menu item
  Set lfm_menu = UI.AddMenuItem( UI.Menu_View, 1, -1)
  lfm_menu.Caption = "Last.&fm"     
  lfm_menu.Checked = lfm_Panel.Common.Visible
  lfm_menu.ShortCut = "Ctrl+Alt+f"
  Script.RegisterEvent lfm_menu, "OnClick", "lfm_TogglePanel"

  ' Add item to the main toolbar
  UI.AddMenuItemSep UI.Menu_TbStandard, 0, 0
  Set lfm_button = UI.AddMenuItem( UI.Menu_TbStandard, 0, 0)
  lfm_button.Caption = "Last.fm"
  lfm_button.Checked = lfm_Panel.Common.Visible
  Script.RegisterEvent lfm_button, "OnClick", "lfm_TogglePanel"
  lfm_button.IconIndex = 35
  lfm_button.Hint = "Show current artist details on Last.fm"
  If lfm_Panel.Common.Visible Then
    lfm_button.IconIndex = lfm_onIconIndex
    lfm_Browser.Interf.Navigate "http://www.last.fm"	'open your last.fm homepage
  Else
    lfm_button.IconIndex = lfm_offIconIndex
  End If
 
  ' Listen for changes
  Script.RegisterEvent SDB, "OnPlay", "lfm_OnPlayChange"
End Sub

Sub lfm_TogglePanel(Item)
  lfm_Panel.Common.Visible = not lfm_Panel.Common.Visible
  lfm_menu.Checked = lfm_Panel.Common.Visible
  If lfm_Panel.Common.Visible Then
    lfm_button.IconIndex = lfm_onIconIndex
    lfm_OnPlayChange
  Else
    lfm_button.IconIndex = lfm_offIconIndex
  End If
End Sub

Sub lfm_PanelClose(Item)
  lfm_menu.Checked = false
  lfm_button.IconIndex = lfm_offIconIndex
End Sub

Sub lfm_OnPlayChange
  If Not lfm_Panel.Common.Visible Then
	Exit Sub
  End If
  If lfm_CurrentArtist = SDB.Player.CurrentSong.ArtistName Then
	Exit Sub
  End If
  lfm_CurrentArtist = SDB.Player.CurrentSong.ArtistName
  lfm_Browser.Interf.Navigate ("http://www.last.fm/music/" & lfm_CurrentArtist)
End Sub
Last edited by oldskool73 on Sun May 28, 2006 2:04 pm, edited 2 times in total.

holterpolter
Posts: 292
Joined: Wed Feb 01, 2006 7:29 am
Location: Germany

Post by holterpolter » Sun May 28, 2006 11:00 am

I get an error in Line 15 Col 4

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Sun May 28, 2006 11:09 am

Did you use the installer to install the script?

Change line 15:
from

Code: Select all

lfm_Panel.lfm_BrowserDockedTo = 2
to

Code: Select all

lfm_Panel.DockedTo = 2
Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Sun May 28, 2006 11:13 am

BTW: It would be even better if you did it like this script http://www.mediamonkey.com/forum/viewtopic.php?t=7897
(choose between different sites)

Although the change might not be to big, I do suggest you to ask it to the original author of that script first.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

oldskool73
Posts: 38
Joined: Sat May 27, 2006 3:50 pm
Contact:

Post by oldskool73 » Sun May 28, 2006 1:11 pm

yup, typo fixed on code above and installer, damn find'n'replace :)

steggy : Cheers for the input. Might perhaps add an option to show results from Last.fm, WikiPedia or AllMusic if there is interest.

Don't think I'll make it a 'find more from same...' menu option as I like to have the panel open all the time anyway :)

Also, doesn't really make sense to me to be there as it doesn't find more songs (as the other options in this menu do), but instead finds info, so should perhaps be in the 'get more info' menu instead?

billywizz
Posts: 20
Joined: Fri May 19, 2006 12:53 pm

Post by billywizz » Wed May 31, 2006 4:45 am

Im not familiar with how to write scripts and being new to MM am looking round trying to find something that will display the Now Playing track details in a dockable (preferably) window. Details to include Cover Art and other ID3.2 tag data. I cant find anything that is like this amongst the scripts people have written so thought I might try out this script, bacause the screen shot looks really cool and it offers a reasonable compromise.

When I install it I get a small (1" square) browser window open at the top left of the MM screen that I cant move at all and only dissappears when I click on the supplied taskbar icon. Nothing else I do will move the browser window which covers important elements in the MM toolbar !! The small window asks that I log in to last fm?? Do I need an account with them to use the script ? Playing a track in MM has no affect on the browser window so basically it wont work for me at all. I'm obviously doing something wrong if it should look like your screenshot, but what??
Any help much appreciated

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Wed May 31, 2006 6:31 am

Hello

I can't directly help you with your problem, but what you were looking for in the first place was probably something like the "Detailed Song Info Panel" script ( http://www.mediamonkey.com/forum/viewtopic.php?t=6165 ).
A more simple alternative also exists (as dockable internal panel), but I can't find it right away. But it exists and is quite new, so you might easily find it if you want it.

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

Guest

Post by Guest » Wed May 31, 2006 6:59 am

hi Billy,

Steegy is probably right, all this script does is look up the artist on Last.fm so it's not really what you are looking for (...although I am working on just that, a complete rippoff... errr.. homage to... the Amarok now playing panel, see http://static.kdenews.org/danimo/amarok_airborne.png)

As to the problem, do you have the latest version of MediaMonkey?

billywizz
Posts: 20
Joined: Fri May 19, 2006 12:53 pm

Post by billywizz » Wed May 31, 2006 10:26 am

Excellent thanks for the replies. I checked out the detailed info panel and it is great.


As for this script I am using the latest MM version.

Thanks again for the help.

Post Reply