Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom configs #62

Merged
merged 4 commits into from Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -16,4 +16,4 @@ site/
demo.gif
.mypy_cache/
poetry.lock

*.sw[po]
13 changes: 8 additions & 5 deletions CREDITS.md
Expand Up @@ -42,7 +42,8 @@ These projects were used to build `aria2p`. **Thank you!**
[`requests`](https://requests.readthedocs.io) |
[`responses`](https://github.com/getsentry/responses) |
[`toml`](https://github.com/uiri/toml) |
[`websocket_client`](https://github.com/websocket-client/websocket-client.git)
[`websocket_client`](https://github.com/websocket-client/websocket-client.git) |
[`xdg`](https://github.com/srstevenson/xdg)

### Indirect dependencies
[`aiocontextvars`](https://github.com/fantix/aiocontextvars) |
Expand All @@ -55,14 +56,13 @@ These projects were used to build `aria2p`. **Thank you!**
[`attrs`](https://www.attrs.org/) |
[`backcall`](https://github.com/takluyver/backcall) |
[`beautifulsoup4`](http://www.crummy.com/software/BeautifulSoup/bs4/) |
[`certifi`](https://certifi.io/) |
[`certifi`](https://certifiio.readthedocs.io/en/latest/) |
[`chardet`](https://github.com/chardet/chardet) |
[`click`](https://palletsprojects.com/p/click/) |
[`colorama`](https://github.com/tartley/colorama) |
[`contextvars`](http://github.com/MagicStack/contextvars) |
[`decorator`](https://github.com/micheles/decorator) |
[`dis3`](https://github.com/KeyWeeUsr/python-dis3) |
[`entrypoints`](https://github.com/takluyver/entrypoints) |
[`execnet`](https://execnet.readthedocs.io/en/latest/) |
[`flake8-polyfill`](https://gitlab.com/pycqa/flake8-polyfill) |
[`future`](https://python-future.org) |
Expand All @@ -74,12 +74,14 @@ These projects were used to build `aria2p`. **Thank you!**
[`ipython-genutils`](http://ipython.org) |
[`jedi`](https://github.com/davidhalter/jedi) |
[`Jinja2`](https://palletsprojects.com/p/jinja/) |
[`joblib`](https://joblib.readthedocs.io) |
[`livereload`](https://github.com/lepture/python-livereload) |
[`lunr`](https://github.com/yeraydiazdiaz/lunr.py) |
[`Markdown`](https://Python-Markdown.github.io/) |
[`MarkupSafe`](https://palletsprojects.com/p/markupsafe/) |
[`mccabe`](https://github.com/pycqa/mccabe) |
[`more-itertools`](https://github.com/erikrose/more-itertools) |
[`mkdocs-material-extensions`](https://github.com/facelessuser/mkdocs-material-extensions) |
[`more-itertools`](https://github.com/more-itertools/more-itertools) |
[`mypy-extensions`](https://github.com/python/mypy_extensions) |
[`nltk`](http://nltk.org/) |
[`packaging`](https://github.com/pypa/packaging) |
Expand All @@ -92,7 +94,7 @@ These projects were used to build `aria2p`. **Thank you!**
[`pluggy`](https://github.com/pytest-dev/pluggy) |
[`prompt-toolkit`](https://github.com/prompt-toolkit/python-prompt-toolkit) |
[`ptyprocess`](https://github.com/pexpect/ptyprocess) |
[`py`](http://py.readthedocs.io/) |
[`py`](https://py.readthedocs.io/) |
[`pycodestyle`](https://pycodestyle.readthedocs.io/) |
[`pydocstyle`](https://github.com/PyCQA/pydocstyle/) |
[`pyfiglet`](https://github.com/pwaller/pyfiglet) |
Expand All @@ -114,6 +116,7 @@ These projects were used to build `aria2p`. **Thank you!**
[`termcolor`](http://pypi.python.org/pypi/termcolor) |
[`testfixtures`](https://github.com/Simplistix/testfixtures) |
[`tornado`](http://www.tornadoweb.org/) |
[`tqdm`](https://github.com/tqdm/tqdm) |
[`traitlets`](http://ipython.org) |
[`typed-ast`](https://github.com/python/typed_ast) |
[`typing-extensions`](https://github.com/python/typing/blob/master/typing_extensions/README.rst) |
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -24,6 +24,7 @@ requests = "*"
loguru = "*"
websocket_client = "*"
asciimatics = { version = "^1.11.0", optional = true }
xdg = "^4.0.1"

[tool.poetry.dev-dependencies]
bandit = "^1.5"
Expand Down
29 changes: 29 additions & 0 deletions src/aria2p/api.py
Expand Up @@ -328,6 +328,35 @@ def move_to_bottom(self, download: Download) -> int:
"""
return self.client.change_position(download.gid, 0, "POS_END")

def retry_downloads(self, downloads: List[Download], clean: bool = False) -> List[bool]:
"""
Resume failed downloads from where they left off with new GIDs.

Parameters:
downloads: the list of downloads to remove.
clean: whether to remove the aria2 control file as well.

pawamoy marked this conversation as resolved.
Show resolved Hide resolved
Returns:
Success or failure of the operation for each given download.
"""
result = []
for download in downloads:
if not download.has_failed:
continue
try:
uri = download.files[0].uris[0]["uri"]
new_download_gid = self.add_uris([uri], download.options)
if not new_download_gid:
continue

self.remove([download], clean)
result.append(True)

except ClientException as error:
result.append(error)

return result

def remove(
self, downloads: List[Download], force: bool = False, files: bool = False, clean: bool = True
) -> List[bool]:
Expand Down