Skip to content

Instantly share code, notes, and snippets.

@imagesafari
Last active June 9, 2018 00:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imagesafari/e41160e182631271bf16942b520924dc to your computer and use it in GitHub Desktop.
Save imagesafari/e41160e182631271bf16942b520924dc to your computer and use it in GitHub Desktop.
Generate sdrtrunk aliases from RR talkgroup csv
#!/usr/bin/perl
#
# Convert RadioReference.com talkgroup csv download into xml to insert into sdrtrunk playlist.xml
#
# Usage: perl make_playlist.pl <csv filename> > <aliasfile.xml>
#
# Jon Anhold (jon@anhold.com) N8USK - 2016-08-19
use Data::Dumper;
my ($FILE) = @ARGV;
open FILE, "<$FILE";
while (<FILE>) {
my @line = ();
next if $_ =~ /^Decimal/; #skip header
chomp;
my ($decimaltg,$subfleet,$alphatag,$mode,$desc,$tag,$category) = split(',');
my $hextg = sprintf("%X", $decimaltg);
my $priority = "50";
if ($mode eq "E") { $priority = "-1" } # set encrypted channels to "Do Not Monitor"
# edit this to set certain categories to "Do Not Monitor"
if ($tag =~ /Sanitation|Public Works/) { $priority = "-1" }
print "<alias color=\"-16777216\" iconName=\"No Icon\" name=\"$alphatag: $desc - $tag - $category\">\n";
print "<id xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"talkgroupID\" talkgroup=\"$hextg\"/>\n";
print " <id xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"priority\" priority=\"$priority\"/>\n";
print "</alias>\n";
}
@imagesafari
Copy link
Author

imagesafari commented Aug 19, 2016

Download CSV from radioreference.com:

ohio_marcs-ip__multi-agency_radio_communications__p25__trunking_system__various__ohio_-_scanner_frequencies

ohio_marcs-ip__multi-agency_radio_communications__p25__trunking_system__various__ohio_-_scanner_frequencies

Run it through this perl:

3__jon_anhold_bespin-2____radio__zsh_

and then insert into the appropriate section of sdrtrunk playlist.xml

@imagesafari
Copy link
Author

Updated to set encrypted talk groups (mode = E) to priority -1

@hans109h
Copy link

hans109h commented Nov 8, 2016

If you are generating your own CSV to use with this script make sure that the values do not contain quotes or SDRTrunk won't parse the playlist file correctly.

@chudgoo
Copy link

chudgoo commented Jan 13, 2018

Very nice! Saved me a ton of time! Thanks for writing this!

@radiotec117
Copy link

This script works awesome! Thanks for taking the time to write this and share it!

@karlshea
Copy link

I needed to change the sprintf to

my $hextg = sprintf("%0.4X", $decimaltg);

for sdrtrunk to match any talkgroup with less than 4 characters.

@ImDroided
Copy link

Where do I put the output for this? I have it in my playlist_v2.xml file and the alias's show up in the tab but the now playing tab only shows talkgroup id's

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment