How to use the aria2p.Download function in aria2p

To help you get started, we’ve selected a few aria2p examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pawamoy / aria2p / tests / test_downloads.py View on Github external
def setup_method(self):
        self.bitfield = (
            "9e7ef5fbdefdffffdfffffffffffffdf7fff5dfefff7feffefffdff7fffffffbfeffbffddf7de9f7eefffffffeffe77bb"
            "f8fdbdcffef7fffffbefad7ffffffbf55bff7edfedfeff7ffff7ffffff3ffff7d3ffbfffddddffe7ffffffffffdedf7fd"
            "fef62fbdfffffbffbffdcfaffffafebeff3ebff7d5fffbbb2bafef77ffaffe7d37fbffffffb6dfffffffedfebbecbbffe"
            "bdefffffffff977f7ffdffee7fffffffdfeb3f67dddffeedfffffbfffffdaffbfeedfadef6dfd9d2df9fb7f689ffcff3f"
            "fbfebbfdbd7fcddfa77dfddffdfe327fdcbf77fad87ffff6ff7ffebfefdfbbffdefdafeefed7fefffe7ffad9ffdcffefc"
            "ffbbf3c07ef7fc0"
        )
        self.download = Download(
            API(),
            {
                "bitfield": self.bitfield,
                "bittorrent": {},
                "completedLength": "889592532",
                "connections": "44",
                "dir": "/home/pawamoy/Downloads/torrents/tmp",
                "downloadSpeed": "745509",
                "files": [
                    {
                        "completedLength": "58132",
                        "index": "1",
                        "length": "58132",
                        "path": "/home/pawamoy/Downloads/torrents/tmp/dl/logo.jpg",
                        "selected": "true",
                        "uris": [],
github pawamoy / aria2p / tests / test_api.py View on Github external
def test_get_downloads_method():
    with Aria2Server(port=7105, session=SESSIONS_DIR / "dl-2-aria2.txt") as server:
        downloads = server.api.get_downloads()
        assert len(downloads) == 2
        assert isinstance(downloads[0], Download)
        assert downloads[0].gid == "2089b05ecca3d829"
github pawamoy / aria2p / src / aria2p / cli.py View on Github external
do_all (bool): pause all downloads if True.

    Returns:
        int: 0 if all success, 1 if one failure.
    """
    print(
        "Deprecation warning: command 'purge' is deprecated in favor of command 'remove', "
        "and will be removed in version 0.7.0.",
        file=sys.stderr,
    )
    if do_all:
        if api.purge_all():
            return 0
        return 1

    downloads = [Download(api, {"gid": gid}) for gid in gids]
    result = api.purge(downloads)
    if all(result):
        return 0
    for item in result:
        if isinstance(item, ClientException):
            print(item, file=sys.stderr)
    return 1
github pawamoy / aria2p / src / aria2p / cli.py View on Github external
api (API): the API instance to use.
        gids (list of str): the GIDs of the downloads to pause.
        do_all (bool): pause all downloads if True.
        force (bool): force pause or not (see API.pause).

    Returns:
        int: 0 if all success, 1 if one failure.
    """
    if do_all:
        if api.pause_all(force=force):
            return 0
        return 1

    # FIXME: could break if API.resume needs more info than just gid
    # See how we do that in subcommand_remove
    downloads = [Download(api, {"gid": gid}) for gid in gids]
    result = api.pause(downloads, force=force)
    if all(result):
        return 0
    for item in result:
        if isinstance(item, ClientException):
            print(item, file=sys.stderr)
    return 1
github pawamoy / aria2p / src / aria2p / cli.py View on Github external
Args:
        api (API): the API instance to use.
        gids (list of str): the GIDs of the downloads to resume.
        do_all (bool): pause all downloads if True.

    Returns:
        int: 0 if all success, 1 if one failure.
    """
    if do_all:
        if api.resume_all():
            return 0
        return 1

    # FIXME: could break if API.resume needs more info than just gid
    # See how we do that in subcommand_remove
    downloads = [Download(api, {"gid": gid}) for gid in gids]
    result = api.resume(downloads)
    if all(result):
        return 0
    for item in result:
        if isinstance(item, ClientException):
            print(item, file=sys.stderr)
    return 1