minor updates
This commit is contained in:
parent
876fd4faf4
commit
8e8e637dbe
3 changed files with 52 additions and 4 deletions
31
configs/fish/functions/mega-dl.fish
Normal file
31
configs/fish/functions/mega-dl.fish
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue