get files from torrent file

This commit is contained in:
j 2009-09-03 18:29:04 +02:00
parent 827674c85d
commit 56e4f0b539
1 changed files with 13 additions and 0 deletions

View File

@ -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']