def findDuplicateImages(filename, site = wikipedia.getSite(u'commons', u'commons')):
'''
Takes the photo, calculates the SHA1 hash and asks the mediawiki api for a list of duplicates.
TODO: Add exception handling, fix site thing
'''
f = open(filename, 'rb')
hashObject = hashlib.sha1()
hashObject.update(f.read(-1))
return site.getFilesFromAnHash(base64.b16encode(hashObject.digest()))
评论列表
文章目录