it works
This commit is contained in:
parent
89ac4cfa5e
commit
88d6db09d5
Binary file not shown.
Before Width: | Height: | Size: 475 KiB After Width: | Height: | Size: 468 KiB |
|
@ -15,27 +15,31 @@ stdout,stderr = out.communicate() # Extract the outputs
|
|||
#print(stdout) # Print the output
|
||||
print(stderr) # Print any errors
|
||||
|
||||
cleaned_stdout = stdout.partition(b"\nmessages\n")[2] + b"" # Trim the messages by removing timestamp and connection info
|
||||
cleaned_stdout = (stdout.partition(b"\nmessages\n")[2] + b"").decode("utf-8") # Trim the messages by removing timestamp and connection info
|
||||
print(cleaned_stdout) # Print the cleaned output
|
||||
|
||||
# Discord limits each message to 2000 chars, if the message is longer than that, truncate it
|
||||
truncated_stdout = [cleaned_stdout[i:i+maxCharPerMessage] for i in range(0, len(cleaned_stdout), maxCharPerMessage)]
|
||||
print (truncated_stdout) # Print the truncated message
|
||||
|
||||
if (truncated_stdout[0] != b'You have no messages.\n'): # If the first part of the truncated message is empty (no messages) dont send it.
|
||||
if (truncated_stdout[0] != "You have no messages.\n"): # If the first part of the truncated message is empty (no messages) dont send it.
|
||||
vidcap = cv2.VideoCapture("rtsp://10.85.3.33:554/11")
|
||||
success,image = vidcap.read()
|
||||
print(success)
|
||||
if success:
|
||||
cv2.imwrite("LibraryFrame.png", image)
|
||||
imagewebhook = DiscordWebhook(url=webhookURL, content="Live Snapshot")
|
||||
with open("LibraryFrame.png", "rb") as f:
|
||||
imagewebhook.add_file(file=f.read(), filename='LibraryFrame.png')
|
||||
response = imagewebhook.execute()
|
||||
# imagewebhook = DiscordWebhook(url=webhookURL, content="Live Snapshot")
|
||||
# with open("LibraryFrame.png", "rb") as f:
|
||||
# imagewebhook.add_file(file=f.read(), filename='LibraryFrame.png')
|
||||
# response = imagewebhook.execute()
|
||||
|
||||
for message_part in truncated_stdout: # For every message part in the truncated output, run this loop
|
||||
message_part = b"```" + message_part + b"```"
|
||||
webhook = DiscordWebhook(url=webhookURL, content=message_part) # Send the output to the webhook URL
|
||||
response = webhook.execute()
|
||||
message_part = "```" + message_part + "```" # Encapsulate the messsage
|
||||
print(message_part)
|
||||
webhook = DiscordWebhook(url=webhookURL, content=message_part) # Attach the message
|
||||
if success:
|
||||
with open("LibraryFrame.png", "rb") as f:
|
||||
webhook.add_file(file=f.read(), filename='LibraryFrame.png')
|
||||
response = webhook.execute() # Hit send
|
||||
else:
|
||||
print("Done.")
|
||||
|
|
Loading…
Reference in New Issue