[PP-Script / Queue-Script] Notifications (All In One)

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
l2g
Posts: 228
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by l2g » 06 Jul 2017, 02:16

Applied several accumulating bugs into one release in addition to another new notification service called MatterMost.

Release v0.6.0 (Direct Download Link) is now in place.

The release details (and new documentation) can be found at the head of this thread (quick link).

Happy notifying! :)

l2g
Posts: 228
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by l2g » 10 Jul 2017, 02:08

Final bump for this script (sorry for the double post).
This is just a minor release that applies some small updates:
  • Small bug fix for MatterMost Notifications users.
  • Inline Configuration Check (users can test their settings now right from the NZB-Get configuration page)!
Release v0.6.1 (Direct Download Link) is now in place.

The release details (and new documentation) can be found at the head of this thread (quick link).

Happy notifying! :)

devicenull
Posts: 5
Joined: 04 Feb 2016, 18:37

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by devicenull » 10 Aug 2017, 17:22

I just found this script when I was looking to see if I could send notifications to slack. Nice work. I have run into one problem though, running NZBGet 19.1 on a Qnap w/ Notify 0.6.1 installed, I am still getting the certificate errors mentioned above. I do not have https connections enabled for NZBGet though it appears to be an issue processing Slack's cert for the https connection.

If I run Notify from the command line to my slack instance, it works fine but when a file or the test operation is run, it fails (even though the dialog says that the test passed). Here are the logs from NZBget:

Code: Select all

Thu Aug 10 13:05:12 2017        INFO    Executing script Notify.py with command TestServers
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) SERVERS="slack://RedactedTokenA/RedactedTokenB/RedactedTokenC/#notifications"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(default) TITLE=None
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(default) BODY=None
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDEIMAGE="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) SERVERS="slack://RedactedTokenA/RedactedTokenB/RedactedTokenC/#notifications"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) ONFAILURE="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) ONSUCCESS="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDESTATS="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDEFILES="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDELOGS="OnFailure"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] get(config) INCLUDEIMAGE="yes"
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] Server parsed to: {'host': 'RedactedTokenA', 'user': None, 'query': '%23notifications', 'url': 'slack://RedactedTokenA/RedactedTokenB/RedactedTokenC/%23notifications', 'path': '/RedactedTokenB/RedactedTokenC/', 'fullpath': '/RedactedTokenB/RedactedTokenC/%23notifications', 'password': None, 'port': None, 'qsd': {}, 'schema': 'slack'}
Thu Aug 10 13:05:13 2017        WARNING Notify: No user was specified; using NZB-Notify.
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] Slack POST URL: https://hooks.slack.com/services/RedactedTokenA/RedactedTokenB/RedactedTokenC (cert_verify=True)
Thu Aug 10 13:05:13 2017        INFO    Notify: [DEBUG] Slack Payload: {'username': 'NZB-Notify', 'mrkdwn': True, 'channel': '#notifications', 'attachments': [{'footer': 'NZB-Notify', 'color': '#3AA3E3', 'text': '## NZBGet-Notify Configuration Test ##\r\n- **OnFailure**: Yes\r\n- **OnSuccess**: Yes\r\n- **Include Statistics**: Yes\r\n- **Include File Listings**: Yes\r\n- **Include Log Details**: Yes\r\n', 'title': 'NZBGet-Notify Configuration Test', 'ts': 1502384713.785524, 'footer_icon': 'http://yes'}]}
Thu Aug 10 13:05:14 2017        WARNING Notify: A Connection error occured sending Slack:notifications notification.
Thu Aug 10 13:05:14 2017        INFO    Notify: [DEBUG] Socket Exception: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
Thu Aug 10 13:05:14 2017        INFO    Notify: [DEBUG] Exiting with return code: 93
Thu Aug 10 13:05:14 2017        INFO    Script Notify.py with command TestServers successful
From the command line:

Code: Select all

