StreamsTreeNode: Library subnode for your favourite streams

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

Moderators: Peke, Gurus

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

StreamsTreeNode: Library subnode for your favourite streams

Post by Steegy »

Functionality now built-in in MediaMonkey.
This script should not be necessary anymore.


StreamsTreeNode's own forum post.

The StreamsTreeNode script adds a node structure to the library node where you can add internet streams (or anything else) that start when you click on them.

INSTALLER: http://home.scarlet.be/ruben.castelein/ ... eeNode.exe

===========================================================

The script consists of 1 script file ("StreamsTreeNode.vbs").


StreamsTreeNode.vbs (for the Scripts\Auto folder)

Code: Select all

'====================================================================================
' 
' MEDIAMONKEY SCRIPT: StreamsTreeNode v1.1   by   Steegy aka RC (Ruben Castelein)
'
'  Adds internet streams (or something else) as nodes, to the library node
'  ..released 22.02.2006 (last updated 2006-12-13)
' 
'  You can manually change/add the streams using the "StreamsNodes.Add" lines (in Sub OnStartup)
'  e.g.    .Add "DI Trance", Array("http://160.79.128.40:7050", "Digitally Imported")
'          >> Shows a stream node "DI Trance" in the subnode "Digitally Imported", that links to "http://160.79.128.40:7050"
'
'  FORMAT: .Add "CAPTION", Array("LOCATION", "CATEGORY")
'  if there is no CATEGORY specified, the node is added to the main "Internet Streams" node
'
'  Set USE_EXTERNAL_PLAYER to True to use an external player (default is False: use internal MM player)
'  The location to the external player that can play internet streams (e.g. Winamp) must be set using PlayerEXE
'
'====================================================================================

Option Explicit


Dim StreamsNodes : Set StreamsNodes = CreateObject("Scripting.Dictionary")
Dim Categories : Set Categories = CreateObject("Scripting.Dictionary")

Const USE_EXTERNAL_PLAYER = False    ' If you set this to True, the player specified as PlayerEXE will be used to play the streams
Dim PlayerEXE : PlayerEXE = """" & "C:\Program Files\Winamp\Winamp.exe" & """"        ' As default, Winamp is set as external player

Dim Tree : Set Tree = SDB.MainTree



