Sunday, July 28, 2013

Real-time meta data from Icecast using LiquidSoap (reprise)

I found a bug in my script. It pops up when there's an apostrophe or a paren in the song title. Below, I've modified the script slightly to fix this issue. Also, I've changed the external program call so that it uses notify-send to pop up the song title on my desktop.







set("log.file",false)
set("log.stdout",false)
set("log.level",3)
def apply_metadata(m) =
title = m["title"]
#print("Now playing: #{title}")
system("notify-send #{quote(title)}")
endradio = input.http(
user_agent="joats/kludged-up-script",
timeout=30.,
poll_delay=.5,
new_track_on_metadata=true,
force_mime="audio/mpeg",
buffer=.5,
id="original",
"http://music.joat:8000/airtime_128"
)

radio = on_metadata(apply_metadata,radio)
output.dummy(fallible=true,radio)

For those that can't see it, the changes are all in the line starting with "system".

Real-time meta data from Icecast using LiquidSoap

One of the annoying things about trying to pull metadata from Icecast is that it's a "pull". This is typically cron'd and can be as much as a minute "late". The following LiquidSoap script fixes this issue, allowing for a metadata "push".

The following listens to an Icecast stream and only extracts the metadata. It does not forward any audio. The below becomes valuable when you want to post "Now Playing" data to digital signage, IRC, or Jabber channels.







set("log.file",false)
set("log.stdout",false)
set("log.level",3)

def apply_metadata(m) =
title = m["title"]
print("Now playing: #{title}")
# system("~/Desktop/mytest.bash '#{title}'")
end

radio = input.http(
user_agent="joats/kludged-up-script",
timeout=30.,
poll_delay=.5,
new_track_on_metadata=true,
force_mime="audio/mpeg",
buffer=.5,
id="original",
"http://music.joat:8000/airtime_128"
)

radio = on_metadata(apply_metadata,radio)
output.dummy(fallible=true,radio)

Note that there's one line commented out in the above. It's there as an example, for when you want to pass the variable to an external script. About the only other line you'd need to change is the one containing "music.joat". Point that at your Icecast server.

Note: "output.dummy" is needed, to keep LiquidSoap from complaining that there's no output defined.

Monday, July 22, 2013

Please just STFU!

Maybe it's just me getting old but I miss the "good old days" of the Internet, where you could ask a question (or search) online and you'd get an answer or volunteers to help figure it out. Seeing as how I've been on the Internet in some or or other since the 80's (yeah, I'm an old fart), it's probably my age.

That being said, a long-running trend I've noticed is the tendency to respond to questions without actually answering them. Responses tend to fall into one of a stereotypical category. Example: while researching the implementation of dynamic DNS servers, I came across a mailing list thread that irked me a bit. The answers in the thread fell into one of a number of categories:

  • The nonspecific answer: set up a server and write a script.

  • The LMGTFY answer: search Google for it.

  • The fake offer of help: I'd help but I'm too busy.

  • The not answering the question answer: Responding to a response instead of the initial question (start a new thread, dammit!).

  • The "didn't understand the question" answer: Missed it by that much.

  • The cut and paste expert's answer: Someone attempting to make themselves knowledgeable via blatant plagarism.

  • The actual answer: It is usually: 1) the shortest response, 2) the last response, and 3) posted months or years after the initial question was asked.


Please! If you're not answering the question, you're just adding to the background noise. And, yeah, above is the reason that I vote down answers in ServerFault, StackOverflow, and SuperUser.

Friday, July 12, 2013

Docbook admonitions

For the better part of a year, I've been attempting to get Docbook to produce admonition graphics (i.e., note, important, and warning). Having worked with Publican, I wanted a similar format without all of the baggage that comes with Publican.

Publican fans should make note that I'm using a home-grown web editor for my Docbook work. I save brain cells by not having to remember which switches to use when running xsltproc at the command line. Publican was a nightmare in getting it to work with a similar interface (ask if you want either).

In any case, I've switched from running Docbook 4.5 to 5.0. The "good":

  • The syntax is cleaned up a bit.

  • Admonition graphics now work.

  • One more thing off of my "to do" list!


The bad:

  • I had to rewrite a chunk of the web editor's code to get it to work with 5.0.

  • The syntax checker is more rigid than the previous version (see closing tag discussion below)


The really ugly:

  • Primarily, everything that I've written to date. The older version was tolerant of missing close tags if a more-senior opening tag was declared. This is no longer the case. It appears that all closing tags must be explicit.

  • Then there's my hand-drawn graphics. The same gene set that prevents anyone in my family from being able to carry a tune, appears to also prevent any of us from being able to draw anything attractive. I need to find a nice set of "note", "important", and "warning" icons that are Creative Commons licensed, so that I can start throwing my docs up online.


The only other thing left to do is to fix the syntax content and to tweak the features on the web editor. Notes in the wiki and tool plus docs online shortly.

Sunday, July 7, 2013

Scripted XChat tab renaming II

Following is a slight modification to the XChat tab renaming script from 21 May. One thing that I noticed was that, if I closed a channel before running the script, the script would change the name of the server to whatever channel was missing.

In the following, the context line grabs the context for the specific channel. If the channel doesn't exist, context is set to 0. The fix is just a simple check for the status of the context variable. If it's set to 0, it skips renaming the channel.








#!/bin/bash

#following renames specific channels in XChat2

# "#192.168.2.215_docs" to "docs"

context=`dbus-send --dest=org.xchat.service --print-reply --type=method_call /org/xchat/Remote org.xchat.plugin.FindContext string:"bitlbee" string:"#192.168.2.215_docs" | tail -n1 | awk '{print $2}'`

if [ "$context" -ne 0 ]
then

dbus-send --dest=org.xchat.service --type=method_call /org/xchat/Remote org.xchat.plugin.SetContext uint32:$context

dbus-send --dest=org.xchat.service --type=method_call /org/xchat/Remote org.xchat.plugin.Command string:"settab docs"

fi

# repeat the above, as needed, for any other channels

The above works with my set up and no longer impacts the server names in XChat.

Friday, July 5, 2013

Visit to the 757 Makerspace

There's a new makerspace going up nearby. I finally had the time to visit it today. Although it's a bit further from home, it's still within an hour's drive from the house (through non-workday traffic).

With apologies to all concerned, I'm forced to compare it with the now-closed 757Labs hackerspace as that's the only other "space" I've ever visited.

  • The building is a bit older than the now-closed 757Labs, and it's much more industrial.

  • The location is in an industrial area. 757Labs was in a business area. I see this as an advantage as we can make more maker-type noises without worrying about upsetting the neighbors.

  • There's no hang-out facilities in the makerspace. This was an ongoing point of contention at 757Labs, between those there "to accomplish actual work" and those there to "network" (okay, to hang out on one of the couches).

  • Although there seems to be much the same equipment in both spaces, the makerspace has dedicated locations for them (i.e., a locked room for the equipment which requires special training (e.g., the laser cutter)). Maybe it's just that the makerspace isn't (yet?) overrun with people's in-progress projects.

  • There's a restaurant right across the street which has been described as having a "full menu". I'll hold my opinion until I've visited it.

  • There's just so much more space, though fewer chairs. Hopefully it'll force a focus on work (and cleaning up after yourself).

  • The dues appear to be around twice what 757Labs required.

  • Web site here. Facebook page here.

  • Oh, and parking! We won't talk about the parking issues experienced at 757Labs. Let's just say that, from the looks of it, the makerspace just has more.


I'm looking forward to being a member and getting some of my on-hold projects completed. First need is some cases for Raspberry Pi's with different daughterboards installed (e.g., PiFace, RazBerry).