Beispiel #1
0
def getSizeFromFd(torrent_file) :
    """Get hash from a torrent file descriptor

    @type  torrent_file: fd
    @param torrent_file: torrent file 

    @return: size
    """
    res = torrent_file.read()
    metainfo = bDecode.decode(res)[0]

    info = metainfo['info']
    torrent_file.seek(0)
    return int(info['length'])
Beispiel #2
0
def getHashFromFd(torrent_file) :
    """Get hash from a torrent file descriptor

    @type  torrent_file: file
    @param torrent_file: torrent file to hash

    @return: Torrent hash
    """
    res = torrent_file.read()
    metainfo = bDecode.decode(res)[0]

    info = metainfo['info']
    pieces = StringIO.StringIO(info['pieces'])
    torrent_file.seek(0)
    return hashlib.sha1(bDecode.bencode(info)).hexdigest().upper()