Sub OnStartup

    With StreamsNodes
        'MainStreams
        .Add "DI Trance", Array("http://160.79.128.40:7050", "")
  
        ' Digitally Imported (subcategory "Digitally Imported")
        .Add "Trance", Array("http://160.79.128.40:7050", "Digitally Imported")
        .Add "Eurodance", Array("http://160.79.128.40:7010", "Digitally Imported")
        .Add "Vocal Trance", Array("http://160.79.128.40:7004", "Digitally Imported")
        .Add "DJ Mixes", Array("http://160.79.128.40:7026", "Digitally Imported")
        .Add "Ambient", Array("http://160.79.128.40:7054", "Digitally Imported")
        .Add "New Age", Array("http://160.79.128.40:7030", "Digitally Imported")
        .Add "Best Of The 80s", Array("http://160.79.128.40:7038", "Digitally Imported")
  
        ' Jazz Streams (subcategory "Jazz")
        '.Add "FM 91 - Toronto", Array("http://www.jazz.fm/streaming/JAZZFM91.pls", "Jazz")
        '.Add "KSBR - Orange County CA", Array("http://www.live365.com/play/59719?membername=&session=ksbrcd%3A0&SaneID=67.97.53.153-1036082540940&lid=691-usa", "Jazz")
        '.Add "KCEA - Atherton CA", Array("http://kcea.realfx.net:8000/", "Jazz")
        '.Add "KCSM - San Mateo (ogg)", Array("http://hifi.kcsm.org:8040/vorbis2.ogg", "Jazz")
        '.Add "KJAZ - San Francisco", Array("http://205.188.215.228:8000", "Jazz")
        '.Add "KPLU - Tacoma", Array("http://66.225.205.102:80", "Jazz")
        '.Add "KUVO - Denver", Array("http://www.kuvo.org/stream/kuvo_2.pls", "Jazz")
        '.Add "KKJZ - Long Beach", Array("http://www.live365.com/play/kkjz1", "Jazz")
        '.Add "Jazz a la Mode", Array("http://www.live365.com/play/61471?membername=&session=jazzradiochannel%3A0&SaneID=67.97.53.153-1036082540940&lid=691-usa", "Jazz")
        '.Add "Jazz Den", Array("http://listen.thejazzden.org.uk:10025", "Jazz")
        '.Add "JazzPlayerRadio", Array("http://www.live365.com/play/elvii1", "Jazz")
        '.Add "Modern Jazz", Array("http://64.236.34.196:80/stream/1019", "Jazz")
        '.Add "radioioJazz", Array("http://69.28.128.148:80/stream/radioio_jazz_free_hi", "Jazz")
        '.Add "WAMC - Albany", Array("http://pubint.ic.llnwd.net/stream/pubint_wamc", "Jazz")
        '.Add "WEMU - Ann Arbor", Array("http://164.76.121.201:8000/broadband", "Jazz")
        '.Add "WLNZ - Lansing MI", Array("http://www.live365.com/play/273491?membername=&session=wlnzfm%3A0&SaneID=67.97.53.153-1036082540940&lid=691-usa", "Jazz")
        '.Add "WNCU - Durham NC", Array("http://152.9.6.199:1910/", "Jazz")
        '.Add "WWOZ - New Orleans", Array("http://wwoz-sc.streamguys.com/listen.pls", "Jazz")

        ' Classical Streams (subcategory "Classical")
        '.Add "Classical Music America", Array("http://66.250.45.52:8500", "Classical")
        '.Add "InfiniteClassical.com", Array("http://65.39.195.222:2000", "Classical")
        '.Add "KBAQ - Phoenix", Array("http://kbaq.org:8080/livestream/connect_high.pls", "Classical")
        '.Add "KUAT - Tucson", Array("http://150.135.250.53:9000", "Classical")
        '.Add "KUSC - Los Angeles", Array("http://www.kusc.org/streams/kusc96.m3u", "Classical")
        '.Add "KWAX - Eugene OR", Array("http://darkwing.uoregon.edu:8000/", "Classical")
        '.Add "KXPR - Sacramento", Array("http://66.225.205.53:80", "Classical")
        '.Add "magnatune.com Pre 1800", Array("http://magnatune.com/artists/music/Classical/Classical-http_shuffle.m3u", "Classical")
        '.Add "Otto's Baroque Music", Array("http://212.72.165.25:9112", "Classical")
        '.Add "radioIoClassical", Array("http://69.28.128.148:80/stream/radioio_classical_med", "Classical")
        '.Add "Swiss Internet Radio", Array("http://82.197.162.73:80", "Classical")
        '.Add "VPR", Array("http://64.202.98.51:8050", "Classical")
        '.Add "WCPE - Wake Forest NC", Array("http://www.ibiblio.org/wcpe/wcpe.pls", "Classical")
        '.Add "WDAV - Davidson NC", Array("http://www.wdav.org/wdav-112k.pls", "Classical")
        '.Add "We Met In Classics", Array("http://220.95.210.103:8000", "Classical")
        '.Add "WPSU - Penn State University", Array("http://128.118.86.117:8000/listen.pls", "Classical")
    End With


    Dim BaseNode : Set BaseNode = Tree.CreateNode
    BaseNode.Caption = "Internet Streams"
    BaseNode.IconIndex = 56
    Tree.AddNode Tree.Node_MyComputer, BaseNode, 1


    Dim StreamsNodesKeys : StreamsNodesKeys = StreamsNodes.Keys

    Dim i, ChildNode, SubNode, Location, Category

    For i = 0 To StreamsNodes.Count - 1
        Location = StreamsNodes(StreamsNodesKeys(i))(0)
	    Category = StreamsNodes(StreamsNodesKeys(i))(1)
  
        Set ChildNode = Tree.CreateNode
        ChildNode.Caption = StreamsNodesKeys(i)
        ChildNode.IconIndex = 40
        ChildNode.CustomData = Location
        ChildNode.UseScript = Script.ScriptPath
        ChildNode.OnFillTracksFunct = "OpenStream"
	
	    If Category = "" Then
            Tree.AddNode BaseNode, ChildNode, 3
	    Else
	        Set SubNode = CreateOrGetSubnode(BaseNode, Category, 56, 3)
	        Tree.AddNode SubNode, ChildNode, 3
	    End If
    Next

