update gdrivedl()

This commit is contained in:
Tomasz Kapias 2023-03-19 16:14:04 +07:00
parent 6a15c81069
commit 7694d6bd6f
Signed by: tkapias
SSH key fingerprint: SHA256:bsmasrX7y0xxAHa/x1x8zAgHInO4nPpKMk5JIQ0Vsbw

View file

@ -617,10 +617,16 @@ gdrivedl() {
local _ID=$1
local _FILENAME=$2
if [[ -z "$XDG_DOWNLOAD_DIR" ]]; then
mkdir $HOME/Downloads
local _XDG_DOWNLOAD_DIR="$HOME/Downloads"
else
local _XDG_DOWNLOAD_DIR="$XDG_DOWNLOAD_DIR"
fi
wget --prefer-family=IPv4 --force-directories --no-check-certificate --no-hsts --continue --load-cookies "/tmp/gdrive-cookies-${_ID}.txt" \
"https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/gdrive-cookies-${_ID}.txt \
--keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=${_ID}' -O- | \
sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=${_ID}" -O "${XDG_DOWNLOAD_DIR}/$_FILENAME" \
sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=${_ID}" -O "${_XDG_DOWNLOAD_DIR}/$_FILENAME" \
&& rm -rf "/tmp/gdrive-cookies-${_ID}.txt"
}