Discussion:
[libtorrent] Complete control in torrent download
Faheem Mohammed
2017-02-22 13:16:16 UTC
Permalink
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
Ronald Degmar
2017-02-22 17:42:47 UTC
Permalink
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
Post by Faheem Mohammed
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
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"
#torrent_info = lt.torrent_info("/home/faheem/Downloads/abcd.torrent")
torrent_handle = lt.add_magnet_uri(ses,link,params)
"/home/faheem/"})
raise exception
print "Getting meta data"
time.sleep(1)
print 'got metadata, starting torrent download...'
current_iteration = 0
torrent_status = torrent_handle.status()
print "current_iteration: " + str(current_iteration)
print "Calling torrent_handle.pause()...Pausing Torrent"
sys.stdout.flush()
torrent_handle.pause()
print "Torrent Is Not Paused Yet"
time.sleep(1)
sys.stdout.flush()
print "Torrent Is Paused!"
torrent_handle.pause()
time.sleep(20)
sys.stdout.flush()
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
print "Is Paused"
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Faheem Mohammed
2017-02-23 16:21:07 UTC
Permalink
I am not so good in python... Can you please elaborate the answer...
What about pausing,resuming and queuing..
Regards
Post by Ronald Degmar
Hello,
For multiple torrent downloads, you don't need multiprocessing.
I implemented also threads but just a single query is more efficient. like
*while (any(not hand.is_seed() for hand in handles)):*
* ...*
* for h in handles:*
* s = h.status()*
* ...*
Ronald Barrios
Post by Faheem Mohammed
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
Post by Faheem Mohammed
as follows,
import libtorrent as lt
import time
import sys
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"
#torrent_info = lt.torrent_info("/home/faheem/
Downloads/abcd.torrent")
Post by Faheem Mohammed
torrent_handle = lt.add_magnet_uri(ses,link,params)
"/home/faheem/"})
raise exception
print "Getting meta data"
time.sleep(1)
print 'got metadata, starting torrent download...'
current_iteration = 0
torrent_status = torrent_handle.status()
print "current_iteration: " + str(current_iteration)
print "Calling torrent_handle.pause()...Pausing Torrent"
sys.stdout.flush()
torrent_handle.pause()
print "Torrent Is Not Paused Yet"
time.sleep(1)
sys.stdout.flush()
print "Torrent Is Paused!"
torrent_handle.pause()
time.sleep(20)
sys.stdout.flush()
print 'Checking Torrent....'
continue
print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d)
%s'
Post by Faheem Mohammed
% \
(torrent_status.progress * 100, torrent_status.download_rate
/ 1000, torrent_status.upload_rate / 1000, \
torrent_status.num_peers, const_state_str[torrent_
status.state]),
Post by Faheem Mohammed
\
sys.stdout.flush()
current_iteration += 1
print "Is Paused"
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.
Post by Faheem Mohammed
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Ronald Degmar
2017-02-23 17:07:43 UTC
Permalink
No, I'm not doing that.
I was helping, not working.
Post by Faheem Mohammed
I am not so good in python... Can you please elaborate the answer...
What about pausing,resuming and queuing..
Regards
Post by Ronald Degmar
Hello,
For multiple torrent downloads, you don't need multiprocessing.
I implemented also threads but just a single query is more efficient.
like
Post by Ronald Degmar
*while (any(not hand.is_seed() for hand in handles)):*
* ...*
* for h in handles:*
* s = h.status()*
* ...*
Ronald Barrios
Post by Faheem Mohammed
I am trying to build a small torrent downloading python application
with
Post by Ronald Degmar
Post by Faheem Mohammed
libtorrent. Until now I have received some codes which downloads the
torrent and displays progress details. I would like to add features
like
Post by Ronald Degmar
Post by Faheem Mohammed
'pausing, 'resuming', 'deleting', 'queuing' and 'multiple downloads'.
I tried some, but not so familiar with python programming. Current code
is
Post by Faheem Mohammed
as follows,
import libtorrent as lt
import time
import sys
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"
#torrent_info = lt.torrent_info("/home/faheem/
Downloads/abcd.torrent")
Post by Faheem Mohammed
torrent_handle = lt.add_magnet_uri(ses,link,params)
"/home/faheem/"})
raise exception
print "Getting meta data"
time.sleep(1)
print 'got metadata, starting torrent download...'
current_iteration = 0
torrent_status = torrent_handle.status()
print "current_iteration: " + str(current_iteration)
print "Calling torrent_handle.pause()...Pausing Torrent"
sys.stdout.flush()
torrent_handle.pause()
print "Torrent Is Not Paused Yet"
time.sleep(1)
sys.stdout.flush()
print "Torrent Is Paused!"
torrent_handle.pause()
time.sleep(20)
sys.stdout.flush()
print 'Checking Torrent....'
continue
print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d)
%s'
Post by Faheem Mohammed
% \
(torrent_status.progress * 100, torrent_status.download_rate
/ 1000, torrent_status.upload_rate / 1000, \
torrent_status.num_peers, const_state_str[torrent_
status.state]),
Post by Faheem Mohammed
\
sys.stdout.flush()
current_iteration += 1
print "Is Paused"
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.
Post by Faheem Mohammed
I think multiprocessing is needed for multiple downloads. Please check
it
Post by Ronald Degmar
Post by Faheem Mohammed
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
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Faheem Mohammed
2017-02-24 06:14:31 UTC
Permalink
Does libtorrent support pausing and resuming??
Post by Ronald Degmar
No, I'm not doing that.
I was helping, not working.
Post by Faheem Mohammed
I am not so good in python... Can you please elaborate the answer...
What about pausing,resuming and queuing..
Regards
Post by Ronald Degmar
Hello,
For multiple torrent downloads, you don't need multiprocessing.
I implemented also threads but just a single query is more efficient.
like
Post by Ronald Degmar
*while (any(not hand.is_seed() for hand in handles)):*
* ...*
* for h in handles:*
* s = h.status()*
* ...*
Ronald Barrios
Post by Faheem Mohammed
I am trying to build a small torrent downloading python application
with
Post by Ronald Degmar
Post by Faheem Mohammed
libtorrent. Until now I have received some codes which downloads the
torrent and displays progress details. I would like to add features
like
Post by Ronald Degmar
Post by Faheem Mohammed
'pausing, 'resuming', 'deleting', 'queuing' and 'multiple downloads'.
I tried some, but not so familiar with python programming. Current
code
Post by Faheem Mohammed
Post by Ronald Degmar
is
Post by Faheem Mohammed
as follows,
import libtorrent as lt
import time
import sys
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',
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
'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"
#torrent_info = lt.torrent_info("/home/faheem/
Downloads/abcd.torrent")
Post by Faheem Mohammed
torrent_handle = lt.add_magnet_uri(ses,link,params)
# ses.add_torrent({'ti': torrent_info, 'save_path': "/home/faheem/"})
raise exception
print "Getting meta data"
time.sleep(1)
print 'got metadata, starting torrent download...'
current_iteration = 0
torrent_status = torrent_handle.status()
print "current_iteration: " + str(current_iteration)
print "Calling torrent_handle.pause()...Pausing Torrent"
sys.stdout.flush()
torrent_handle.pause()
print "Torrent Is Not Paused Yet"
time.sleep(1)
sys.stdout.flush()
print "Torrent Is Paused!"
torrent_handle.pause()
time.sleep(20)
sys.stdout.flush()
print 'Checking Torrent....'
continue
%d)
Post by Faheem Mohammed
Post by Ronald Degmar
%s'
Post by Faheem Mohammed
% \
(torrent_status.progress * 100,
torrent_status.download_rate
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
/ 1000, torrent_status.upload_rate / 1000, \
torrent_status.num_peers, const_state_str[torrent_
status.state]),
Post by Faheem Mohammed
\
sys.stdout.flush()
current_iteration += 1
print "Is Paused"
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.
Post by Faheem Mohammed
I think multiprocessing is needed for multiple downloads. Please
check
Post by Faheem Mohammed
it
Post by Ronald Degmar
Post by Faheem Mohammed
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
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
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
sledgehammer999
2017-02-24 08:19:23 UTC
Permalink
Yes. Libtorrent it does. Each torrent_handle has a pause() and resume()
method. Also the session has that too and affects all torrents.
I suggest you start reading the docs first:
http://libtorrent.org/reference.html
Also a small tutorial: http://libtorrent.org/tutorial.html

Yes, they are in c++ but I think you can understand the logic and transfer
it to python.
Post by Faheem Mohammed
Does libtorrent support pausing and resuming??
Post by Ronald Degmar
No, I'm not doing that.
I was helping, not working.
Post by Faheem Mohammed
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 <
Post by Ronald Degmar
Hello,
For multiple torrent downloads, you don't need multiprocessing.
I implemented also threads but just a single query is more efficient.
like
Post by Ronald Degmar
*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 <
Post by Faheem Mohammed
I am trying to build a small torrent downloading python application
with
Post by Ronald Degmar
Post by Faheem Mohammed
libtorrent. Until now I have received some codes which downloads
the
Post by Ronald Degmar
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
torrent and displays progress details. I would like to add features
like
Post by Ronald Degmar
Post by Faheem Mohammed
'pausing, 'resuming', 'deleting', 'queuing' and 'multiple
downloads'.
Post by Ronald Degmar
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
I tried some, but not so familiar with python programming. Current
code
Post by Faheem Mohammed
Post by Ronald Degmar
is
Post by Faheem Mohammed
as follows,
import libtorrent as lt
import time
import sys
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',
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
'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"
#torrent_info = lt.torrent_info("/home/faheem/
Downloads/abcd.torrent")
Post by Faheem Mohammed
torrent_handle = lt.add_magnet_uri(ses,link,params)
"/home/faheem/"})
raise exception
print "Getting meta data"
time.sleep(1)
print 'got metadata, starting torrent download...'
current_iteration = 0
torrent_status = torrent_handle.status()
print "current_iteration: " + str(current_iteration)
print "Calling torrent_handle.pause()...Pausing Torrent"
sys.stdout.flush()
torrent_handle.pause()
print "Torrent Is Not Paused Yet"
time.sleep(1)
sys.stdout.flush()
print "Torrent Is Paused!"
torrent_handle.pause()
time.sleep(20)
sys.stdout.flush()
print 'Checking Torrent....'
continue
%d)
Post by Faheem Mohammed
Post by Ronald Degmar
%s'
Post by Faheem Mohammed
% \
(torrent_status.progress * 100,
torrent_status.download_rate
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
/ 1000, torrent_status.upload_rate / 1000, \
torrent_status.num_peers, const_state_str[torrent_
status.state]),
Post by Faheem Mohammed
\
sys.stdout.flush()
current_iteration += 1
print "Is Paused"
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
Post by Ronald Degmar
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
pausing, resuming, queuing and multiple downloads.
I am beginner in python so kindly produce codes for the above
requirements.
Post by Faheem Mohammed
I think multiprocessing is needed for multiple downloads. Please
check
Post by Faheem Mohammed
it
Post by Ronald Degmar
Post by Faheem Mohammed
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
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
------------------------------------------------------------
------------------
Post by Ronald Degmar
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Faheem Mohammed
2017-02-24 15:28:00 UTC
Permalink
Someone, please give me the code for pausing and resuming in python...

On Fri, Feb 24, 2017 at 1:49 PM, sledgehammer999 <
Post by sledgehammer999
Yes. Libtorrent it does. Each torrent_handle has a pause() and resume()
method. Also the session has that too and affects all torrents.
http://libtorrent.org/reference.html
Also a small tutorial: http://libtorrent.org/tutorial.html
Yes, they are in c++ but I think you can understand the logic and transfer
it to python.
Post by Faheem Mohammed
Does libtorrent support pausing and resuming??
Post by Ronald Degmar
No, I'm not doing that.
I was helping, not working.
2017-02-23 11:21 GMT-05:00 Faheem Mohammed <
Post by Faheem Mohammed
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 <
Post by Ronald Degmar
Hello,
For multiple torrent downloads, you don't need multiprocessing.
I implemented also threads but just a single query is more
efficient.
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
like
Post by Ronald Degmar
*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 <
Post by Faheem Mohammed
I am trying to build a small torrent downloading python
application
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
with
Post by Ronald Degmar
Post by Faheem Mohammed
libtorrent. Until now I have received some codes which downloads
the
Post by Ronald Degmar
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
torrent and displays progress details. I would like to add
features
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
like
Post by Ronald Degmar
Post by Faheem Mohammed
'pausing, 'resuming', 'deleting', 'queuing' and 'multiple
downloads'.
Post by Ronald Degmar
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
I tried some, but not so familiar with python programming.
Current
Post by Faheem Mohammed
Post by Ronald Degmar
code
Post by Faheem Mohammed
Post by Ronald Degmar
is
Post by Faheem Mohammed
as follows,
import libtorrent as lt
import time
import sys
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',
\
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
'downloading', 'finished', 'seeding',
'allocating',
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
'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"
#torrent_info = lt.torrent_info("/home/faheem/
Downloads/abcd.torrent")
Post by Faheem Mohammed
torrent_handle = lt.add_magnet_uri(ses,link,params)
"/home/faheem/"})
raise exception
print "Getting meta data"
time.sleep(1)
print 'got metadata, starting torrent download...'
current_iteration = 0
torrent_status = torrent_handle.status()
print "current_iteration: " + str(current_iteration)
print "Calling torrent_handle.pause()...Pausing Torrent"
sys.stdout.flush()
torrent_handle.pause()
print "Torrent Is Not Paused Yet"
time.sleep(1)
sys.stdout.flush()
print "Torrent Is Paused!"
torrent_handle.pause()
time.sleep(20)
sys.stdout.flush()
print 'Checking Torrent....'
continue
print '\r%.2f%% complete (down: %.1f kb/s up: %.1f kB/s
%d)
Post by Faheem Mohammed
Post by Ronald Degmar
%s'
Post by Faheem Mohammed
% \
(torrent_status.progress * 100,
torrent_status.download_rate
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
/ 1000, torrent_status.upload_rate / 1000, \
torrent_status.num_peers, const_state_str[torrent_
status.state]),
Post by Faheem Mohammed
\
sys.stdout.flush()
current_iteration += 1
print "Is Paused"
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
Post by Ronald Degmar
Post by Faheem Mohammed
Post by Ronald Degmar
Post by Faheem Mohammed
pausing, resuming, queuing and multiple downloads.
I am beginner in python so kindly produce codes for the above
requirements.
Post by Faheem Mohammed
I think multiprocessing is needed for multiple downloads. Please
check
Post by Faheem Mohammed
it
Post by Ronald Degmar
Post by Faheem Mohammed
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
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
------------------------------------------------------------
------------------
Post by Ronald Degmar
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
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Arvid Norberg
2017-02-24 16:28:22 UTC
Permalink
On Fri, Feb 24, 2017 at 10:28 AM, Faheem Mohammed <
Post by Faheem Mohammed
Someone, please give me the code for pausing and resuming in python...
This is not the right forum for asking how to program in python.
--
Arvid Norberg
Faheem Mohammed
2017-02-24 16:41:52 UTC
Permalink
I just want the libtorrent code for pausing in python... I think this can
be asked here...
Regards
Post by Arvid Norberg
On Fri, Feb 24, 2017 at 10:28 AM, Faheem Mohammed <
Post by Faheem Mohammed
Someone, please give me the code for pausing and resuming in python...
This is not the right forum for asking how to program in python.
--
Arvid Norberg
------------------------------------------------------------
------------------
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Arvid Norberg
2017-02-24 16:47:05 UTC
Permalink
On Fri, Feb 24, 2017 at 11:41 AM, Faheem Mohammed <
Post by Faheem Mohammed
I just want the libtorrent code for pausing in python... I think this can
be asked here...
http://libtorrent.org/reference-Core.html#pause-resume
--
Arvid Norberg
Faheem Mohammed
2017-02-24 17:03:19 UTC
Permalink
Please just give me an idea of how to use it in python... I cannot get it...
Sorry for disturbing...
Regards
Post by Arvid Norberg
On Fri, Feb 24, 2017 at 11:41 AM, Faheem Mohammed <
Post by Faheem Mohammed
I just want the libtorrent code for pausing in python... I think this can
be asked here...
http://libtorrent.org/reference-Core.html#pause-resume
--
Arvid Norberg
------------------------------------------------------------
------------------
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Arvid Norberg
2017-02-24 17:23:25 UTC
Permalink
On Fri, Feb 24, 2017 at 12:03 PM, Faheem Mohammed <
Post by Faheem Mohammed
Please just give me an idea of how to use it in python... I cannot get it...
assuming that "h" is an object of type torrent_handle, call:

h.pause()

or

h.resume()
Post by Faheem Mohammed
Sorry for disturbing...
Regards
Post by Arvid Norberg
On Fri, Feb 24, 2017 at 11:41 AM, Faheem Mohammed <
Post by Faheem Mohammed
I just want the libtorrent code for pausing in python... I think this
can
Post by Arvid Norberg
Post by Faheem Mohammed
be asked here...
http://libtorrent.org/reference-Core.html#pause-resume
--
Arvid Norberg
------------------------------------------------------------
------------------
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
--
Arvid Norberg
Faheem Mohammed
2017-02-24 17:46:12 UTC
Permalink
*Current code I am working on is as follows. At iteration 10 it has to
pause. I used the code 'torrent_handle.pause()' but not pausing.*



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 = "magnet url"
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 == 5:
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)
Post by Arvid Norberg
On Fri, Feb 24, 2017 at 12:03 PM, Faheem Mohammed <
Post by Faheem Mohammed
Please just give me an idea of how to use it in python... I cannot get it...
h.pause()
or
h.resume()
Post by Faheem Mohammed
Sorry for disturbing...
Regards
Post by Arvid Norberg
On Fri, Feb 24, 2017 at 11:41 AM, Faheem Mohammed <
Post by Faheem Mohammed
I just want the libtorrent code for pausing in python... I think this
can
Post by Arvid Norberg
Post by Faheem Mohammed
be asked here...
http://libtorrent.org/reference-Core.html#pause-resume
--
Arvid Norberg
------------------------------------------------------------
------------------
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
--
Arvid Norberg
------------------------------------------------------------
------------------
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Arvid Norberg
2017-02-24 18:13:08 UTC
Permalink
On Fri, Feb 24, 2017 at 12:46 PM, Faheem Mohammed <
Post by Faheem Mohammed
*Current code I am working on is as follows. At iteration 10 it has to
pause. I used the code 'torrent_handle.pause()' but not pausing.*
probably because you didn't read the documentation I referred you to.
Specifically this part:

