Use `curl` if not running on OpenBSD

This commit is contained in:
Lucas 2020-11-01 18:51:45 +00:00
parent 6bbdb29b10
commit 8de76cf8b1
2 changed files with 28 additions and 2 deletions

View File

@ -23,6 +23,19 @@ err()
exit 1
}
fetch_file()
{
# Assumes utility supports `-o output_file`
case $(uname) in
OpenBSD)
$torsocks ftp -MV "$@"
;;
*)
$torsocks curl -fLSs "$@"
;;
esac
}
api()
{
printf "https://%s%s\n" "$INVIDIOUS" "$*"
@ -93,6 +106,6 @@ id=$(get_id "$url")
[ ${#id} -eq 11 ] || err "invalid video ID $id"
# XXX choose in some clever way
itag=$($torsocks ftp -MVo - "$(api "/api/v1/videos/$id")" |
itag=$(fetch_file -o - "$(api "/api/v1/videos/$id")" |
jq -r ".formatStreams[].itag" | head -n 1)
api "/latest_version?id=$id&itag=$itag"

View File

@ -22,6 +22,19 @@ err()
exit 1
}
fetch_file()
{
# Assumes utility supports `-o output_file`
case $(uname) in
OpenBSD)
$torsocks ftp -MV "$@"
;;
*)
$torsocks curl -fLSs "$@"
;;
esac
}
tonumber()
{
printf "%u" "$1" 2>/dev/null
@ -44,6 +57,6 @@ url=https://tools.ietf.org/rfc/rfc$n.txt
mkdir -p "$RFCDIR"
if [ ! -f "$rfcfile" ]; then
$torsocks ftp -Vo "$rfcfile" "$url" || err "couldn't fetch RFC $n"
fetch_file -o "$rfcfile" "$url" || err "couldn't fetch RFC $n"
fi
${PAGER:-more} "$rfcfile"