-
-
Save s00d/2ae4eb5466bbb4edf92cf05c1aac711b to your computer and use it in GitHub Desktop.
Download file from cloud.mail.ru from linux console with bash script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# idea: https://novall.net/itnews/bash-skript-dlya-skachivaniya-fajlov-s-mail-ru-cherez-konsol-linux.html | |
URL="$1" | |
FILENAME="$2" | |
[ -z "$FILENAME" ] && { | |
echo "Syntax: `basename $0` <url> <dst_path>" >&2 | |
exit 1 | |
} | |
URLPART0=$(wget --quiet -O - $URL | grep -o '"weblink_get":\[[^]]\+\]' | sed 's/.*"url":"\([^"]\+\)".*/\1/') | |
URLPART1=$(echo $URL | awk -F '/public/' '{print $2}') | |
URLPART2=$(wget --quiet -O - "https://cloud.mail.ru/api/v2/tokens/download" | sed 's/.*"token":"\([^"]\+\)".*/\1/') | |
wget --no-check-certificate --referer=$URL "$URLPART0/$URLPART1/$FILENAME?key=$URLPART2" -O $FILENAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment