Skip to content

Commit 382dd16

Browse files
Fixed typo in urlwatcher.sh and fixed NCC file output
Fixed ncc output being written on stderr
1 parent 84b7b49 commit 382dd16

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

NotifierBot/Sources/Notifier/Commands/DiffCommand.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct DiffCommand: Command {
3333
let realName = entry.name
3434
// Send the diff file and the contents of the ncc file
3535
let nccInfo = try? String(contentsOfFile: "\(mainDirectory!)/urlwatcher/images/\(realName)/\(nccFile)")
36+
print("Sending diff file and NCC information:\n\(nccInfo ?? "nil")")
3637
JFUtils.sendImage(path: "\(mainDirectory!)/urlwatcher/images/\(realName)/\(diffFile)", chatID: chatID, text: nccInfo)
3738
}
3839
}

urlwatcher/urlwatcher.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ function screenshotsMatch {
106106
local IMAGE_LATEST="$2"
107107

108108
# Calculate the normalized cross correllation between both images
109-
NCC=$(compare -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" "$DIFF_FILE")
109+
NCC=$(compare -quiet -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" "$DIFF_FILE" 2>&1)
110110

111-
if [ "NCC" -lt "$NCC_THRESHOLD" ]; then
111+
if [ "$NCC" -lt "$NCC_THRESHOLD" ]; then
112112
# The screenshots are not identical
113113
echo "Possible change detected. Confirming..."
114114

@@ -131,13 +131,13 @@ function screenshotsMatch {
131131

132132
# Compare the two cropped screenshots again
133133
# Calculate the normalized cross correllation between both images
134-
NCC=$(compare -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" "$DIFF_FILE")
134+
NCC=$(compare -quiet -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" "$DIFF_FILE" 2>&1)
135135

136-
if [ "NCC" -lt "$NCC_THRESHOLD" ]; then
136+
if [ "$NCC" -lt "$NCC_THRESHOLD" ]; then
137137
# The screenshots do not match. The website has changed
138138

139139
# Write detailed NCC information to a file (and don't overwrite the diff file)
140-
compare -verbose -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" /dev/null > "$NCC_FILE"
140+
compare -verbose -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" /dev/null &> "$NCC_FILE"
141141

142142
# Return false, as the screenshots do not match
143143
# In bash: 1 == false
@@ -146,7 +146,7 @@ function screenshotsMatch {
146146
fi
147147

148148
# Write detailed NCC information to a file (and don't overwrite the diff file)
149-
compare -verbose -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" /dev/null > "$NCC_FILE"
149+
compare -verbose -metric NCC "$IMAGE_OLD" "$IMAGE_LATEST" /dev/null &> "$NCC_FILE"
150150

151151
# If statement above didn't exit, that means we have no mismatching hashes and therefore the screenshots match (return true)
152152
# In bash: 0 == true

0 commit comments

Comments
 (0)