💾 Archived View for perplexing.space › 2020 › silly-cli-mistakes.gmi captured on 2020-11-07 at 01:15:29. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2020-10-31)

-=-=-=-=-=-=-

Silly CLI Mistakes

2020-09-29

When I wrote previously⁰ about streaming gemcasts without any special client support, I included a kludge to offset the first line of gemini response from the audio file content.

The full command I mentioned was:

echo -en 'C:gemini://kwiecien.us/gemcast/20200828.ogg\r\n' | \
  openssl s_client -quiet -connect kwiecien.us:1965 | \
  tail -c +30 | \
  mpv --cache-secs=10 -

Where the call to "tail" is used to truncate what was a response like:

20 application/octet-stream\r\n

Which sort-of worked, but of course broke as soon as the smallest thing changed. Listening to the latest gemcast from Ben¹ I noticed the above wasn't working because the response was now:

20 audio/ogg\r\n

I don't know why it didn't occur to me the first time, probably because I was thinking of the audio file as a binary format, but the response is textual -- which means sed would work better here to delete the first line. The following seems to be the better "fetch thing from gemini" and is more robust in terms of response and filetype:

echo -en 'C:gemini://kwiecien.us/gemcast/20200828.ogg\r\n' | \
  openssl s_client -quiet -connect kwiecien.us:1965 | \
  sed '1d' | \
  mpv --cache-secs=10 -

I should really try out acdw's more polished script², I don't yet use a client that deals gracefully with things like large images, it'd be nice to figure out a way to do something like "pipe to image viewer" (or xdg-open).

[0]: gemini://perplexing.space/2020/streaming-gemcasts-conlangs.gmi

[1]: gemini://kwiecien.us/gemcast/index.gmi

[2]: gemini://gemlog.blue/users/acdw/1599345870.gmi