def findDuplicateImages(filename):
'''
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')
result = []
hashObject = hashlib.sha1()
hashObject.update(f.read(-1))
#f.close()
sha1Hash = base64.b16encode(hashObject.digest())
params = {
'action' : 'query',
'list' : 'allimages',
'aisha1' : sha1Hash,
'aiprop' : '',
}
data = query.GetData(params, site=wikipedia.getSite(), useAPI = True, encodeTitle = False)
for image in data['query']['allimages']:
result.append(image['name'])
return result
评论列表
文章目录