Skip to content

Instantly share code, notes, and snippets.

@jadedgnome
Forked from s00d/dl-cloud-mail-ru.sh
Last active June 8, 2018 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jadedgnome/19274439e5011ff3939f09ea0f1060ab to your computer and use it in GitHub Desktop.
Save jadedgnome/19274439e5011ff3939f09ea0f1060ab to your computer and use it in GitHub Desktop.
Download file from cloud.mail.ru from linux console with bash script
#!/usr/bin/env bash
# idea: https://novall.net/itnews/bash-skript-dlya-skachivaniya-fajlov-s-mail-ru-cherez-konsol-linux.html
for link in "$@" ;
do URL="$link"
FILENAME=$(curl -A "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0" -s "$URL" | grep -E '"name":' | tac | head -1 | sed -e 's|.*"name":\ "||' -e 's|",.*||')
URLPART0=$(wget -U "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0" --quiet -O - "$URL" | grep -o '"weblink_get":\[[^]]\+\]' | sed 's/.*"url":"\([^"]\+\)".*/\1/')
URLPART1=$(echo "$URL" | awk -F '/public/' '{print $2}')
URLPART2=$(wget -U "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0" --quiet -O - "https://cloud.mail.ru/api/v2/tokens/download" | sed 's/.*"token":"\([^"]\+\)".*/\1/')
wget --no-check-certificate -U "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:56.0) Gecko/20100101 Firefox/56.0" --referer="$URL" "$URLPART0/$URLPART1/$FILENAME?key=$URLPART2" -O "$FILENAME"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment