PLEASE HELP..
I have been looking through the documentation for a long, but cannot get
the proper code for obtaining filename from magnet uri... Below is my code:
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
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 = file
torrent_handle = None
params = {
'save_path': '/home/faheem/Downloads/',
'storage_mode': lt.storage_mode_t(2)
}
link = "magnet:?xt=urn:btih:B583B1DE1473232CBC480E703F5F8EEDF647D531&dn=Rufus+2.12+Create+bootable+USB+flash+drives+%28USB+keys+or+pen+drives%2C+and+memory+sticks%29+-+786zx&tr=http%3A%2F%2Ft.nyaatracker.com
<http://2ft.nyaatracker.com/>%2Fannounce&tr=http%3A%2F%2Ft.nyaatracker.com
<http://2ft.nyaatracker.com/>%3A80%2Fannounce&tr=http%3A%2F%2Fipv4.tracker.harry.lu
<http://2fipv4.tracker.harry.lu/>%2Fannounce&tr=http%3A%2F%2Fipv4.tracker.harry.lu
<http://2fipv4.tracker.harry.lu/>%3A80%2Fannounce&tr=https%3A%2F%2Fopen.kickasstracker.com
<http://2fopen.kickasstracker.com/>%3A443%2Fannounce&tr=http%3A%2F%2Ftracker.tfile.me
<http://2ftracker.tfile.me/>%2Fannounce&tr=udp%3A%2F%2Ftracker.coppersurfer.tk
<http://2ftracker.coppersurfer.tk/>%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.ilibr.org
<http://2ftracker.ilibr.org/>%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.pirateparty.gr
<http://2ftracker.pirateparty.gr/>%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.ilibr.org
<http://2ftracker.ilibr.org/>%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org
<http://2ftracker.opentrackr.org/>%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.zer0day.to
<http://2ftracker.zer0day.to/>%3A1337%2Fannounce&tr=udp%3A%2F%2Fp4p.arenabg.com
<http://2fp4p.arenabg.com/>%3A1337%2Fannounce&tr=udp%3A%2F%2Fshadowshq.yi.org
<http://2fshadowshq.yi.org/>%3A6969%2Fannounce&tr=udp%3A%2F%2Feddie4.nl%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.zer0day.to
<http://2ftracker.zer0day.to/>%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org
<http://2ftracker.leechers-paradise.org/>%3A6969%2Fannounce&tr=udp%3A%2F%2Fcoppersurfer.tk%3A6969%2Fannounce"
try:
torrent_handle = lt.add_magnet_uri(ses,link,params)
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 const_state_str[torrent_status.state] == "checking":
print 'Checking Torrent....'
continue
print'faheem %.3f MB'%(float(torrent_status.total_done/float(1000000)))
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)
while torrent_handle.is_seed():
print'SEEDING'
On Tue, Mar 21, 2017 at 12:51 PM, Faheem Mohammed <
Post by Faheem MohammedCan anyone give me a code to retrieve filename in python. I am a beginner
in this, so can't convert the c code in documentation. Please help...
Post by Angel LeonMy bad Faheem, I believe that didn't answer your question 100% as you may
also be dealing with a client that's been shut down and starting a previous
session, and the file may have already been completed.
In that case you want to take a look at torrent_handle::file_progress(
...)
file_progress()
void *file_progress* (std::vector<boost::int64_t>& progress, int flags
= 0) const;
This function fills in the supplied vector with the the number of bytes
downloaded of each file in this torrent. The progress values are ordered
the same as the files in the torrent_info
<http://www.libtorrent.org/reference-Core.html#torrent_info>. This
operation is not very cheap. Its complexity is *O(n + mj)*. Where *n* is
the number of files, *m* is the number of downloading pieces and *j* is the
number of blocks in a piece.
The flags parameter can be used to specify the granularity of the file
progress. If left at the default value of 0, the progress will be as
accurate as possible, but also more expensive to calculate. If
torrent_handle::piece_granularity is specified, the progress will be
specified in piece granularity. i.e. only pieces that have been fully
downloaded and passed the hash check count. When specifying piece
granularity, the operation is a lot cheaper, since libtorrent already keeps
track of this internally and no calculation is required.
Post by Angel LeonThe answer was on the first link given to you. Read about alerts.
http://libtorrent.org/reference-Alerts.html#metadata-received-alert
You're interested in file-completed-alert
http://libtorrent.org/reference-Alerts.html#file-completed-alert
Read the answers given to you.
Sorry no you have been repeatedly given links to read the manual. You
did
Post by Angel Leonnot show any effort on your part to do research and I doubt anyone else
here has any interest in fast-tracking your urgent deadline demands. In
fact it would have been quicker to search the manual than write the
question.
http://www.catb.org/~esr/faqs/smart-questions.html
Sorry, I was a bit urgent... that's why??? Regards
Post by Calum LindSeriously?! People here don't mind answering questions but you are
just
Post by Angel LeonPost by Calum Lindbeing lazy and not reading the reference manual, all the answers are
there.
Post by Calum LindOn 18 March 2017 at 17:26, Faheem Mohammed <
Post by Faheem MohammedHow to determine whether the download is finished.. Is there any
inbuilt
Post by Calum LindPost by Faheem Mohammedfunction..
On Tue, Mar 14, 2017 at 8:18 PM, Arvid Norberg <
Post by Arvid NorbergOn Tue, Mar 14, 2017 at 10:26 AM, Faheem Mohammed <
Post by Faheem Mohammedcan you please explain the code using torrent handle to retrieve
filename
Post by Arvid Norberghttp://libtorrent.org/reference-Alerts.html#metadata-
received-alert
Post by Angel LeonPost by Calum LindPost by Faheem MohammedPost by Arvid Norberghttp://libtorrent.org/reference-Core.html#torrent_file()
http://libtorrent.org/reference-Core.html#torrent_info
http://libtorrent.org/reference-Core.html#files()
http://libtorrent.org/reference-Storage.html#file_storage
http://libtorrent.org/reference-Storage.html#num_files()
http://libtorrent.org/reference-Storage.html#file_path()
--
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
------------------------------------------------------------
------------------
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 Angel LeonCheck 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