[/share/CACHEDEV1_DATA/.qpkg/NZBGet/nzbget/scripts] # python Notify.py -s slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications -t "Test" -b "Test Msg" -D
[INFO] [DEBUG] Script mode forced off.
2017-08-10 13:18:37,959 - 21480 - DEBUG - get(default) SERVERS=None
2017-08-10 13:18:37,959 - 21480 - DEBUG - set(config) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,959 - 21480 - DEBUG - set(environment) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,959 - 21480 - DEBUG - get(default) TITLE=None
2017-08-10 13:18:37,959 - 21480 - DEBUG - set(config) TITLE="Test"
2017-08-10 13:18:37,960 - 21480 - DEBUG - set(environment) TITLE="Test"
2017-08-10 13:18:37,960 - 21480 - DEBUG - get(default) BODY=None
2017-08-10 13:18:37,960 - 21480 - DEBUG - set(config) BODY="Test Msg"
2017-08-10 13:18:37,960 - 21480 - DEBUG - set(environment) BODY="Test Msg"
2017-08-10 13:18:37,960 - 21480 - DEBUG - get(default) INCLUDEIMAGE=None
2017-08-10 13:18:37,960 - 21480 - DEBUG - get(config) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(config) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(config) TITLE="Test"
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(config) BODY="Test Msg"
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(default) INCLUDEIMAGE=None
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(default) INCLUDEIMAGE=None
2017-08-10 13:18:37,961 - 21480 - DEBUG - get(config) SERVERS="slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/#notifications"
2017-08-10 13:18:37,964 - 21480 - DEBUG - Server parsed to: {'host': 'Redacted TokenA', 'user': None, 'query': '%23notifications', 'url': 'slack://Redacted TokenA/RedactedTokenB/RedactedTokenC/%23notifications', 'path': '/RedactedTokenB/RedactedTokenC/', 'fullpath': '/RedactedTokenB/RedactedTokenC/%23notifications', 'password': None, 'port': None, 'qsd': {}, 'schema': 'slack'}
2017-08-10 13:18:37,964 - 21480 - WARNING - No user was specified; using NZB-Notify.
2017-08-10 13:18:38,184 - 21480 - DEBUG - Slack POST URL: https://hooks.slack.com/services/Redacted TokenA/RedactedTokenB/RedactedTokenC (cert_verify=True)
2017-08-10 13:18:38,185 - 21480 - DEBUG - Slack Payload: {'username': 'NZB-Notify', 'mrkdwn': True, 'channel': '#notifications', 'attachments': [{'color': '#3AA3E3', 'text': 'Test Msg', 'footer': 'NZB-Notify', 'ts': 1502385518.184911, 'title': 'Test'}]}
2017-08-10 13:18:38,529 - 21480 - DEBUG - Exiting with return code: 93

l2g
Posts: 228
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by l2g » 11 Aug 2017, 00:24

Try adding ?verify=False to your url...

So: slack://RedactedTokenA/RedactedTokenB/RedactedTokenC/?verify=False.

Let me know how it goes.

Consider that this error you're getting is happening for a reason though... your Qnap server is unable to verify the authenticity of Slacks website which could be caused by a number of reasons, but here are the most likely:
  • Your certificate authority (CA) file may be out of whack causing your Qnap server to fail in properly validating the authenticity of Slacks website.
  • Your Qnap has been compromised in some way and your being subjected to a man-in-the-middle attack when using this device.
Either way... ?verify=False should fix the issue for you. I trust you know your own environment and trust all authors of any apps/plugins you installed onto your Qnap device. So it should be safe to assume the first option; that just your CA file is just messed or out dated. I will admit though... your situation certainly does seem peculiar though... Good luck!

devicenull
Posts: 5
Joined: 04 Feb 2016, 18:37

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by devicenull » 11 Aug 2017, 00:47

Hmm...... That does work. I did have an issue recently where this box was hit with some malware that was hitting a lot of Qnap boxes. I did go through Qnap's removal process and hadn't seen any other quirks with cert verification. I wonder if there is a way to clear and re-install all the certificates on a Qnap..? Off to Google.

Thanks!

devicenull
Posts: 5
Joined: 04 Feb 2016, 18:37

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by devicenull » 11 Aug 2017, 19:25

Just to circle back.... I'd been on Qnap's QTS 4.2.x firmware for a while since updating to 4.3.x was a 32->64 bit change and required updating a lot of installed services I was worried they wouldn't update cleanly. I bit the bullet and did that update today and found that I no longer need the "verify" parameter for the URL. Not sure if the firmware fixed an underlying cert store issue or if it was just a side effect of newer (and 64-bit) libraries and python...? Either way, thanks for the workaround and now I don't need it.

