MusicBee DI Radio Station List

I’ve been checking out MusicBee for my tunes since reading about it in the Lifehacker article Top 10 Underhyped Windows Apps (applications actually). Besides adding some local files I also wanted to import the entire list of Digitally Imported radio stations, as that’s what I’m mostly listening too nowadays (there’s something for every mood. I couldn’t find a list in proper OPML format however. Adding all of them manually quickly gets boring, but PowerShell offers a nice solution, especially as there’s already an API available one can tap into: http://tobiass.eu/api.

A nice occasion to make some publicity for the Invoke-WebRequest, a new cmdlet in PowerShell 3.0, that allows for acting on the contents of webpages:

<#
# ==============================================================================================
# NAME:
#    Get-AllDIChannels.ps1
# ==============================================================================================
# AUTHOR:
#    koen.vermoesen@xylos.com
# ==============================================================================================
# DESCRIPTION:
#    This script preps and opml with all DI radio stations for import in MusicBee
#       Digitally Imported (DI): http://www.di.fm/
#       MusicBee (MB): http://getmusicbee.com
#       API: http://tobiass.eu/api
# ==============================================================================================
# DATE:
#    23 February 2013
# ==============================================================================================
# TO DO:
#    /
# ==============================================================================================
# HISTORY:
#    2013-01-23 Initial Version
# ==============================================================================================
#>

$DIAPI = "http://tobiass.eu/api/channels/di.fm"
$XMLChannels = Join-path $env:TEMP -ChildPath "AllDIChannels.xml"
$RootURI = "http://listen.di.fm/public3/"

# http://dmitrysotnikov.wordpress.com/2012/08/06/new-in-powershell-3-parse-html-without-ie-object-unless-a-local-file/
$ChannelList = (Invoke-WebRequest -URI $DIAPI).content

$TimeStamp = Get-Date -Format s
$XMLHeader = @"
<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
  <head>
    <title>Complete DI Channel List for importing in MusicBee</title>
    <dateCreated>$TimeStamp</dateCreated>
  </head>
  <body>
"@
$XMLFooter = @"
  </body>
</opml>
"@

Out-File -InputObject $XMLHeader -Encoding utf8 -FilePath $XMLChannels   # overwrites if it already exists

$ChannelList.split("`n") | % {
    [String]$Entry = $_
    [Array]$Channel = $Entry.Split("|")
    $Label = $Channel[0]
    $ID = $Channel[1]
    $URL = -Join $RootURI + $ID + ".pls"
    if ($Label) {
        Out-Host -InputObject "Writing $Label"
        # xml label (e.g. description, category) need to be lowercase!
        out-File -InputObject (-Join "    <outline text=`"DI " + $Label + "`" description=`"" + $Label + "`" category=`"Electronic Dance Music/MP3/96k/`" type=`"link`" url=`"" + $URL + "`" />") -Encoding utf8 -Append -FilePath $XMLChannels
    }
}

Out-File -InputObject $XMLFooter -Encoding utf8 -FilePath $XMLChannels -Append

The resulting xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<opml version="2.0">
  <head>
    <title>Complete DI Channel List for importing in MusicBee</title>
    <dateCreated>2013-02-24T10:27:42</dateCreated>
  </head>
  <body>
    <outline text="DI Ambient" description="Ambient" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/ambient.pls" />
    <outline text="DI Breaks" description="Breaks" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/breaks.pls" />
    <outline text="DI Chillout" description="Chillout" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/chillout.pls" />
    <outline text="DI Chillout Dreams" description="Chillout Dreams" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/chilloutdreams.pls" />
    <outline text="DI Chiptunes" description="Chiptunes" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/chiptunes.pls" />
    <outline text="DI Classic EuroDance" description="Classic EuroDance" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/classiceurodance.pls" />
    <outline text="DI Classic EuroDisco" description="Classic EuroDisco" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/classiceurodisco.pls" />
    <outline text="DI Classic Trance" description="Classic Trance" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/classictrance.pls" />
    <outline text="DI Classic Vocal Trance" description="Classic Vocal Trance" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/classicvocaltrance.pls" />
    <outline text="DI Club Dubstep" description="Club Dubstep" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/clubdubstep.pls" />
    <outline text="DI Club Sounds" description="Club Sounds" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/club.pls" />
    <outline text="DI Cosmic Downtempo" description="Cosmic Downtempo" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/cosmicdowntempo.pls" />
    <outline text="DI DJ Mixes" description="DJ Mixes" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/djmixes.pls" />
    <outline text="DI Dark DnB" description="Dark DnB" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/darkdnb.pls" />
    <outline text="DI Deep House" description="Deep House" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/deephouse.pls" />
    <outline text="DI Deep Nu-Disco" description="Deep Nu-Disco" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/deepnudisco.pls" />
    <outline text="DI Deep Tech" description="Deep Tech" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/deeptech.pls" />
    <outline text="DI Disco House" description="Disco House" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/discohouse.pls" />
    <outline text="DI Drum 'n Bass" description="Drum 'n Bass" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/drumandbass.pls" />
    <outline text="DI Dubstep" description="Dubstep" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/dubstep.pls" />
    <outline text="DI Electro House" description="Electro House" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/electro.pls" />
    <outline text="DI Epic Trance" description="Epic Trance" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/epictrance.pls" />
    <outline text="DI EuroDance" description="EuroDance" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/eurodance.pls" />
    <outline text="DI Funky House" description="Funky House" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/funkyhouse.pls" />
    <outline text="DI Future Synthpop" description="Future Synthpop" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/futuresynthpop.pls" />
    <outline text="DI Glitch Hop" description="Glitch Hop" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/glitchhop.pls" />
    <outline text="DI Goa-Psy Trance" description="Goa-Psy Trance" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/goapsy.pls" />
    <outline text="DI Hands Up" description="Hands Up" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/handsup.pls" />
    <outline text="DI Hard Dance" description="Hard Dance" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/harddance.pls" />
    <outline text="DI Hardcore" description="Hardcore" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/hardcore.pls" />
    <outline text="DI Hardstyle" description="Hardstyle" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/hardstyle.pls" />
    <outline text="DI House" description="House" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/house.pls" />
    <outline text="DI Latin House" description="Latin House" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/latinhouse.pls" />
    <outline text="DI Liquid DnB" description="Liquid DnB" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/liquiddnb.pls" />
    <outline text="DI Liquid Dubstep" description="Liquid Dubstep" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/liquiddubstep.pls" />
    <outline text="DI Lounge" description="Lounge" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/lounge.pls" />
    <outline text="DI Minimal" description="Minimal" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/minimal.pls" />
    <outline text="DI Oldschool Acid" description="Oldschool Acid" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/oldschoolacid.pls" />
    <outline text="DI Oldschool Electronica" description="Oldschool Electronica" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/classictechno.pls" />
    <outline text="DI Progressive" description="Progressive" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/progressive.pls" />
    <outline text="DI Progressive Psy" description="Progressive Psy" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/progressivepsy.pls" />
    <outline text="DI PsyChill" description="PsyChill" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/psychill.pls" />
    <outline text="DI Soulful House" description="Soulful House" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/soulfulhouse.pls" />
    <outline text="DI Space Dreams" description="Space Dreams" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/spacemusic.pls" />
    <outline text="DI Tech House" description="Tech House" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/techhouse.pls" />
    <outline text="DI Techno" description="Techno" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/techno.pls" />
    <outline text="DI Trance" description="Trance" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/trance.pls" />
    <outline text="DI Tribal House" description="Tribal House" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/tribalhouse.pls" />
    <outline text="DI UK Garage" description="UK Garage" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/ukgarage.pls" />
    <outline text="DI Vocal Chillout" description="Vocal Chillout" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/vocalchillout.pls" />
    <outline text="DI Vocal Trance" description="Vocal Trance" category="Electronic Dance Music/MP3/96k/" type="link" url="http://listen.di.fm/public3/vocaltrance.pls" />
  </body>
</opml>

You can use it to import the list op radio stations:

Image 116

Note that you seem to have to reboot before all of the radio stations to show up

Image 119

Image 117

Alternatively, one could look into Tobiass’ own lightweight di.fm player or the DI.fm “Mondern UI” app if you’re a Windows 8 user as an alternative: . The latter certainly has stunning graphics.

Di.fm

 

Enjoy the beats,

Koen

http://blog.koenvermoesen.be/about-koen/

Tagged with: ,
Posted in PowerShell, Scripting
IT Pro Summer GP
IT Pro Summer Grand Prix
MVA
Microsoft Virtual Academy
Pro-Exchange
Pro-Exchange / Pro-Lync / Pro-Office365
MEET

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 158 other followers

%d bloggers like this: