{"id":927,"date":"2015-01-13T10:01:58","date_gmt":"2015-01-13T10:01:58","guid":{"rendered":"http:\/\/naich.net\/wordpress\/?p=927"},"modified":"2020-09-01T08:58:13","modified_gmt":"2020-09-01T08:58:13","slug":"pirpl-its-another-pirate-radio-playlist-thing","status":"publish","type":"post","link":"https:\/\/naich.net\/wordpress\/index.php\/pirpl-its-another-pirate-radio-playlist-thing\/","title":{"rendered":"Pirpl &#8211; it&#8217;s another Pirate Radio PLaylist thing!"},"content":{"rendered":"<p><a href=\"https:\/\/naich.net\/wordpress\/wp-content\/uploads\/2015\/01\/Old-Radio-Station-Edited.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright  wp-image-939\" src=\"https:\/\/naich.net\/wordpress\/wp-content\/uploads\/2015\/01\/Old-Radio-Station-Edited.jpg\" alt=\"Old Radio Station Edited\" width=\"371\" height=\"273\"><\/a>If you liked the previous <a title=\"Pi-rate Radio Jukebox\" href=\"https:\/\/naich.net\/wordpress\/?p=890\">Pi-rate Radio Jukebox<\/a>&nbsp;(and 15 people did!), you won&#8217;t want to miss this latest version of it. &nbsp;It&#8217;s basically the same thing, but it runs as a <a href=\"https:\/\/kb.iu.edu\/d\/aiau\">daemon<\/a>,&nbsp;so you can fire up your favourite tunes using a browser rather than&nbsp;logging in to your Pi to start up scripts. &nbsp;As usual it&#8217;s horribly coded in Bash and features a fuck-ugly interface with no aesthetic considerations whatsoever. &nbsp;You can insert prettiness yourself if you want to &#8211; it&#8217;s easy enough because the web pages are done as templates. &nbsp;All the code is commented to <del>pad it out and make it look more substantial than it is<\/del> clearly show what is going on.<\/p>\n<p>This one is called <span style=\"color: #8000ff;\">Pirpl<\/span>&nbsp;and is pronounced &#8220;Purple&#8221; because it seemed like a good idea at the time. &nbsp;Something to do with <strong>Pi<\/strong>rate <strong>R<\/strong>adio <strong>PL<\/strong>aylists or something &#8211; it&#8217;s all a bit tenuous, quite frankly. &nbsp;Anyway, the main improvement is that rather than telling it what to play from the command line, &nbsp;you pick what you want to listen to from a list on a web page. &nbsp;As before, you can tell it to play all the MP3s in a directory (and all sub-directories) or give it a list of MP3s to play in a file. &nbsp;It&#8217;ll then play them (in a random order if you want), showing the current tune on a web page and allowing you to skip a track or stop playing and go back to the playlist chooser.<\/p>\n<p>Other improvements are:<\/p>\n<ul>\n<li>Support for MP3 ID tags in both version 1 and version 2 format. &nbsp;The old player&nbsp;only recognised version 1 tags.<\/li>\n<li>Umm&#8230; that&#8217;s about it really. &nbsp;The code is slightly better in places, I suppose. &nbsp;Still the playlist choosing thing is good, isn&#8217;t it?<\/li>\n<\/ul>\n<h3>Quick start<\/h3>\n<figure id=\"attachment_943\" aria-describedby=\"caption-attachment-943\" style=\"width: 289px\" class=\"wp-caption alignright\"><a href=\"http:\/\/naich.net\/wordpress\/wp-content\/uploads\/2015\/01\/pirpl.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-943 size-full\" src=\"http:\/\/naich.net\/wordpress\/wp-content\/uploads\/2015\/01\/pirpl.png\" alt=\"pirpl\" width=\"289\" height=\"321\" srcset=\"https:\/\/naich.net\/wordpress\/wp-content\/uploads\/2015\/01\/pirpl.png 289w, https:\/\/naich.net\/wordpress\/wp-content\/uploads\/2015\/01\/pirpl-270x300.png 270w\" sizes=\"auto, (max-width: 289px) 100vw, 289px\" \/><\/a><figcaption id=\"caption-attachment-943\" class=\"wp-caption-text\">Nice clean lines. What is not to like?<\/figcaption><\/figure>\n<p>Want to get going already? &nbsp;<a title=\"Download the archive here\" href=\"http:\/\/naich.net\/pirpl\/pirpl-1.0.tar.gz\">This is the tarred archive<\/a>&nbsp;(20.8 kB)<\/p>\n<p>Download the archive, untar it, edit the &#8220;pirpl_conf&#8221;&nbsp;file (you&#8217;ll see why in the file) and add playlist information to the &#8220;pirpl_playlist.conf&#8221; (you&#8217;ll see how in the file). &nbsp;Before you can start it up, you need to make sure that the following packages are installed on your Pi: &nbsp;netcat, sox, id3v2. &nbsp;If one or more isn&#8217;t then, install any missing ones&nbsp;with<\/p>\n<pre>sudo apt-get install netcat sox id3v2<\/pre>\n<p>The program that does the transmitting needs to run as root, so setuid&nbsp;&nbsp;that bad boy up with:<\/p>\n<pre>sudo chown root:root pifm\nsudo chmod 4755 pifm<\/pre>\n<p>Before you can oscillate any electromagnetic fields, you&#8217;ll need to make an aerial for your Pi. &nbsp;<a title=\"Pi-rate Radio Jukebox\" href=\"http:\/\/naich.net\/wordpress\/?p=890\" target=\"_blank\" rel=\"noopener noreferrer\">Instructions are in first paragraph of the&nbsp;drivel&nbsp;for pirbj<\/a>.<\/p>\n<p>Once you are sorted, start the whole lot up&nbsp;with the command:<\/p>\n<pre>.\/pirpl.sh pirpl_conf<\/pre>\n<p>To stop it press CTRL-C.<\/p>\n<h3>The gruesome details<\/h3>\n<p>There are quite a few files that make up <span style=\"color: #8000ff;\">pirpl<\/span>. &nbsp;This is how they work.<\/p>\n<h4><a title=\"The program that does most of it\" href=\"http:\/\/naich.net\/pirpl\/pirpl.sh\" target=\"_blank\" rel=\"noopener noreferrer\">pirpl.sh<\/a><\/h4>\n<p>This is the main program file. &nbsp;Have a look at it if you want to gaze in wonder at the insane beauty of Bash, but there is no need to edit it. &nbsp;All the configuration stuff is now in&#8230;<\/p>\n<h4><a title=\"The configuration file\" href=\"http:\/\/naich.net\/pirpl\/pirpl_conf\" target=\"_blank\" rel=\"noopener noreferrer\">pirpl_conf<\/a><\/h4>\n<p>Various settings for things like the names of files, the transmitter frequency and where you installed <span style=\"color: #8000ff;\">pirpl<\/span>. &nbsp;You probably want to change the transmitter frequency to somewhere empty on your radio&#8217;s dial. &nbsp;You will also need to change&nbsp;PIFM_BASE to the directory where you untarred the files. &nbsp;The web server port should not be accessible to the outside world. &nbsp;Other than that, it&#8217;s probably best to leave everything else as it is unless you really like reading error messages.<\/p>\n<h4><a title=\"Playlist configuration\" href=\"http:\/\/naich.net\/pirpl\/pirpl_playlist.conf\" target=\"_blank\" rel=\"noopener noreferrer\">pirpl_playlist.conf<\/a><\/h4>\n<p>This is where you tell <span style=\"color: #8000ff;\">pirpl&nbsp;<\/span>all about your music. &nbsp;Each line has the path to the playlist or directory containing MP3s, the displayed name of the playlist, and whether to shuffle it. &nbsp;I&#8217;ve left all my playlists in as examples. &nbsp;Actually, I forgot to delete them and now I can&#8217;t be bothered to take them out. &nbsp;Sorry. &nbsp;If you are using a playlist rather than a directory, the format is one path to an MP3 per line.<\/p>\n<h4><a title=\"Playlist template\" href=\"http:\/\/naich.net\/pirpl\/pirpl_playlist_template.html\" target=\"_blank\" rel=\"noopener noreferrer\">pirpl_playlist_template.html<\/a><\/h4>\n<p>Your browser will show this as a web page so open that link, right click and choose &#8220;View page source&#8221; to see what is in it. &nbsp;You have probably worked out for yourself that this is a template file for showing the available playlists, as defined in pirpl_playlist.conf. &nbsp;The bits in &#8220;@@&#8221;s are replaced with the information about playlists. &nbsp;I&#8217;m sure you can work out what&#8217;s going on in that file.<\/p>\n<h4><a title=\"Track info template\" href=\"http:\/\/naich.net\/pirpl\/pirpl_template.html\" target=\"_blank\" rel=\"noopener noreferrer\">pirpl_template.html<\/a><\/h4>\n<p>This is the template for showing information about the track that is playing. &nbsp;It&#8217;s the usual stark functionality you get from me, simply because it works and I can&#8217;t be bothered to try and make it look nice.<\/p>\n<h4><a title=\"Web server script\" href=\"http:\/\/naich.net\/pirpl\/pirpl_server.sh\" target=\"_blank\" rel=\"noopener noreferrer\">pirpl_server.sh<\/a><\/h4>\n<p>This is the script that does the web server. &nbsp;It doesn&#8217;t do much; it just outputs a file to the browser and filters commands out of the text sent by the browser, storing any it finds in a file which is picked up by pirpl.sh.<\/p>\n<h4><a title=\"Source code for pifm\" href=\"http:\/\/naich.net\/pirpl\/source\/pifm.c\" target=\"_blank\" rel=\"noopener noreferrer\">pifm and source\/pifm.c<\/a><\/h4>\n<p>The program that does the transmitting. &nbsp;It&#8217;s a barely modified version of <a title=\"Wibble\" href=\"http:\/\/www.icrobotics.co.uk\/wiki\/index.php\/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter\">this one<\/a>&nbsp;and the source is included if you want to have a look and compile it yourself.<\/p>\n<h4><a title=\"Start as user\" href=\"http:\/\/naich.net\/pirpl\/startwrapper.sh\" target=\"_blank\" rel=\"noopener noreferrer\">startwrapper.sh<\/a><\/h4>\n<p>The best way to start <span style=\"color: #aa00b3;\"><span style=\"color: #a500ad;\">Pirpl<\/span><span style=\"color: #000000;\"> is as a service, when the Pi boots up. &nbsp;You don&#8217;t want to run it as root, so the easiest way to start it as a normal user is to put&nbsp;a&nbsp;command similar to this in your \/etc\/rc.local file:<\/span><\/span><\/p>\n<pre>sudo -u naich \/home\/naich\/pirpl\/startwrapper.sh<\/pre>\n<p>You could use sudo to start <span style=\"color: #a500ad;\">Pirpl<\/span> directly but you end up with sudo hanging around like a bad smell in your process list.<\/p>\n<h3>In conclusion<\/h3>\n<p>Using this program without the proper license is probably illegal where you are, so don&#8217;t use it ever.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you liked the previous Pi-rate Radio Jukebox&nbsp;(and 15 people did!), you won&#8217;t want to miss this latest version of it. &nbsp;It&#8217;s basically the same thing, but it runs as a daemon,&nbsp;so you can fire up your favourite tunes using a browser rather than&nbsp;logging in to your Pi to start up scripts. &nbsp;As usual it&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[74,102],"tags":[],"class_list":["post-927","post","type-post","status-publish","format-standard","hentry","category-geek","category-raspberry-pi"],"_links":{"self":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=927"}],"version-history":[{"count":14,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/927\/revisions"}],"predecessor-version":[{"id":1159,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/927\/revisions\/1159"}],"wp:attachment":[{"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/naich.net\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}