Created
October 24, 2021 22:48
-
-
Save devster31/1c601a14b9d4ea710a09073c5ae8feb0 to your computer and use it in GitHub Desktop.
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 characters
import glob | |
import pathlib | |
from doit.tools import LongRunning | |
DOIT_CONFIG = {"action_string_formatting": "new"} | |
def aria_files(): | |
globs = glob.glob("*.aria2.txt") + glob.glob("*.session") | |
files = [] | |
for g in globs: | |
p = pathlib.Path(g) | |
if p.suffix == ".txt" and p.with_suffix(".session").name in globs: | |
to_add = p.with_suffix(".session").name | |
globs.remove(to_add) | |
files.append(to_add) | |
else: | |
files.append(p.name) | |
return files | |
def cmd_string(_file): | |
f = pathlib.Path(_file) | |
return ( | |
f"aria2c --input-file {_file} " | |
"--load-cookies cookies.txt " | |
'--on-download-complete "$(pwd)"/hook.sh ' | |
"--optimize-concurrent-downloads true " | |
"--show-console-readout false " | |
"--conditional-get true" | |
) + ( | |
f" --save-session {f.with_suffix('.session').name}" | |
if f.suffix == ".txt" | |
else "" | |
) | |
def task_download(): | |
files = aria_files() | |
yield { | |
"basename": "download", | |
"name": None, | |
"doc": "downloads input-files with aria2", | |
} | |
for f in files: | |
cmd = cmd_string(f) | |
yield { | |
"name": f, | |
"actions": [LongRunning(cmd)], | |
"verbosity": 2, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment