Пример #1
0
def rescan():
	#Get cursor over all documents that have info data
	cursor = db.torrents.find({'metadata_timestamp':{'$gt':0}})
	print "Rescanning %d torrents" % cursor.count()
	i = 0
	for torrent in cursor:
		print "Rescanning torrent %d" % i
		i += 1
		_id = torrent['_id']
		data = db.data.get(_id).read()
		info = torrentParse.extractInfo(bencode.bdecode(data)) 
		info = sunicode(info)
		db.torrents.update({'_id':_id},{'$set':info})
Пример #2
0
	def _updateInfo(self, info_hash, info):
		#Ensure the info is correctly encoded
		info = sunicode(info)
		binhash = Binary(info_hash)
		self.torrents.update({'_id':binhash},{'$set':info}, upsert = True)