iw4p / torrentp

Python torrent downloader - Download from torrent with .torrent file or magnet link, with just 3 lines of python code.
Other
152 stars 29 forks source link

The torrents download really slowly! #24

Open zemendaniel opened 1 month ago

zemendaniel commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

Hi, is the problem still persist?

zemendaniel commented 1 month ago

Hi, thanks for the question, the issue has been resolved. I have left the solution in the comments.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Nima Akbarzadeh @.> Sent: Friday, July 12, 2024 4:28:47 PM To: iw4p/torrentp @.> Cc: Zemen Dániel @.>; Author @.> Subject: Re: [iw4p/torrentp] The torrents download really slowly! (Issue #24)

Hi, is the problem still persist?

— Reply to this email directly, view it on GitHubhttps://github.com/iw4p/torrentp/issues/24#issuecomment-2225705535, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6JFG37QMA2NIXL2EKSPSWLZL7RZ7AVCNFSM6AAAAABKXRYW2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRVG4YDKNJTGU. You are receiving this because you authored the thread.Message ID: @.***>

iw4p commented 1 month ago

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 commented 1 month ago

@iw4p My downloader function wasnt async.

zemendaniel commented 1 month ago

@iw4p sry for the late reply

iw4p commented 1 month ago

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

zemendaniel commented 1 month ago

Np mate, love the library btw

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Nima Akbarzadeh @.> Sent: Monday, July 15, 2024 12:53:47 PM To: iw4p/torrentp @.> Cc: Zemen Dániel @.>; Author @.> Subject: Re: [iw4p/torrentp] The torrents download really slowly! (Issue #24)

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

— Reply to this email directly, view it on GitHubhttps://github.com/iw4p/torrentp/issues/24#issuecomment-2228219841, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A6JFG32SC22YHQTR37Y25M3ZMOS3XAVCNFSM6AAAAABKXRYW2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRYGIYTSOBUGE. You are receiving this because you authored the thread.Message ID: @.***>