commit d757a20d6ea9868cdec4113898a64c74f78b4fa0 parent 95a43befc0f32ece8aa9dfa26cca9b50ba2c5fc9 Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Fri, 4 Dec 2020 07:32:04 +0100 plumb: translate gph line into url Diffstat:
M | .local/bin/plumb | | | 15 | ++++++++++----- |
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/.local/bin/plumb b/.local/bin/plumb @@ -199,13 +199,18 @@ handle_url() { if regexmatch "$t" '^(0|1|3|7|9|g|I|h)' && \ [ "$(printf '%s' "$t" | awk -F'\t' '{print NF}')" -eq 4 ]; then # construct uri from gopher item - type="$(printf '%s' "$t" | cut -c 1)" - path="$(printf '%s' "$t" | awk -F'\t' '{print $2}')" - host="$(printf '%s' "$t" | awk -F'\t' '{print $3}')" - port="$(printf '%s' "$t" | awk -F'\t' '{print $4}')" + type="$(printf '%s' "$t" | cut -c1)" + path="$(printf '%s' "$t" | cut -d' ' -f2)" + host="$(printf '%s' "$t" | cut -d' ' -f3)" + port="$(printf '%s' "$t" | cut -d' ' -f4)" + t="gopher://${host}:${port}/${type}${path}" + elif regexmatch "$t" '^\[(0|1|3|7|9|g|I|h)\|.*\|.*\|.*\|[0-9]+\]$'; then + type="$(printf '%s' "$t" | cut -c2)" + path="$(printf '%s' "$t" | cut -d'|' -f3)" + host="$(printf '%s' "$t" | cut -d'|' -f4)" + port="$(printf '%s' "$t" | cut -d'|' -f5 | sed 's,\],,')" t="gopher://${host}:${port}/${type}${path}" fi - if regeximatch "$t" '\.(mp4|mkv|webm|avi|ogv|gif|m3u|pls)$'; then detach $prefix mpv "$t" elif regeximatch "$t" '^radio://'; then