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

The torrents download really slowly! #24

Open
zemendaniel opened this issue Jul 11, 2024 · 8 comments
Open

The torrents download really slowly! #24

zemendaniel opened this issue Jul 11, 2024 · 8 comments

Comments

@zemendaniel
Copy link

Hi, my problem is that the torrents download very slowly (a few kilobytes/s despite having a gigabit internet). I'm running ubuntu server btw. The command line version works perfectly tho, please help.

import subprocess
from torrentp import TorrentDownloader
import os
import argparse
import asyncio
from dotenv import load_dotenv
load_dotenv()


def downloader(info_hash):
    torrent_file = TorrentDownloader(f"magnet:?xt=urn:btih:{info_hash}", os.environ['SAVE_PATH'])
    asyncio.run(torrent_file.start_download())


if  __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--hash", required=True, type=str)
    args = parser.parse_args()

    downloader(args.hash)
@zemendaniel
Copy link
Author

Okay, I'm dumb. Here is the solution:
`import argparse
import asyncio
from torrentp import TorrentDownloader

parser = argparse.ArgumentParser()
parser.add_argument("--hash", required=True, type=str)
args = parser.parse_args()

torrent_file = TorrentDownloader(f"magnet:?xt=urn:btih:{args.hash}", '.')
asyncio.run(torrent_file.start_download())
`

@iw4p
Copy link
Owner

iw4p commented Jul 12, 2024

Hi, is the problem still persist?

@zemendaniel
Copy link
Author

zemendaniel commented Jul 12, 2024 via email

@iw4p
Copy link
Owner

iw4p commented Jul 12, 2024

Good but I can not see the diff between two codes for impacting on the speed. Can you explain a little bit more how the second code has better speed for downloading torrent files?

@zemendaniel
Copy link
Author

@iw4p My downloader function wasnt async.

@zemendaniel
Copy link
Author

@iw4p sry for the late reply

@iw4p
Copy link
Owner

iw4p commented Jul 15, 2024

Oh I see, I didn't realize that for the first time.

@zemendaniel
Copy link
Author

zemendaniel commented Jul 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants