caronc / nzb-notify

Push Notifications to a large number of supported services for NZBGet and SABnzbd (based on Apprise)
GNU General Public License v3.0
129 stars 15 forks source link

Could not initialize ... instance. #69

Closed ghost closed 4 years ago

ghost commented 4 years ago

:beetle: Describe the bug Attempting to integrate Notify.py with NzbGet and no matter which notification provider I use, I get an error message stating that it "Could not initialize ... instance."

:bulb: Screenshots and Logs Executing Notify.py with -D reveals:

python Notify.py -t 'Hello' -b 'World' -s discord://{WebhookID}/{WebhookToken}-c -D

2020-09-09 15:59:28,535 - 1631 - DEBUG - Script Mode: shell
2020-09-09 15:59:28,536 - 1631 - DEBUG - Python v3.8.5
2020-09-09 15:59:28,539 - 1631 - DEBUG - OS: Linux 5.4.0-26-generic
2020-09-09 15:59:28,540 - 1631 - DEBUG - get(default) SERVERS=None
2020-09-09 15:59:28,540 - 1631 - DEBUG - set(config) SERVERS="discord://{WebhookID}/{WebhookToken}"
2020-09-09 15:59:28,540 - 1631 - DEBUG - set(environment) SERVERS="discord://{WebhookID}/{WebhookToken}"
2020-09-09 15:59:28,540 - 1631 - DEBUG - get(default) TITLE=None
2020-09-09 15:59:28,540 - 1631 - DEBUG - set(config) TITLE="Hello"
2020-09-09 15:59:28,540 - 1631 - DEBUG - set(environment) TITLE="Hello"
2020-09-09 15:59:28,540 - 1631 - DEBUG - get(default) BODY=None
2020-09-09 15:59:28,540 - 1631 - DEBUG - set(config) BODY="World"
2020-09-09 15:59:28,540 - 1631 - DEBUG - set(environment) BODY="World"
2020-09-09 15:59:28,540 - 1631 - DEBUG - get(default) INCLUDEIMAGE=None
2020-09-09 15:59:28,541 - 1631 - DEBUG - get(config) SERVERS="discord://{WebhookID}/{WebhookToken}"
2020-09-09 15:59:28,541 - 1631 - DEBUG - get(config) TITLE="Hello"
2020-09-09 15:59:28,541 - 1631 - DEBUG - get(config) BODY="World"
2020-09-09 15:59:28,541 - 1631 - DEBUG - get(default) INCLUDEIMAGE=None
2020-09-09 15:59:28,541 - 1631 - DEBUG - get(default) INCLUDEIMAGE=None
2020-09-09 15:59:28,541 - 1631 - DEBUG - get(config) SERVERS="discord://{WebhookID}/{WebhookToken}"
2020-09-09 15:59:28,542 - 1631 - ERROR - Could not initialize discord://{WebhookID}/{WebhookToken} instance.
2020-09-09 15:59:28,542 - 1631 - DEBUG - Exiting with return code: 0

Trying PushBullet:

python Notify.py -t 'Hello' -b 'World' -s pbul://{access_token} -D

2020-09-09 16:15:33,941 - 3094 - DEBUG - Script Mode: shell
2020-09-09 16:15:33,941 - 3094 - DEBUG - Python v3.8.5
2020-09-09 16:15:33,944 - 3094 - DEBUG - OS: Linux 5.4.0-26-generic
2020-09-09 16:15:33,945 - 3094 - DEBUG - get(default) SERVERS=None
2020-09-09 16:15:33,945 - 3094 - DEBUG - set(config) SERVERS="pbul://{access_token}"
2020-09-09 16:15:33,945 - 3094 - DEBUG - set(environment) SERVERS="pbul://{access_token}"
2020-09-09 16:15:33,945 - 3094 - DEBUG - get(default) TITLE=None
2020-09-09 16:15:33,945 - 3094 - DEBUG - set(config) TITLE="Hello"
2020-09-09 16:15:33,945 - 3094 - DEBUG - set(environment) TITLE="Hello"
2020-09-09 16:15:33,945 - 3094 - DEBUG - get(default) BODY=None
2020-09-09 16:15:33,945 - 3094 - DEBUG - set(config) BODY="World"
2020-09-09 16:15:33,945 - 3094 - DEBUG - set(environment) BODY="World"
2020-09-09 16:15:33,946 - 3094 - DEBUG - get(default) INCLUDEIMAGE=None
2020-09-09 16:15:33,946 - 3094 - DEBUG - get(config) SERVERS="{access_token}"
2020-09-09 16:15:33,946 - 3094 - DEBUG - get(config) TITLE="Hello"
2020-09-09 16:15:33,946 - 3094 - DEBUG - get(config) BODY="World"
2020-09-09 16:15:33,946 - 3094 - DEBUG - get(default) INCLUDEIMAGE=None
2020-09-09 16:15:33,946 - 3094 - DEBUG - get(default) INCLUDEIMAGE=None
2020-09-09 16:15:33,946 - 3094 - DEBUG - get(config) SERVERS="pbul://{access_token}"
2020-09-09 16:15:33,947 - 3094 - ERROR - Could not initialize pbul://{access_token} instance.
2020-09-09 16:15:33,947 - 3094 - DEBUG - Exiting with return code: 0

:computer: Your System Details:

:crystal_ball: Additional context I am able to curl the webhook url, which is: https://discord.com/api/webhooks/{WebhookID}/{WebhookToken} where I get JSON back

curl https://discord.com/api/webhooks/{WebhookID}/{WebhookToken}

{"type": 1, "id": "{WebhookID}", "name": "NZBget", "avatar": "45d03949837307...758e130779", "channel_id": "743665...07807007", "guild_id": "7436...30573128", "application_id": null, "token": "{WebhookToken}"}
caronc commented 4 years ago

Wow, this is a really weird one.

What version of apprise got installed into your environment?

You should be able to run:

apprise -V

Next i'd be curious if these notifications work from the command line. You can even use the webhook url too:

apprise -vvv -b "test" https://discord.com/api/webhooks/{WebhookID}/{WebhookToken}

Let me know your results!

tivotyro commented 4 years ago

Apprise Version

apprise -V

apprise v0.8.6
Copyright (C) 2020 Chris Caron <lead2gold@gmail.com>
This code is licensed under the MIT License.

The other request works:

apprise -vvv -b "test" https://discord.com/api/webhooks/{WebhookID}/{WebhookToken}

2020-09-09 16:50:31,642 - DEBUG - Loaded URL: discord://{WebhookID}/{WebhookToken}/?format=text&overflow=upstream&tts=no&avatar=yes&footer=no&footer_logo=yes&image=no&verify=yes
2020-09-09 16:50:31,643 - DEBUG - Discord POST URL: https://discordapp.com/api/webhooks/{WebhookID}/{WebhookToken} (cert_verify=True)
2020-09-09 16:50:31,643 - DEBUG - Discord Payload: {'tts': False, 'wait': True, 'content': 'test', 'avatar_url': 'https://github.com/caronc/apprise/raw/master/apprise/assets/themes/default/apprise-info-256x256.png'}
2020-09-09 16:50:31,825 - INFO - Sent Discord notification.
caronc commented 4 years ago

Strange,

So the apprise backend that Notify.py wraps is working great. Its the Notify.py script that isn't passing back the information correctly.

I'll investigate this further and see what i can find. Does the TEST notification work at all (from within NZBGet)?

caronc commented 4 years ago

Make sure that in the same directory as the Notify.py script that there isn't a directory called Notify. There could be an environment confict where Notify.py isn't actually using the global apprise library that you proved to work.

tivotyro commented 4 years ago

Does the TEST notification work at all (from within NZBGet)?

It returns success, but also displays the error.

image

I reset the webhook so that url is no longer valid

Make sure that in the same directory as the Notify.py script that there isn't a directory called Notify.

Indeed that Notify folder is present in the same place

caronc commented 4 years ago

I just pushed a small fix that will make the logging a little better (source).

Maybe you could try upgrading your copy of NZBGet using the new master branch with this small change? I'm hoping the NZB-Notify logs will reveal a bit more information to help us debug this one. Delete the old Notify directory too (just in-case something is lingering in there causing any issues before you re-checkout the master branch.

Basically your commands like the following should be a bit more revealing (i hope):

b0mb commented 4 years ago

i get the same error msg using nzbget and notify with telegram msg configured

ghost commented 4 years ago

So now there are two errors in the outputs:

I will just reset the tokens when we have this figured out so you can see the actual token values which may be important to troubleshooting.

python Notify.py -t 'Hello' -b 'World' -s pbul://o.7UmHe3EaV7rdBNXGbIJ0FOGRXLlFUYKP -D

2020-09-10 09:58:02,027 - 14430 - DEBUG - Script Mode: shell
2020-09-10 09:58:02,028 - 14430 - DEBUG - Python v3.8.5
2020-09-10 09:58:02,031 - 14430 - DEBUG - OS: Linux 5.4.0-26-generic
2020-09-10 09:58:02,031 - 14430 - DEBUG - get(default) SERVERS=None
2020-09-10 09:58:02,032 - 14430 - DEBUG - set(config) SERVERS="pbul://o.7UmHe3EaV7rdBNXGbIJ0FOGRXLlFUYKP"
2020-09-10 09:58:02,032 - 14430 - DEBUG - set(environment) SERVERS="pbul://o.7UmHe3EaV7rdBNXGbIJ0FOGRXLlFUYKP"
2020-09-10 09:58:02,032 - 14430 - DEBUG - get(default) TITLE=None
2020-09-10 09:58:02,032 - 14430 - DEBUG - set(config) TITLE="Hello"
2020-09-10 09:58:02,032 - 14430 - DEBUG - set(environment) TITLE="Hello"
2020-09-10 09:58:02,032 - 14430 - DEBUG - get(default) BODY=None
2020-09-10 09:58:02,032 - 14430 - DEBUG - set(config) BODY="World"
2020-09-10 09:58:02,032 - 14430 - DEBUG - set(environment) BODY="World"
2020-09-10 09:58:02,032 - 14430 - DEBUG - get(default) INCLUDEIMAGE=None
2020-09-10 09:58:02,033 - 14430 - DEBUG - get(config) SERVERS="pbul://o.7UmHe3EaV7rdBNXGbIJ0FOGRXLlFUYKP"
2020-09-10 09:58:02,033 - 14430 - DEBUG - get(config) TITLE="Hello"
2020-09-10 09:58:02,033 - 14430 - DEBUG - get(config) BODY="World"
2020-09-10 09:58:02,033 - 14430 - DEBUG - get(default) THEME="general"
2020-09-10 09:58:02,033 - 14430 - DEBUG - get(default) NOTIFICATIONTYPE="info"
2020-09-10 09:58:02,033 - 14430 - DEBUG - get(config) SERVERS="pbul://o.7UmHe3EaV7rdBNXGbIJ0FOGRXLlFUYKP"
2020-09-10 09:58:02,034 - 14430 - ERROR - Unparseable URL pbul://o.7UmHe3EaV7rdBNXGbIJ0FOGRXLlFUYKP.
2020-09-10 09:58:02,034 - 14430 - ERROR - Could not initialize pbul://o.7UmHe3EaV7rdBNXGbIJ0FOGRXLlFUYKP instance.
2020-09-10 09:58:02,034 - 14430 - DEBUG - Exiting with return code: 0
python Notify.py -t 'Hello' -b 'World' -s discord://753395368342978631/cdcbR8bfX-Xiy45k8NF7A64eaIPadJerv5_UgkuFzbvfEBazsdeNitUdDxO1i5wIHbre -D

