From 56e4f0b539658f646eda481cafa0844620f1c83e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 3 Sep 2009 18:29:04 +0200 Subject: [PATCH] get files from torrent file --- oxlib/torrent.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/oxlib/torrent.py b/oxlib/torrent.py index daf7cb0..27f5609 100644 --- a/oxlib/torrent.py +++ b/oxlib/torrent.py @@ -5,6 +5,7 @@ from threading import Event import hashlib from os import stat +import os from BitTornado.BT1.makemetafile import make_meta_file from bencode import bencode, bdecode @@ -55,6 +56,18 @@ def getTorrentInfo(data): tinfo['announce'] = metainfo['announce'] return tinfo +def getFiles(data): + files = [] + info = getTorrentInfo(data) + if 'files' in info: + for f in info['files']: + path = [info['name'], ] + path.extend(f['path']) + files.append(os.path.join(*path)) + else: + files.append(info['name']) + return files + def getTorrentSize(torrentFile): "Returns Size of files in torrent file in bytes" return getTorrentInfo(torrentFile)['size']