'Returns the infohash of the torrent, for non-URL compatible
torrents. Otherwise it returns the swarm identifier (either the root hash
(Merkle torrents) or hash of the live-source authentication key.
@return A string of length 20.'

def get_infohash(self):

    if self.metainfo_valid:
        return self.infohash
    else:
        raise TorrentDefNotFinalizedException()
