Streaming bookmarks made easy in Linux
I enjoy listening to audio streams. I can enjoy stations from cities where I once lived, from places I've visited, or just exotic locales I'll likely never visit. I could never come up with a good way to manage my streaming bookmarks. Perl came to the rescue. Using a single Perl script I store my favorite stations and can generate two tools.
The first tool creates Linux (Cinnamon) menu shortcuts for my stations. It also creates a file I can use with my simple URL shortener.
Check out my Perl script below.
#!/usr/bin/env perl
# This Perl script take a list of streaming URLS and does two things with it.
#
# 1. Creates Linux menu items for each station.
# 2. Creates a file that can be used with an Apache URL shortener.
#
# This is intended to be used with Linux. I suppose it could be modified to work with Windows and/or macOS.
# It assumes ~/.local/share/applications/streaming exists. nvlc must me installed. You can use a different
# player, be sure to modify the script to reflect this.
#
# To use add your favorite stations to the bottom of the script, run, and if nothing happens that's probably
# good news, it worked. Using Cinnamon (possibly other desktops) press the super key and then enter a station
# you want to play and you should hear something.
sub linuxMenu() {
$desktopPath = $_[0];
$desktopName = $_[1];
$desktopUrl = $_[2];
$desktopIcon = ($_[3] eq "") ? "streaming.png" : $_[3];
unlink "${desktopPath}/*.desktop";
$filename="${desktopPath}/${desktopName}.desktop";
open (MENU, ">", ${filename});
print MENU "[Desktop Entry]\n";
print MENU "Type=Application\n";
print MENU "Name=${desktopName}\n";
print MENU "Comment=${desktopName} streaming\n";
print MENU "Exec=nvlc \"${desktopUrl}\"\n";
print MENU "Terminal=true\n";
print MENU "Icon=/home/jcm/.local/share/icons/${desktopIcon}\n";
close (MENU);
}
# This feeds my Apache URL shortener.
# https://opensource.com/article/18/7/apache-url-shortener
sub apacheAliases() {
$apacheFile = $_[0];
$apacheNickname = $_[1];
$apacheUrl = $_[2];
open (APACHE, ">>", "${apacheFile}");
if ($apacheNickname ne "") {
print APACHE "s/${apacheNickname} ${apacheUrl}\n";
}
close (APACHE);
}
foreach (sort(<DATA>)) {
chomp;
$i++;
next if (/^#/);
($category,$name,$url,$tags,$favicon,$nickname) = split /~/;
&linuxMenu("/home/jcm/.local/share/applications/streaming",${name},${url},"${favicon}");
&apacheAliases("/home/jcm/Desktop/apache.txt",${nickname},${url});
}
__DATA__
#$category~$name~$url~$tags~$favicon~$nick
1970s~Magic 70s Florida~http://airspectrum.cdnstream1.com:8012/1605_192~~~m70fl
1980s~Austin 80s~http://n1fa-e2.revma.ihrhls.com:80/zc8403~~~austin80s
1980s~WRBQ (Q105)~http://playerservices.streamtheworld.com/pls/WRBQFM.pls~~~q105
BBC~BBC World Service~http://stream.live.vc.bbcmedia.co.uk/bbc_world_service~~~bbcws
Classic Rock~94.3 FM WIBG~http://ice7.securenetsystems.net/WIBGFM~~~wibg
Classic Rock~96 Rock~https://ample.revma.ihrhls.com/zc8917/18_ccr2w3iwb5a602/playlist.m3u8~96rock.jpg~96rock
Classic Rock~B97~https://stream.revma.ihrhls.com/zc2609~~~b97
Classic Rock~Classic Rock Florida HD~http://streaming505.radionomy.com:80/ClassicRockFloridaHD~~~crfl
Classic Rock~New Hampshire's 95.7~http://stream.abacast.net/direct/saga-wzidfmaac-ibc2~~~wzid
Public Radio~KAMU Radio FM 90.9~http://kamu.streamguys1.com/hd1-192~~~kamu
Public Radio~KUT 90.5 FM~http://kut.streamguys1.com/kut-free.aac~~~kut
Public Radio~WFIT~https://streaming.wfit.org/wfit-fm~~~wfit
Public Radio~WNYC~http://wnyc-iheart.streamguys.com/wnycfm-iheart.aac~~wnyc
Public Radio~WREK 91.1 Atlanta GA~http://streaming.wrek.org:8000/main/128kb.mp3~~~wrek
Public Radio~KBRW~http://tektite.streamguys1.com:5340/live~~~kbrw