Page 1 of 3

[MM2+3] Search Google, Wikipedia, Last.fm, ...

Posted: Mon Jan 30, 2006 2:32 am
by onkel_enno
As a Wish of Mhesse, here is a small script which creates 2 Entries in the Find more From - Menu-Item to Search google for "the Artist" or "the Artist and the Album".
Maybe someone else needs it too.
BTW: The URL google.de can easily be changed :wink:

- Create a file Google.vbs in Scripts\Auto and paste the code into it.
- Start MM.
- Enjoy!

Code: Select all

Sub OnStartUp
	SDB.UI.AddMenuItemSep SDB.UI.Menu_Pop_TrackList_MoreFrom, -1, -1
	SDB.UI.AddMenuItemSep SDB.UI.Menu_Pop_NP_MoreFrom, -1, -1
	
	Dim MenuItem
	Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList_MoreFrom, -1, -1)
	MenuItem.Caption = SDB.Localize("Artist") + " (google.de)"
	MenuItem.IconIndex = 37
	MenuItem.OnClickFunc = "Google"
	MenuItem.UseScript = Script.ScriptPath
	MenuItem.Hint = "Artist"
	
	Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP_MoreFrom, -1, -1)
	MenuItem.Caption = SDB.Localize("Artist") + " (google.de)"
	MenuItem.IconIndex = 37
	MenuItem.OnClickFunc = "Google"
	MenuItem.UseScript = Script.ScriptPath
	MenuItem.Hint = "Artist"
	
	Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList_MoreFrom, -1, -1)
	MenuItem.Caption = SDB.Localize("Album") + " (google.de)"
	MenuItem.IconIndex = 37
	MenuItem.OnClickFunc = "Google"
	MenuItem.UseScript = Script.ScriptPath
	MenuItem.Hint = "Album"
	
	Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP_MoreFrom, -1, -1)
	MenuItem.Caption = SDB.Localize("Album") + " (google.de)"
	MenuItem.IconIndex = 37
	MenuItem.OnClickFunc = "Google"
	MenuItem.UseScript = Script.ScriptPath
	MenuItem.Hint = "Album"
	
	Set MenuItem = Nothing
End Sub

Sub Google(MenuItem)
	if SDB.SelectedSongList.Count > 0 then
		Dim Song
		Set Song = SDB.SelectedSongList.Item(0)
		Dim Artist
		Dim Album
	
		Artist = "%22" + Replace(Song.ArtistName, " ", "%20") + "%22"
		Artist = Replace(Artist, "&", "%26")
		Album = "%22" + Replace(Song.AlbumName, " ", "%20") + "%22"
		Album = Replace(Album, "&", "%26")
		
		Dim WshShell
		Set WshShell = CreateObject("WScript.Shell")
		if MenuItem.Hint = "Artist" then
			WshShell.Run("www.google.de/search?q=" + Artist + "")
		else
			WshShell.Run("www.google.de/search?q=" + Artist + "+" + Album)
		end if
		Set WshShell = Nothing
	end if
end Sub

Posted: Mon Jan 30, 2006 5:01 am
by trixmoto
Useful script, I like it! :)

Posted: Mon Jan 30, 2006 6:23 am
by Sammy20
Nice!

Request: Could you make a script so it searches http://www.allmusic.com/ for the artist profile.

Wait, not to sound too greedy, but it would be cool if it had 3 options in a sub-menu to display search results for:

Wikipedia
AMG All music
last.fm

This would be very handy.

Posted: Mon Jan 30, 2006 6:51 am
by onkel_enno
Thx you both. 8)

I'm not sure about these 3. I can't find something about URL I can put the Serach Criterias in :-?
Maybe someone else has an idea. Trix?

Posted: Mon Jan 30, 2006 7:01 am
by Sammy20
I know of a script that has the search code for those 3 sites. I'll go fetch it now.....

Posted: Mon Jan 30, 2006 7:05 am
by Lowlander
Wikipedia:
http://en.wikipedia.org/wiki/Artist

lastfm:
http://www.last.fm/explore/explore.php? ... =[b]Artist[/b] for search and http://www.last.fm/music/Artist for artist page.

allmusic
works with a dll and encrypted url so a no go it seems.

Posted: Mon Jan 30, 2006 7:08 am
by trixmoto
:) Wikipedia: Use the link

Code: Select all

WshShell.Run("http://en.wikipedia.org/wiki/Special:Search?search=" + Artist + "&go=Go")
:( Allmusic: Doesn't use open search links, not sure how you'd do that.

:) Last.fm: Use this link

Code: Select all

WshShell.Run("http://www.last.fm/explore/search.php?q=" + Artist + "&m=artists")

Posted: Mon Jan 30, 2006 7:14 am
by trixmoto
Looks like Lowlander has beaten me to it! :oops:

Although, I'd recommend using the Wikipedia (and Last.fm) search links rather than the direct links, as you get more useful pages if your match does not exist.

Posted: Mon Jan 30, 2006 7:35 am
by Lowlander

Posted: Mon Jan 30, 2006 7:47 am
by Sammy20
Great, thanks guys.

Posted: Mon Jan 30, 2006 7:52 am
by onkel_enno
Nice work guys :lol:

Posted: Mon Jan 30, 2006 8:04 am
by Sammy20
Well I suck.

I just tried making a script for all those sites. It added in MM successfully, but when I click on it I get a 'unknown name' error message. Here's the code

Code: Select all

 removed by request 

Can someone make them for me.

Posted: Mon Jan 30, 2006 8:12 am
by onkel_enno
Your OnClickFunc-Method points to Wikipedia, but there is no Wikipedia-Procedure. Rename Sub Google(Menuitem) to Sub Wikipedia(Menuitem).

Posted: Mon Jan 30, 2006 8:44 am
by Sammy20
That fixed it. Thank you 8)


Could someone help me with allmusic. I tried your code lowlander and got this result:

http://www.allmusic.com/cg/amg.dll?P=am ... s%22&go=Go

Here's my code:

Code: Select all

 Removed by request 

Posted: Mon Jan 30, 2006 8:49 am
by Lowlander
For allmusic you would need to do this I think:

Code: Select all

Artist = Replace(Song.ArtistName, " ", "")
You also don't need this in the url

Code: Select all

&go=Go