2020-09-10 10:04:54,514 - 15223 - DEBUG - Script Mode: shell
2020-09-10 10:04:54,514 - 15223 - DEBUG - Python v3.8.5
2020-09-10 10:04:54,517 - 15223 - DEBUG - OS: Linux 5.4.0-26-generic
2020-09-10 10:04:54,518 - 15223 - DEBUG - get(default) SERVERS=None
2020-09-10 10:04:54,518 - 15223 - DEBUG - set(config) SERVERS="discord://753395368342978631/cdcbR8bfX-Xiy45k8NF7A64eaIPadJerv5_UgkuFzbvfEBazsdeNitUdDxO1i5wIHbre"
2020-09-10 10:04:54,518 - 15223 - DEBUG - set(environment) SERVERS="discord://753395368342978631/cdcbR8bfX-Xiy45k8NF7A64eaIPadJerv5_UgkuFzbvfEBazsdeNitUdDxO1i5wIHbre"
2020-09-10 10:04:54,518 - 15223 - DEBUG - get(default) TITLE=None
2020-09-10 10:04:54,518 - 15223 - DEBUG - set(config) TITLE="Hello"
2020-09-10 10:04:54,518 - 15223 - DEBUG - set(environment) TITLE="Hello"
2020-09-10 10:04:54,518 - 15223 - DEBUG - get(default) BODY=None
2020-09-10 10:04:54,518 - 15223 - DEBUG - set(config) BODY="World"
2020-09-10 10:04:54,519 - 15223 - DEBUG - set(environment) BODY="World"
2020-09-10 10:04:54,519 - 15223 - DEBUG - get(default) INCLUDEIMAGE=None
2020-09-10 10:04:54,519 - 15223 - DEBUG - get(config) SERVERS="discord://753395368342978631/cdcbR8bfX-Xiy45k8NF7A64eaIPadJerv5_UgkuFzbvfEBazsdeNitUdDxO1i5wIHbre"
2020-09-10 10:04:54,519 - 15223 - DEBUG - get(config) TITLE="Hello"
2020-09-10 10:04:54,519 - 15223 - DEBUG - get(config) BODY="World"
2020-09-10 10:04:54,519 - 15223 - DEBUG - get(default) THEME="general"
2020-09-10 10:04:54,519 - 15223 - DEBUG - get(default) NOTIFICATIONTYPE="info"
2020-09-10 10:04:54,519 - 15223 - DEBUG - get(config) SERVERS="discord://753395368342978631/cdcbR8bfX-Xiy45k8NF7A64eaIPadJerv5_UgkuFzbvfEBazsdeNitUdDxO1i5wIHbre"
2020-09-10 10:04:54,520 - 15223 - ERROR - Unparseable URL discord://753395368342978631/cdcbR8bfX-Xiy45k8NF7A64eaIPadJerv5_UgkuFzbvfEBazsdeNitUdDxO1i5wIHbre.
2020-09-10 10:04:54,520 - 15223 - ERROR - Could not initialize discord://753395368342978631/cdcbR8bfX-Xiy45k8NF7A64eaIPadJerv5_UgkuFzbvfEBazsdeNitUdDxO1i5wIHbre instance.
2020-09-10 10:04:54,520 - 15223 - DEBUG - Exiting with return code: 0
caronc commented 4 years ago

Your issue are incredibly environment specific; i spent an hour now on this and i just can't reproduce it :slightly_frowning_face: .

Would you mind sharing the docker container and/or config you're pulling so i can work with that environment and try to debug this further for you guys? I see you mentioned Alpine Linux 3.12 (on Docker)? hence:

# instructions to get the docker-compose.yml file... ...
# docker container and startup?
ghost commented 4 years ago

This should have everything you need.

nzbget_notify_broken.tar.gz

caronc commented 4 years ago

@davidatrean This is perfect! i was able to reproduce your problem immediately. It's definitely an environment issue! apprise is not correctly installed inside it. I had to do the following to fix it:

# With respect to your attached configuration:
docker-compose exec nzbget sh

Then from within the container:

# get pip
apk add py3-pip
# ... say yes when prompted; let it add it and dependencies

# Remove hosed copy of apprise that exists in this container
pip uninstall apprise

# Then just re-add it
pip install apprise

Then everything works great again

ghost commented 4 years ago

I was able to update the NzbGet.Dockerfile and get positive results. Thank you for all your help!

FROM linuxserver/nzbget

RUN apk add py3-chardet && \
    apk add py3-pip && \
    pip uninstall -y apprise && \
    pip install apprise

And for all the little script-kiddies, the tokens have all been reset, so you are just wasting your time.