forked from LBRYCommunity/lbry-sdk
33 lines
659 B
Text
33 lines
659 B
Text
|
#!/bin/bash
|
||
|
|
||
|
set -euo pipefail
|
||
|
|
||
|
urlencode() {
|
||
|
local LANG=C
|
||
|
local length="${#1}"
|
||
|
for (( i = 0; i < length; i++ )); do
|
||
|
local c="${1:i:1}"
|
||
|
case $c in
|
||
|
[a-zA-Z0-9.~_-]) printf "$c" ;;
|
||
|
*) printf '%%%02X' "'$c" ;;
|
||
|
esac
|
||
|
done
|
||
|
}
|
||
|
|
||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||
|
if [ -z "$(pgrep lbrynet-daemon)" ]; then
|
||
|
echo "running lbrynet-daemon..."
|
||
|
$DIR/lbrynet-daemon 2>&1 >> "$HOME/.lbrynet/daemon.log" &
|
||
|
sleep 3 # let the daemon load before connecting
|
||
|
fi
|
||
|
|
||
|
ARG=${1:-}
|
||
|
|
||
|
if [ -z "$ARG" ]; then
|
||
|
URL=""
|
||
|
else
|
||
|
URL="view?name=$(urlencode "$(echo "$ARG" | cut -c 8-)")"
|
||
|
fi
|
||
|
|
||
|
/usr/bin/xdg-open "http://localhost:5279/$URL"
|