Skip to content

Instantly share code, notes, and snippets.

@image72
Created October 19, 2023 02:31
Show Gist options
  • Save image72/ec7a0b546bf27b895cc8f46d8956331b to your computer and use it in GitHub Desktop.
Save image72/ec7a0b546bf27b895cc8f46d8956331b to your computer and use it in GitHub Desktop.
aria2 downloads
const link = window.prompt("Enter URL");
fetch("http://127.0.0.1:6800/jsonrpc", {
method: "POST",
headers: {
"content-type": "application/x-www-form-urlencoded"
},
body: JSON.stringify({
jsonrpc: "2.0",
id: "someID",
method: "aria2.addUri",
params: [
"token:TOKEN_STRING",
[link],
{ out: link.split("/").pop() }
]
})
});
function dl2() {
link=$1
# get params[0].out filename by link
filename=$(basename -- "$link")
extension="${filename##*.}"
filename="${filename%.*}"
out_filename="$filename.out.$extension"
curl -X POST -H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": "someID",
"method": "aria2.addUri",
"params": [
"token:TOKEN_STRING",
["'$link'"],
{ "out": "'$out_filename'" }
]
}' http://127.0.0.1:6800/jsonrpc
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment