def convert_remote_torrent_to_json(torrent):
 torrent_name = torrent['name']
 if ((torrent_name is None) or (len(torrent_name.strip()) == 0)):
  torrent_name = 'Unnamed torrent'
 relevance_score = relevance_score_remote_torrent(torrent_name)
 return {'id': torrent['torrent_id'], 'infohash': torrent['infohash'].encode('hex'), 'name': torrent_name, 'size': torrent['length'], 'category': torrent['category'], 'num_seeders': torrent['num_seeders'], 'num_leechers': torrent['num_leechers'], 'last_tracker_check': 0, 'relevance_score': relevance_score}

def convert_remote_torrent_to_json ( torrent ) : torrent_name = torrent [ 'name' ] if ( ( torrent_name is None ) or ( len ( torrent_name . strip ( ) ) == 0 ) ) : torrent_name = 'Unnamed torrent' relevance_score = relevance_score_remote_torrent ( torrent_name ) return { 'id' : torrent [ 'torrent_id' ] , 'infohash' : torrent [ 'infohash' ] . encode ( 'hex' ) , 'name' : torrent_name , 'size' : torrent [ 'length' ] , 'category' : torrent [ 'category' ] , 'num_seeders' : torrent [ 'num_seeders' ] , 'num_leechers' : torrent [ 'num_leechers' ] , 'last_tracker_check' : 0 , 'relevance_score' : relevance_score }
this method converts a torrent that has been received by remote peers in the network to a json dictionary .