Re: [libtorrent] Complete control in torrent download
Brought to you by:
arvidn
|
From: Faheem M. <fah...@gm...> - 2017-02-24 06:14:49
|
Does libtorrent support pausing and resuming??
On Thu, Feb 23, 2017, 10:38 PM Ronald Degmar <ron...@gm...>
wrote:
> No, I'm not doing that.
> I was helping, not working.
>
> 2017-02-23 11:21 GMT-05:00 Faheem Mohammed <fah...@gm...>:
>
> > I am not so good in python... Can you please elaborate the answer...
> > What about pausing,resuming and queuing..
> > Regards
> >
> > On Wed, Feb 22, 2017 at 11:12 PM, Ronald Degmar <ron...@gm...
> >
> > wrote:
> >
> > > Hello,
> > >
> > > For multiple torrent downloads, you don't need multiprocessing.
> > > I implemented also threads but just a single query is more efficient.
> > like
> > > the following:
> > >
> > >
> > > *while (any(not hand.is_seed() for hand in handles)):*
> > > * ...*
> > > * for h in handles:*
> > > * s = h.status()*
> > > * ...*
> > >
> > > Ronald Barrios
> > >
> > > 2017-02-22 8:16 GMT-05:00 Faheem Mohammed <fah...@gm...
> >:
> > >
> > > > I am trying to build a small torrent downloading python application
> > with
> > > > libtorrent. Until now I have received some codes which downloads the
> > > > torrent and displays progress details. I would like to add features
> > like
> > > > 'pausing, 'resuming', 'deleting', 'queuing' and 'multiple downloads'.
> > > > I tried some, but not so familiar with python programming. Current
> code
> > > is
> > > > as follows,
> > > >
> > > > import libtorrent as lt
> > > > import time
> > > > import sys
> > > > def get_libtorrent_session_and_start_dht(start_port, end_port):
> > > > ses = lt.session()
> > > > ses.listen_on(start_port, end_port)
> > > > ses.add_dht_router('dht.transmissionbt.com', start_port)
> > > > ses.add_dht_router('router.bittorrent.com', start_port)
> > > > ses.add_dht_router('router.utorrent.com', start_port)
> > > > ses.start_dht()
> > > > return ses
> > > > #p.terminate()
> > > > const_state_str = ['queued', 'checking', 'downloading metadata', \
> > > > 'downloading', 'finished', 'seeding',
> 'allocating',
> > > > 'checking fastresume']
> > > > const_pause_torrent = "pause_torrent"
> > > > const_resume_torrent = "resume_torrent"
> > > > const_kill_torrent = "kill_torrent"
> > > > const_user_logged_in = "user_logged_in"
> > > > const_user_logged_out = "user_logged_out"
> > > > const_quit_seeding = "quit_seeding"
> > > >
> > > > ses = get_libtorrent_session_and_start_dht(6881, 6891)
> > > > torrent_info = None
> > > > torrent_handle = None
> > > > params = {
> > > > 'save_path': '/home/faheem/Downloads/',
> > > > 'storage_mode': lt.storage_mode_t(2)
> > > > }
> > > > link = "magneturl"
> > > > try:
> > > > #torrent_info = lt.torrent_info("/home/faheem/
> > > Downloads/abcd.torrent")
> > > > torrent_handle = lt.add_magnet_uri(ses,link,params)
> > > > # ses.add_torrent({'ti': torrent_info, 'save_path':
> > > > "/home/faheem/"})
> > > > except Exception as exception:
> > > > raise exception
> > > > print "Getting meta data"
> > > > while not torrent_handle.has_metadata():
> > > > time.sleep(1)
> > > > print 'got metadata, starting torrent download...'
> > > >
> > > > current_iteration = 0
> > > > while not torrent_handle.is_seed():
> > > > torrent_status = torrent_handle.status()
> > > >
> > > > print "current_iteration: " + str(current_iteration)
> > > >
> > > > if current_iteration == 10:
> > > > print "Calling torrent_handle.pause()...Pausing Torrent"
> > > > sys.stdout.flush()
> > > > torrent_handle.pause()
> > > > while not torrent_handle.status().paused:
> > > > print "Torrent Is Not Paused Yet"
> > > > time.sleep(1)
> > > > sys.stdout.flush()
> > > > while torrent_handle.status().paused:
> > > > print "Torrent Is Paused!"
> > > > torrent_handle.pause()
> > > > time.sleep(20)
> > > > sys.stdout.flush()
> > > >
> > > > if const_state_str[torrent_status.state] == "checking":
> > > > print 'Checking Torrent....'
> > > > continue
> > > >
> > > > print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers:
> %d)
> > > %s'
> > > > % \
> > > > (torrent_status.progress * 100,
> torrent_status.download_rate
> > > > / 1000, torrent_status.upload_rate / 1000, \
> > > > torrent_status.num_peers, const_state_str[torrent_
> > > status.state]),
> > > > \
> > > > sys.stdout.flush()
> > > >
> > > > current_iteration += 1
> > > >
> > > > if torrent_status.paused:
> > > > print "Is Paused"
> > > > else:
> > > > print "Is Not Paused"
> > > >
> > > > time.sleep(1)
> > > >
> > > >
> > > > Here there at iteration 10, it has to pause but not working.
> > > >
> > > > Please look through the code and produce a detailed code for enabling
> > > > pausing, resuming, queuing and multiple downloads.
> > > >
> > > > I am beginner in python so kindly produce codes for the above
> > > requirements.
> > > >
> > > > I think multiprocessing is needed for multiple downloads. Please
> check
> > it
> > > >
> > > > It is URGENT..
> > > >
> > > > REGARDS
> > > > ------------------------------------------------------------
> > > > ------------------
> > > > Check out the vibrant tech community on one of the world's most
> > > > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > > > _______________________________________________
> > > > Libtorrent-discuss mailing list
> > > > Lib...@li...
> > > > https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
> > > >
> > > ------------------------------------------------------------
> > > ------------------
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > > _______________________________________________
> > > Libtorrent-discuss mailing list
> > > Lib...@li...
> > > https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
> > >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Libtorrent-discuss mailing list
> > Lib...@li...
> > https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
> >
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Libtorrent-discuss mailing list
> Lib...@li...
> https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
>
|