End Sub



Sub OpenStream(Node)

    If Not USE_EXTERNAL_PLAYER Then
        Dim StreamSong : Set StreamSong = SDB.NewSongData
        StreamSong.Path = Node.CustomData
        StreamSong.Title = Node.Caption
        SDB.Player.PlaylistAddTrack StreamSong
        SDB.Player.PlaylistMoveTrack SDB.Player.PlaylistCount - 1, 0
        SDB.Player.Stop
        SDB.Player.CurrentSongIndex = 0
        SDB.Player.Play
    Else
        Dim WShell : Set WShell = CreateObject("WScript.Shell")
        Dim Command : Command = PlayerEXE & " " & Node.CustomData
        Call WShell.Run(Command, 1, 0)
    End If
    
End Sub



Function CreateOrGetSubnode(ParentNode, Caption, IconIndex, RelativePosition)

    If Categories.Exists(Caption) Then
        Set CreateOrGetSubnode = Categories(Caption)
    Else
        Set CreateOrGetSubnode = Tree.CreateNode
        CreateOrGetSubnode.Caption = Caption
        CreateOrGetSubnode.IconIndex = IconIndex
        Tree.AddNode ParentNode, CreateOrGetSubnode, RelativePosition
        Categories.Add Caption, CreateOrGetSubnode
    End If
    
End Function
Cheers
Steegy
Last edited by Steegy on Sat Jun 18, 2011 4:28 pm, edited 4 times in total.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
revbob
Posts: 22
Joined: Wed Feb 22, 2006 10:44 am
Location: Decatur AL, USA
Contact:

Thanks, here's a variation

Post by revbob »

I've fiddled with your script, which was probably a bad idea since I've never written VBScript or VB before. :wink:

Here's my idea about what it ought to look like -- but not the way it should be coded! Warning! Evil code!

http://www.crispen.org/etc/StreamsTreeNode.vbs

What I'd do if I knew how to code in VBScript is use a triple (name, URL, genre) insted of a Key-Value pair, make an enum for the genres, and stick nodes under the proper parent in the main look, depending on what the value of the genre is.
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

What I'd do if I knew how to code in VBScript is use a triple (name, URL, genre) insted of a Key-Value pair, make an enum for the genres, and stick nodes under the proper parent in the main look, depending on what the value of the genre is.
I'll change the code so it adds the internet streams to a genre (or anything else) subnode of the "Internet Streams" node, at least if a genre is defined. If there's no genre defined, then the internet streams will be added to the main "Internet Streams" node.

I don't like to make code that would add an internet stream link to the Library > Genre node. It would be an inappropriate position there. A stream is not an artist/title/song so it shouldn't be shown as any of these.
Also, in my opinion there's no need for genre enums.

BTW: As you've certainly seen, VB(script) isn't so hard. You already know programming so... your code doesn't look bad, only not very "universal".
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
revbob
Posts: 22
Joined: Wed Feb 22, 2006 10:44 am
Location: Decatur AL, USA
Contact:

So where's the code? ;-)

Post by revbob »

Thanks very much for your kindness.

Yeah, I agree with you about the genres. The song genre is a different kind of thing from the stream genre. I was just thinking of having a nice simple and properly abstract loop: foreach Genre in Genres {...}

And I do take the point you made earlier, this whole enterprise is hackish. What's really needed is a way for users to edit stream nodes, perhaps as part of a whole user-specified thing? Beats me. That's why you get the big bucks. But I do thank you very much for whipping out a quick script for my purposes, and maybe some other folks can use it too.

I blogged about the whole genres thing a couple of days ago. It's a big, big problem. I'm sure you were way ahead of me on it: http://blog.crispen.org/archives/2006/02/20/more-tags/

Thanks again,
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

About the need for an easy way to add/edit/delete/organise these stream nodes, I can't agree with you more.
The main reason why I don't plan to add this yet is mentioned in the "TODO" in the script. I want to wait what the future version of MM brings on internet streaming support, and what MM users are expecting.
I don't want to do a lot of work if it then seems to be useless when the new version of MM comes out.

