mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-07-27 22:04:15 +09:00
feat: create call_downloader function
This commit is contained in:
parent
c50ae4def9
commit
08da8657b7
@ -211,26 +211,38 @@ class Aria2pFD(ExternalFD):
|
|||||||
'''
|
'''
|
||||||
AVAILABLE_OPT = 'show'
|
AVAILABLE_OPT = 'show'
|
||||||
|
|
||||||
def _make_cmd(self, tmpfilename, info_dict):
|
def _call_downloader(self, tmpfilename, info_dict):
|
||||||
cmd = [self.exe]
|
import aria2p
|
||||||
|
aria2 = aria2p.API(
|
||||||
|
aria2p.Client(
|
||||||
|
host="http://localhost",
|
||||||
|
port=6800,
|
||||||
|
secret=""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
options = dict()
|
options = dict()
|
||||||
options["min-split-size"] = "1M"
|
options["min-split-size"] = "1M"
|
||||||
options["max-connection-per-server"] = 4
|
options["max-connection-per-server"] = 4
|
||||||
dn = os.path.dirname(tmpfilename)
|
dn = os.path.dirname(tmpfilename)
|
||||||
if dn:
|
if dn:
|
||||||
options["dir"] = dn
|
options["dir"] = dn
|
||||||
|
else:
|
||||||
|
options["dir"] = os.path.abspath('.')
|
||||||
options["out"] = os.path.basename(tmpfilename)
|
options["out"] = os.path.basename(tmpfilename)
|
||||||
options["header"] = []
|
options["header"] = []
|
||||||
for key, val in info_dict['http_headers'].items():
|
for key, val in info_dict['http_headers'].items():
|
||||||
options["header"].append(f"{key}: {val}")
|
options["header"].append(f"{key}: {val}")
|
||||||
options["hearder"] = str(options["header"])
|
|
||||||
# cmd += self._option('--interface', 'source_address')
|
# cmd += self._option('--interface', 'source_address')
|
||||||
# cmd += self._option('--all-proxy', 'proxy')
|
# cmd += self._option('--all-proxy', 'proxy')
|
||||||
# cmd += self._bool_option('--check-certificate', 'nocheckcertificate', 'false', 'true', '=')
|
# cmd += self._bool_option('--check-certificate', 'nocheckcertificate', 'false', 'true', '=')
|
||||||
# cmd += self._bool_option('--remote-time', 'updatetime', 'true', 'false', '=')
|
# cmd += self._bool_option('--remote-time', 'updatetime', 'true', 'false', '=')
|
||||||
|
# cmd += ["call", "adduri", "-J", "[[\"{}\"], {}]".format(info_dict['url'], str(options)).replace("'", '"')]
|
||||||
cmd += ['call', 'adduri', [info_dict['url'], str(options)]]
|
download = aria2.add_uris([info_dict['url']], options)
|
||||||
return cmd
|
while download.status == "active":
|
||||||
|
download = aria2.get_download(download.gid)
|
||||||
|
print(download.progress_string())
|
||||||
|
print(download.status)
|
||||||
|
|
||||||
|
|
||||||
class HttpieFD(ExternalFD):
|
class HttpieFD(ExternalFD):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user