Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading the fileset from a torrent

I want to (quickly) put a program/script together to read the fileset from a .torrent file. I want to then use that set to delete any files from a specific directory that do not belong to the torrent.

Any recommendations on a handy library for reading this index from the .torrent file? Whilst I don't object to it, I don't want to be digging deep into the bittorrent spec and rolling a load of code from scratch for this simple purpose.

I have no preference on language.

like image 883
Cheekysoft Avatar asked Jan 02 '09 12:01

Cheekysoft


1 Answers

I would use rasterbar's libtorrent which is a small and fast C++ library.
To iterate over the files you could use the torrent_info class (begin_files(), end_files()).

There's also a python interface for libtorrent:

import libtorrent
info = libtorrent.torrent_info('test.torrent')
for f in info.files():
    print "%s - %s" % (f.path, f.size)
like image 100
Benedikt Waldvogel Avatar answered Sep 29 '22 01:09

Benedikt Waldvogel