As a consequence of a request I made about this, maybe internet streams could be managed completely as in Winamp, i.e. used in playlists for example. When this is possible, you can organise them perfectly with playlists, child playlists, ... and maybe auto-playlists.

So, if there are more requests for an easy user interface for handling internet streams, I might consider it. But please first try to see how easy it is to manage them through the script file.


Concerning your blog about genres... multiple genres have already been requested...
Also, ID3v2 supports as many tags as you want, but to have conformity between programs (what is *very* important!), most programs only write the standard tags. That's the way it should be.
You can add as many tags as you want to a song in MediaMonkey, using e.g. the Custom fields (you can put more than one tag in them by splitting them with ; or something. With Magic Nodes, you can handle them as separate tags).
A song with all tags that are applicable is a nice idea (like Last.Fm does it), but would need a lot of work of course.
For that, if you just fill the current available standard tags correctly, you should find the songs you want.

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
revbob
Posts: 22
Joined: Wed Feb 22, 2006 10:44 am
Location: Decatur AL, USA
Contact:

Bravo!

Post by revbob »

Now that's great! And I noticed the tricky way you kept that key/value class. Sweet.

The tree now hangs from perhaps a more appropriate place, you demonstrate a "main stream" thing at the top of the tree, and you even include some music apart from the old fogey music I've put in the list. Bravo!

The only quibble I've got goes to your point of possibly implementing this in playlists. If you've got one thing that you call a "playlist" where MM progresses through a sequence of songs, playing them one at a time; and you have another thing you also call a "playlist" that MM doesn't step through at all, but requires the user to click on the stream she wants, I think you're going to confuse your users *and* unnecessarily limit your design.

For instance, thanks to your script, we're a lot closer to my ultimate goal (and I suspect other people's as well): you think media, you bring up MM. That exception is Pandora: http://www.pandora.com/ Even for local media I haven't catalogued yet, MM is well on its way to eroding a decade-long habit of using Windows Explorer. But Pandora fires up not a media player but a web browser (and Flash player).

Pandora may not be unique. There may be other places where it's impossible to extricate the media stream from the web page, or where the site is using a version of QT or Windows Media that WinAmp won't play. It seems to me that those URLs are much more like media stream URLs than playlists are.

Of course, maybe there isn't (in the user's mental world) one kind of object here, but two: media streams and web page media URLs.

Wrt genres, I agree that not using standards is madness. I'm even convinced (pretty much) that the right thing to do is put the composer in the composer tag and not duplicate it in the title, even if that means that all I see on the iPod is "Piano Sonata No. 2 in Eb - 1. Allegro". It's just that we all have gone through a paradigm shift where what was obvious before -- that a song should have one genre tag -- is now equally obviously wrong. But using a partially broken standard is still better than trying something on your own imho.

Thanks again! I'm listening right now.
jazzfido
Posts: 5
Joined: Fri Oct 20, 2006 3:10 am

Post by jazzfido »

Nice script. However, I don't understand why it is necessary to use an external player to play the streams. I can play my streams in MM, from a playlist, without having to use an external player.

Is it possible to change this script so it doesn't use an external player?
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

It certainly is possible. The reason why I used the external Winamp is because MM can't handle the pls (winamp playlist) files for streams (at least none of those I tried). Pls is used almost anywhere (for good reasons: flexibility (server location can change without problems) and several possible stream servers (if one is full/down, another one can be tried)) and at least for me this is essential.

I'll make a version that uses the external player right away.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
jazzfido
Posts: 5
Joined: Fri Oct 20, 2006 3:10 am

Post by jazzfido »

Steegy wrote:It certainly is possible. The reason why I used the external Winamp is because MM can't handle the pls (winamp playlist) files for streams (at least none of those I tried). Pls is used almost anywhere (for good reasons: flexibility (server location can change without problems) and several possible stream servers (if one is full/down, another one can be tried)) and at least for me this is essential.

I'll make a version that uses the external player right away.
It does seem like MM doesn't like .pls. A bit strange that; I would have thought that was an obvious format to support in an audio player. Maybe the script could be coded so that if the stream is a .pls stream then it would open in an external player and if it anything else it opens in MM? Or even better, make it customizable?