I also found that QSonarr and QRadarr (both Mono apps) worked fine to Slack with their built-in connections but did have issues with the certs in the logs if you cranked debug up to trace. When I did the firmware upgrade, I had to go from QMono 4.2.x (32-bit) to QMono 4.6.x (64-bit) which was auto updated and they still did the same even though NZBget and Notify.py were fine. I manually reved QMono up to 4.8.x (64-bit) and they started working.

I definitely think there was some issue with the underlying libraries and/or the interfaces to them that were solved by going to fully 64-bit OS and newer frameworks (be that the latest Python 3.x/2.x that got installed or QMono).

l2g
Posts: 228
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by l2g » 29 Oct 2017, 20:18

Applied several accumulating bugs into one release in addition to two new notification services: Release v0.7.0 (Direct Download Link) is now in place.

The release details (and new documentation) can be found at the head of this thread (quick link).

Happy notifying! :)

JackD
Posts: 17
Joined: 15 Jul 2016, 18:17

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by JackD » 24 Nov 2017, 15:08

Hi,

This is an interesting project, but one thing makes me pause to think about using it...

In CLI mode, (or if being run from an app that is not NZBGet etc.) this could be improved to make it more efficient at runtime with slight changes to move any import into a place that is only used when actually needed (or when *not* in CLI mode).

For example...
all of /nzbget/ should only contain stuff for NZBGet, yet it is all imported with all the deps that that entails.

You've (re)positioned this tool as standalone and it would be great if you could refactor for the perspective of standalone runtime use, I understand you may not even care to do this, but thought I would mention it.

Thanks

l2g
Posts: 228
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by l2g » 24 Nov 2017, 16:08

The nzbget dir/module you're referring to is actually the heart of the entire application (and in all my scripts TBH).

Just a bit of background:
The nzbget directory you're referencing is actually just a framework plug-in i wrote a while back to make complicated and/or repetitive tasks in NZBGet scripting easier to do and more centralized. It never caught on as I'm the only one using it (but oh well ;) ). The framework was then expanded to support CLI calls which is where the naming of the module is throwing you off today. The CLI made it easier for me to test my scripts NZBGet support so i could test them from the command line. But it worked so well, i figured i might as well let people use it that way if they need to and documented it. This very same (nzbget) framework was then expanded to support SABnzbd Post Processing scripts too (which throws the nzbget naming right out the window now). But now I can make my scripts work in all 3 environments with little to no effort at all. The way it's designed, it wouldn't take much effort to support torrent apps too.

So there is no doubt, the naming convention chosen doesn't quite fit with it's function any more, but the module (or it's name) shouldn't cause you to raise any concern. Hopefully this explanation will alleviate that!

On a side note; the Notify GitHub page (and wiki) has a bit better documentation than here. BB Code gets a bit complicated to manage quickly with lists and colours (at least for me); so the wiki/markdown presentation makes things a little easer to explain and link to sections with. Regardless, I try my best to keep this thread as up to date as i can.

JackD
Posts: 17
Joined: 15 Jul 2016, 18:17

Re: [PP-Script / Queue-Script] Notifications (All In One)

Post by JackD » 25 Nov 2017, 17:19

l2g wrote:
24 Nov 2017, 16:08
The nzbget dir/module you're referring to is actually the heart of the entire application (and in all my scripts TBH).
Coming in with a fresh set of eyes, the heart is where the primary goal is achieved, and the goal is to notify.

Therefore, I would say the heart is where ever code extends out from modules in path \Notify\pnotify. Much of everything else is app interfacing - whether that be for NZBGet or whatever. However, I can feel the love and loyalty you have for your framework etc, and why you may be too close to it - blocking you from seeing what I see, which is a pity ;)

For example,
l2g wrote:
24 Nov 2017, 16:08
The CLI made it easier for me to test my scripts NZBGet support
Yes, but the project goal has far wider audience appeal used in CLI and without NZBGet. I say CLI purely because with that perspective, I saw how more efficient this could be made for purpose, and once done, then the project becomes useful for all manner of applications wanting to send notifications. Basically, this could be, pure notifications, and then adapters (using the model of Requests) for CLI, NZBGet, etc etc

And yeah, I have looked at your fine wiki page, it's that good writing which led me to delve a little more to see its potential for application use.

Post Reply

Who is online

Users browsing this forum: No registered users and 36 guests