-
-
Save yauhenipakala/bb62eac43a63bcc49847665f59697306 to your computer and use it in GitHub Desktop.
Revisions
-
yauhenipakala revised this gist
Aug 1, 2023 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -31,10 +31,8 @@ https.get(apiUrlWithQuery, (res) => { '--tries=0', '--timeout=5', json_res.href, '-O', `${folder}${filename}`, ]; const childProcess = spawn(command, args); -
yauhenipakala revised this gist
Aug 1, 2023 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,9 @@ #!/usr/bin/env node // How to // wget http://gist.github.com/... // chmod +x ya.js // ./ya.js download_url path/to/directory const https = require('https'); const { URL } = require('url'); -
yauhenipakala revised this gist
Aug 1, 2023 . 2 changed files with 65 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ #!/usr/bin/env node # -*- coding: utf-8 -*- # How to # wget http://gist.github.com/... # chmod +x ya.js # ./ya.js download_url path/to/directory const https = require('https'); const { URL } = require('url'); const { spawn } = require('child_process'); const base_url = 'https://cloud-api.yandex.net:443/v1/disk/public/resources/download?public_key='; const apiUrl = process.argv[2]; const folder = process.argv[3] || '.'; const encodedUrl = encodeURIComponent(apiUrl); const apiUrlWithQuery = base_url + encodedUrl; https.get(apiUrlWithQuery, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { const json_res = JSON.parse(data); const filename = new URL(json_res.href).searchParams.get('filename'); const command = 'wget'; const args = [ '-c', '--retry-connrefused', '--tries=0', '--timeout=5', json_res.href, '-P', folder, '-O', filename, ]; const childProcess = spawn(command, args); childProcess.stdout.on('data', (data) => { console.log(data.toString()); }); childProcess.stderr.on('data', (data) => { console.error(data.toString()); }); childProcess.on('error', (err) => { console.error('Error:', err.message); }); childProcess.on('exit', (code) => { if (code === 0) { console.log('File downloaded successfully!'); } else { console.error(`Command execution failed with code ${code}`); } }); }); }).on('error', (err) => { console.error('Error:', err.message); }); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,22 +0,0 @@ -
wildcard revised this gist
Oct 1, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,5 +18,5 @@ res = os.popen('wget -qO - {}{}'.format(base_url, url)).read() json_res = json.loads(res) filename = ul.parse_qs(ul.urlparse(json_res['href']).query)['filename'][0] os.system("caffeinate -s wget -c --retry-connrefused --tries=0 --timeout=5 '{}' -P '{}' -O '{}'".format(json_res['href'], folder, filename)) # os.system("wget '{}'".format(json_res['href'])) -
wildcard revised this gist
Sep 29, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -18,5 +18,5 @@ res = os.popen('wget -qO - {}{}'.format(base_url, url)).read() json_res = json.loads(res) filename = ul.parse_qs(ul.urlparse(json_res['href']).query)['filename'][0] os.system("wget -c --retry-connrefused --tries=0 --timeout=5 '{}' -P '{}' -O '{}'".format(json_res['href'], folder, filename)) # os.system("wget '{}'".format(json_res['href'])) -
Yegorov created this gist
Jan 13, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # https://toster.ru/q/72866 # How to # wget http://gist.github.com/... # chmod +x ya.py # ./ya.py download_url path/to/directory import os, sys, json import urllib.parse as ul sys.argv.append('.') if len(sys.argv) == 2 else None base_url = 'https://cloud-api.yandex.net:443/v1/disk/public/resources/download?public_key=' url = ul.quote_plus(sys.argv[1]) folder = sys.argv[2] res = os.popen('wget -qO - {}{}'.format(base_url, url)).read() json_res = json.loads(res) filename = ul.parse_qs(ul.urlparse(json_res['href']).query)['filename'][0] os.system("wget '{}' -P '{}' -O '{}'".format(json_res['href'], folder, filename)) # os.system("wget '{}'".format(json_res['href']))