No matter what, I am glad that I have found MM (used to use WinAmp but it seems to crash all the time these days. Tried 5-10 other players that either suffer from not having a proper library or by not being able to play formats like .ra etc.). There are very few flaws in MM.

Cheers
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

For now, you can replace the original code

Code: Select all

Sub OpenStream(Node) 

  Dim WShell, Command 

  Set WShell = CreateObject("WScript.Shell") 
  Command = WinampEXE & " " & Node.CustomData 

  Result = WShell.Run(Command, 0, 0) 

End Sub 
with this:

Code: Select all

Sub OpenStream(Node)

    Dim StreamSong : Set StreamSong = SDB.NewSongData
    StreamSong.Path = Node.CustomData
    StreamSong.Title = Node.Caption
    SDB.Player.PlaylistAddTrack StreamSong
    SDB.Player.PlaylistMoveTrack SDB.Player.PlaylistCount - 1, 0
    SDB.Player.Stop
    SDB.Player.CurrentSongIndex = 0
    SDB.Player.Play

End Sub
Just make sure that all streams that you specify in the script are not-pls, but something like http://160.79.128.40:7010

I prefer not to put too much work in this (unless you really feel pls-support is needed) because I don't want my efforts to become useless once MM3.0 is out (I don't know what will be possible then, and what not), and I do have other work. Hopefully you understand this. Anyone else can contribute code too, of course.

You can easily get the http://160.79.128.40:7010 url out of a pls file by looking to it's code (just plain text).

Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
jazzfido
Posts: 5
Joined: Fri Oct 20, 2006 3:10 am

Post by jazzfido »

Works a treat! BBC's real streams (with the tara plugin), wma streams etc. all open in MM and work perfectly.

Thank you!
cherryplinth
Posts: 38
Joined: Sat Feb 18, 2006 4:44 pm
Location: sunny California

Post by cherryplinth »

This is dumb. How do I install this script in MM?

I can find the Scripts\Auto folder, but the copied code won't paste into the Scripts\Auto folder. It looks to me like maybe I have to first save the code as a VB Script file, but how do I that?

Whatever I have to do, could someone give me some elementary instructions on how to install the StreamsTreeNode script. It looks like an important script. Thanks.
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

See the FAQ for instructions on how to install AUto-scripts without installer.

Basicly you have to copy the code above, and paste it in a plain text file (e.g. using Notepad or Wordpad/Write). Then save that file as AnyNameYouWant.vbs (make sure that the file extension is vbs !) in MediaMonkey's Scripts\Auto folder, and restart MM.

Wait, I just added an installer here.
Just download, double-click and install, and then restart MediaMonkey.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
cherryplinth
Posts: 38
Joined: Sat Feb 18, 2006 4:44 pm
Location: sunny California

Post by cherryplinth »

hanks for the quick turn around. I have StreamsTreeNode installed and I can see the Internet Stream choices in the Library Menu.

But I seem to be getting a conflict which is preventing MM from playing the selected internet stream. I have tried opening about 20 different internet streams furnished in the script and they all lead to the same two error messages:

"Error #5 - MS VBScript runtime error
Invalid procedure call or arguement: 'Mid'
File:"C:\Program Files\MediaMonkey\Scripts\GoogleArtfinder.vbs"Line 76, column 2"

followed by:

"Error happened during script execution
Invalid procedure call or arguement: 'Mid"

In spite of these messages, the player (MM) opens up and starts playing the last song that I had played before installing the script. Closing out the two error message dialog boxes usually leads to a ctl-alt del shut down.

If I had to guess I would guess that Google ArtFinder is trying open up and find an albumn cover whenever I click on an Internet Stream - and Google ArtFinder is failing because it can't find albumn covers for Internet Streams. But that is just a guess and I don't understand computer code. The other scripts I have in my Scripts/Auto folder are Backup and Toolbar ArtFinder.
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

I send a message to Trixmoto, the author of the GoogleArtFinder script. Hopefully he can help you with this problem. In meantime, you can see if temporarily disabling GoogleArtFinder makes it work fine or not.

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