Example #1
0
	def insertFromTorrent(self, tfile, info_hash = None):
		dtfile = bencode.bdecode(tfile)
		info_dict = dtfile['info']
		#Convert back to bencoded form to check the info_hash
		data = bencode.bencode(info_dict)
		info_hash = self._hashCompare(data, info_hash)
		#Extract all info
		extra_info  = torrentParse.extractTorrentInfo(dtfile)
		info = torrentParse.extractInfo(info_dict)		
		info = dict(info.items() + extra_info.items())
		#Insert...
		self._insertAllData(info_hash, data, info)
Example #2
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})
Example #3
0
	def insertFromMetadata(self, data, info_hash = None):
		info_hash = self._hashCompare(data, info_hash)
		ddata =	bencode.bdecode(data)
		info = torrentParse.extractInfo(ddata)		
		self._insertAllData(info_hash, data, info)