Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def are_the_same(hash1, hash2):
x = imagehash.similarity(hash1, hash2)
return x > __MATCH_THRESHOLD
if secondary:
series_refs.remove(secondary)
tertiary = find_best_score(series_refs)
# 3. if our book is the first (or unknown) issue, figure out if the best
# matching series has a similar cover to the second or third best.
# if it does, we're probably dealing with a trade paperback and a
# regular issue, and we can't find the best series reliably, so we bail
is_first_issue = (lambda i : not i or \
(utils.is_number(i) and float(i)==1.0))(book.issue_num_s)
if is_first_issue and primary and secondary:
too_similar = False
SIMILARITY_THRESHOLD = __MATCH_THRESHOLD - 0.10
hash1 = __get_remote_hash(primary)
hash2 = __get_remote_hash(secondary)
if imagehash.similarity(hash1, hash2) > SIMILARITY_THRESHOLD:
too_similar = True
elif tertiary:
hash3 = __get_remote_hash(tertiary)
if imagehash.similarity(hash1, hash3) > SIMILARITY_THRESHOLD:
too_similar = True
primary = None if too_similar else primary
return primary
# 3. if our book is the first (or unknown) issue, figure out if the best
# matching series has a similar cover to the second or third best.
# if it does, we're probably dealing with a trade paperback and a
# regular issue, and we can't find the best series reliably, so we bail
is_first_issue = (lambda i : not i or \
(utils.is_number(i) and float(i)==1.0))(book.issue_num_s)
if is_first_issue and primary and secondary:
too_similar = False
SIMILARITY_THRESHOLD = __MATCH_THRESHOLD - 0.10
hash1 = __get_remote_hash(primary)
hash2 = __get_remote_hash(secondary)
if imagehash.similarity(hash1, hash2) > SIMILARITY_THRESHOLD:
too_similar = True
elif tertiary:
hash3 = __get_remote_hash(tertiary)
if imagehash.similarity(hash1, hash3) > SIMILARITY_THRESHOLD:
too_similar = True
primary = None if too_similar else primary
return primary