Torrents that are auto-managed may be automatically resumed again
--
Arvid Norberg
sledgehammer999
2017-02-24 18:15:24 UTC
Permalink
So use torrent_handle.auto_manage(false) before torrent_handle.pause(). Or
when adding the torrent to the session make sure to unset the auto_managed
flag.

And this question seems like homework...
Post by Arvid Norberg
On Fri, Feb 24, 2017 at 12:46 PM, Faheem Mohammed <
Post by Faheem Mohammed
*Current code I am working on is as follows. At iteration 10 it has to
pause. I used the code 'torrent_handle.pause()' but not pausing.*
probably because you didn't read the documentation I referred you to.
Torrents that are auto-managed may be automatically resumed again
--
Arvid Norberg
------------------------------------------------------------
------------------
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
sledgehammer999
2017-02-24 18:16:00 UTC
Permalink
Sorry I meant torrent_handle.auto_managed(false)
Post by sledgehammer999
So use torrent_handle.auto_manage(false) before torrent_handle.pause().
Or when adding the torrent to the session make sure to unset the
auto_managed flag.
And this question seems like homework...
Post by Arvid Norberg
On Fri, Feb 24, 2017 at 12:46 PM, Faheem Mohammed <
Post by Faheem Mohammed
*Current code I am working on is as follows. At iteration 10 it has to
pause. I used the code 'torrent_handle.pause()' but not pausing.*
probably because you didn't read the documentation I referred you to.
Torrents that are auto-managed may be automatically resumed again
--
Arvid Norberg
------------------------------------------------------------
------------------
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Faheem Mohammed
2017-02-25 17:45:48 UTC
Permalink
That was the answer I was looking for... Thank you @sledgehammer999...
I am a beginner....So please don't feel disturbed by my questions
Regards...

On Fri, Feb 24, 2017 at 11:46 PM, sledgehammer999 <
Post by sledgehammer999
Sorry I meant torrent_handle.auto_managed(false)
org>
Post by sledgehammer999
So use torrent_handle.auto_manage(false) before torrent_handle.pause().
Or when adding the torrent to the session make sure to unset the
auto_managed flag.
And this question seems like homework...
Post by Arvid Norberg
On Fri, Feb 24, 2017 at 12:46 PM, Faheem Mohammed <
Post by Faheem Mohammed
*Current code I am working on is as follows. At iteration 10 it has to
pause. I used the code 'torrent_handle.pause()' but not pausing.*
probably because you didn't read the documentation I referred you to.
Torrents that are auto-managed may be automatically resumed again
--
Arvid Norberg
------------------------------------------------------------
------------------
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Faheem Mohammed
2017-02-26 10:07:43 UTC
Permalink
Is there queuing in libtorrent... If there how to implement?

On Sat, Feb 25, 2017 at 11:15 PM, Faheem Mohammed <
Post by Faheem Mohammed
I am a beginner....So please don't feel disturbed by my questions
Regards...
On Fri, Feb 24, 2017 at 11:46 PM, sledgehammer999 <
Post by sledgehammer999
Sorry I meant torrent_handle.auto_managed(false)
rg>
Post by sledgehammer999
So use torrent_handle.auto_manage(false) before torrent_handle.pause().
Or when adding the torrent to the session make sure to unset the
auto_managed flag.
And this question seems like homework...
Post by Arvid Norberg
On Fri, Feb 24, 2017 at 12:46 PM, Faheem Mohammed <
Post by Faheem Mohammed
*Current code I am working on is as follows. At iteration 10 it has
to
Post by sledgehammer999
Post by Arvid Norberg
Post by Faheem Mohammed
pause. I used the code 'torrent_handle.pause()' but not pausing.*
probably because you didn't read the documentation I referred you to.
Torrents that are auto-managed may be automatically resumed again
--
Arvid Norberg
------------------------------------------------------------
------------------
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
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
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Continue reading on narkive:
Loading...