31 lines
975 B
Fish
31 lines
975 B
Fish
function mega-dl --argument-names link
|
|
set server "t-800"
|
|
|
|
if test -z $link
|
|
echo "No arguments provided!"
|
|
return
|
|
end
|
|
|
|
# rotate vpn proxy exit node to get new ip
|
|
echo "Requesting new public ip to VPN provider"
|
|
curl -s -X PUT $server:8000/v1/vpn/status --json '{"status": "stopped"}' > /dev/null
|
|
curl -s -X PUT $server:8000/v1/vpn/status --json '{"status": "running"}' > /dev/null
|
|
|
|
while true
|
|
set -l response (curl -s $server:8000/v1/publicip/ip)
|
|
set -l public_ip (echo $response | jq -r ".public_ip")
|
|
set -l country (echo $response | jq -r ".country")
|
|
set -l city (echo $response | jq -r ".city")
|
|
|
|
# wait for the connection to be stablished
|
|
if test -z $public_ip
|
|
sleep 0.2
|
|
else
|
|
echo -e "New IP is $public_ip from $country/$city\n"
|
|
break
|
|
end
|
|
end
|
|
|
|
# use vpn as proxy
|
|
megatools dl --proxy http://$server:8888 $link
|
|
end
|