[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: 185
Joined: 27 Jun 2014, 22:13
Contact:

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

Post by l2g » 07 Nov 2015, 18:04

conradh wrote:I just tested several combination of the settings. Indeed you need the ControlIP to be 0.0.0.0 and the switch SecureControl on OFF.
Only then you don't get an error.

In that case you cannot run NZBGet under SSL.
I got SSL working; however there appears to be an issue with the underlining structure of the xmlrpc library Python ships with. For this reason, you will have to set the ControlIP to 0.0.0.0 for it to work.


You can enable SSL and use the Notify script you wish again using the master branch. Here is a quick link to it.
Last edited by l2g on 06 Jul 2017, 16:41, edited 1 time in total.

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

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

Post by l2g » 11 Aug 2016, 02:18

Release v0.5.0 (Direct Download Link) in place.

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

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

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

Post by l2g » 21 Sep 2016, 03:24

Sorry to be double posting on my own thread. I just added Telegram support and some extra email default support (for Pronto Mail) so I bumped the release up a bit.

Thus: Release v0.5.5 (Direct Download Link) is in place.

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

Happy notifying! :)

m74
Posts: 3
Joined: 20 Oct 2016, 05:36

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

Post by m74 » 20 Oct 2016, 05:48

Well, im not sure how to use this script.
I want notifications on my telegram bot.
I configured the bot in the settings, enabled notify on added to queue, on complete and on error.
When i active the script in QueueScript, ill get a notification when i added a nzb to the Queue, thats ok.
When i active the script in PostScript, il wont get a notification, but an error in the Log.

Code: Select all

Sun Oct 16 15:35:57 2016        INFO    Executing post-process-script nzb-notify-0.5.5/Notify.py for title_of_nzb_file
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get_files('/data/nzbget/tmp') with 1 filter(s)
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(system) NZBDIR="/data/nzbget/nzb"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get_files('/data/nzbget/nzb') with 1 filter(s)
Sun Oct 16 15:35:59 2016        WARNING Notify: NZBParse - NZB-File is missing: title_of_nzb_file
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(system) NZBID="1063"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(config) SERVERS="tgram://botid/chatid"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] Opened connection to SQLite Database: /data/nzbget/tmp/nzbget/nzbget.db
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(default) TITLE=None
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(default) BODY=None
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(config) INCLUDEIMAGE="yes"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(config) SERVERS="tgram://botid/chatid"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(config) ONFAILURE="yes"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(config) ONSUCCESS="yes"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(config) INCLUDESTATS="yes"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(config) INCLUDEFILES="no"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(config) INCLUDELOGS="OnFailure"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(system) SECURECONTROL="no"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(system) SECURECERT=""
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(system) SECUREKEY=""
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(system) CONTROLPORT="6789"
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(system) CONTROLUSERNAME=""
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(system) CONTROLPASSWORD=""
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] API connected @ http://127.0.0.1:6789/xmlrpc
Sun Oct 16 15:35:59 2016        INFO    Notify: [DEBUG] get(system) NZBID="1063"
Sun Oct 16 15:35:59 2016        ERROR   Notify: Traceback (most recent call last):
Sun Oct 16 15:35:59 2016        ERROR   Notify:   File "/data/nzbget/scripts/nzb-notify-0.5.5/Notify/nzbget/ScriptBase.py", line 2418, in run
Sun Oct 16 15:35:59 2016        INFO    Notify:     exit_code = main_function(*args, **kwargs)
Sun Oct 16 15:35:59 2016        ERROR   Notify:   File "/data/nzbget//scripts/nzb-notify-0.5.5/Notify.py", line 993, in postprocess_main
Sun Oct 16 15:35:59 2016        INFO    Notify:     stats = self.get_statistics()
Sun Oct 16 15:35:59 2016        ERROR   Notify:   File "/data/nzbget/scripts/nzb-notify-0.5.5/Notify/nzbget/PostProcessScript.py", line 660, in get_statistics
Sun Oct 16 15:35:59 2016        INFO    Notify:     dl_size = float(group['DownloadedSizeMB'])
Sun Oct 16 15:35:59 2016        ERROR   Notify: KeyError: 'DownloadedSizeMB'
Sun Oct 16 15:35:59 2016        ERROR   Post-process-script nzb-notify-0.5.5/Notify.py for title_of_nzb_file failed
Am i doing something wrong or is it a bug?

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

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

Post by l2g » 20 Oct 2016, 13:41

I never seen that before; that's weird.

Basically what is happening is you're download completed, and NZB-Notify tried to make use of the RCP service built into NZBGet for some extra info to pass along to you. But for some reason the particular items it looks for (which are always there) wasn't present.

Anyway, i added a fix to handle this for you (commit link). If you could download a new copy of the NZB-Notify script from the master branch (Direct Link) and try it again for me; that would be great!

In the meantime (for my own information):
  • What version of NZBGet are you using?
  • What OS are you running?
  • Has this (Notify Script) worked for you in the past?
  • What version of Python do you have installed (not applicable to this issue, but useful none the less)?

m74
Posts: 3
Joined: 20 Oct 2016, 05:36

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

Post by m74 » 20 Oct 2016, 15:34

NZBGet Version: 17.1
OS: latest stable Debian on Pi
Worked: for one time only, dont know why. but im using it just for some days
Python: 2.7.9

Your fix doesnt work, well, its working a bit more than before :D

Code: Select all

 WARNING Notify: Failed to send Telegram:1234567890 notification: (400) Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 4094.

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

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

Post by l2g » 20 Oct 2016, 16:28

m74 wrote:

Code: Select all

 WARNING Notify: Failed to send Telegram:1234567890 notification: (400) Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 4094.
Well you definitely uncovered a bug with the new Telegram support I recently added. Telegram uses a markdown langugage to add bold/italic to things it posts. but it would appear it can't handle these special characters if they don't already have a match; For example:
_i am bold between underscores_ would get translated to: i am bold between underscores

But filenames that have underscores in them already can conflict with this logic... for example: _A_Filename_with_underscores_ (5 underscores) might get translated to AFilenamewithunderscores (spaces are lost because they're reserved for bolding). Alternatively, when a line/word can't be parsed, it usually just doesn't do anything and leaves everything how it was (underscores included - this is how GitHub does it).

Anyway, usually it's not a big deal, but clearly Telegram isn't having any of it. Based on your logs, an odd number of markdown tokens appears to causes Telegram to backfire. But it's giving you the character location the backfire is occurring at.

Sooo... I'm going to need some time to fix this bug. I'll have to write a new chunk of code that escapes the markup language for 'just' Telegram messages since it appears to be the only one that has this problem. What you'll find is some messages might go through and others won't. It'll be completely dependant on the content of the notification.

It would be a fantastic help if you could turn Debugging mode on your Notify Script (through NZBGet's options) and private message me the Payload that triggers your error. The log entry "Telegram Payload: ...." is specific what I'm interested in. I'd also like the Telegram error that shows you the character # that caused it to be rejected.

Edit: I just thought of a quick and dirty fix that may work (content pushed). Can you fetch the master content and try again when you have a chance? I'll still be interested in the payload if it fails though (as per discussion above).

m74
Posts: 3
Joined: 20 Oct 2016, 05:36

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

Post by m74 » 20 Oct 2016, 16:44

Your last fix worked for me!

morback
Posts: 4
Joined: 31 Oct 2016, 11:23

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

Post by morback » 23 Dec 2016, 15:55

Hi

Thanks so much for your script !

As someone who change from pushbullet to Join, it is really appreciated that htere already is a join support for NZBGet

Unfortunately, I did not use your script before, but the Pushbullet one. Yours works really well too, but the Pushbullet's one is more flexible : you can choose if you want the nzb title, status, avgdownspeed, download time etc...

Do you plan to add the ability to report all those informations in the pushes?

Thanks again for your work

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

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

Post by l2g » 24 Dec 2016, 04:34

I do provide all of those statistics and information you're requesting, but it's restricted for certain services. The problem is that some notification services (like Join Notification for example) can't support a lot of characters (PushBullet has no problem). As a result these Notification responses are 'significantly shortened'.

If you want, you can open up the Notify.py script (with a text editor and look for lines 660 - 663). These lines are exclusively for the Join Notification itself; they look like this:

Code: Select all

                # Limit results to just the first 2 line otherwise
                # there is just to much content to display
                body = re.split('[\r\n]+', body)
                body[0] = body[0].strip('#').strip()
                body = '\r\n'.join(body[0:2])
You'll want to comment out (place a hashtag (#) in front of) these lines which will disable this filter i've (intentionally) got in place for JOIN Notifications. Make it so your change looks like:

Code: Select all

                # Limit results to just the first 2 line otherwise
                # there is just to much content to display
                # body = re.split('[\r\n]+', body)
                # body[0] = body[0].strip('#').strip()
                # body = '\r\n'.join(body[0:2])
Save the file and reload NZBGet. I think you'll find that Join Notifications won't handle the large message how you'd have hoped it would. Its certainly no comparison to PushBullet. Another thing you could try is switching to another notification service that supports more characters (like Telegram, or Slack for example). Good luck! :)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests