Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Twitter notifications #31

Closed
drizzt09 opened this issue Oct 4, 2017 · 22 comments
Closed

Request: Twitter notifications #31

drizzt09 opened this issue Oct 4, 2017 · 22 comments
Assignees

Comments

@drizzt09
Copy link

drizzt09 commented Oct 4, 2017

I used to use a twitter notification setup from this url https://forums.sabnzbd.org/viewtopic.php?f=9&t=17999&p=98578&hilit=twitter#p98578
but this past week it has stopped working with error:
Notification script returned exit code 255 and output " C:\Program Files\SABnzbd>CLS C:\Program Files\SABnzbd>SET status= C:\Program Files\SABnzbd>SET zero=0 C:\Program Files\SABnzbd>SET filename="Test Notification" 0 was unexpected at this time. C:\Program Files\SABnzbd>IF EQU 0 (GOTO :SUCCESS) ELSE (GOTO :FAIL) "
Would be excellent if your awesome notify service could include twitter

@caronc caronc self-assigned this Oct 5, 2017
@caronc
Copy link
Owner

caronc commented Oct 5, 2017

I'll see how difficult it is and hopefully have a look at it this weekend. Since Twitter restricts you to 140 characters or less. Space is somewhat very limited, what did you want to be displayed inside the tweet?

@drizzt09
Copy link
Author

drizzt09 commented Oct 5, 2017

Successful or failed download and file name.
I had it DM from 1 twitter account to another twitter account. DM do not have character limits. Also regular tweets are in the process of increasing to 280 characters. Started rolling out last week on a staged roll out.
Another option is supporting zapier. It is designed to connect apps. If you can hook into zapier, zapier can fees twitter (and thousands of other apps)

@caronc
Copy link
Owner

caronc commented Oct 5, 2017

Thanks for your feedback! So do you think this new enhancement should provide both public tweets and DMs, or just DMs?

I'm thinking just private DMs might be the best way to go? What are your thoughts?

Meanwhile I'll investigate zapier (as you mentioned) and other frameworks and see what can be put together.

@drizzt09
Copy link
Author

drizzt09 commented Oct 5, 2017

I personally prefer DM but having two command strings (one for each) would give user options which options are always great.
We use Zapier at work to take specific emails and post to Ryver (Slack competitor). You get 5 zaps in a free account

@caronc
Copy link
Owner

caronc commented Oct 6, 2017

I think i just completed the task! 😄. Have a go at the master branch and let me know how it goes.

The syntax is:
tweet://user@/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/

This is presuming you set up yourself an app correctly on https://apps.twitter.com and generated you a set of Access Tokens!

I was able to send myself a Direct Message (i have not added public tweets yet). If i do implement it, the syntax will be the same, but you'll add ?public=True to the end of the URL.

At this point, I'll just be curious to hear your feedback!

@drizzt09
Copy link
Author

drizzt09 commented Oct 6, 2017

wow that was fast. thanks.
OK, created my app and got all keys needed
downloaded and extracted master branch into scripts folder
selected notify.py and put in the parameters based on the above string with my own info
saved but when running test get error:
Notification script returned exit code 1 and output "'python' is not recognized as an internal or external command, operable program or batch file. "

Question is the section for "user@". Is it supposed to be replaced with "@user" or just "user" and is it sending user or receiving user?

@caronc
Copy link
Owner

caronc commented Oct 6, 2017

For SABnzbd you want to choose the special wrapper script (sabnzbd-notify.py); but Notify.py and the Notify directory both need to be present too (all in the same directory).

Then when you fill out the Notification argument, you'll need to put tweet://user@/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/ in the field. You'll need to substituting all the values with what you got from Twitter.

The user can be your twitter identifier (without the @ symbol in front of it) or it can be the Owner Identifier which you can find out from the same screen your Keys are located at. I realize this seems backwards for twitter, but it's actually the correct syntax for a web page URIs.

If you have access to a terminal, you can change to the directory/of/sabnzb/scripts/ and type:

# Test your command manually (without SABnzbd)
python Notify.py -s tweet://user@/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/

# Or, do the same command with the -D switch to see more debugging information that
# may or may not help you, but it may help me (if you belive the problem is still in the script)
python Notify.py -D -s tweet://user@/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/

@drizzt09
Copy link
Author

drizzt09 commented Oct 6, 2017

fixed the script, selection, changed the user which i had a different user. Now i have the user that belongs to the keys.
I used CMD in Windows to run your command but get error there too (which i assume is because im on Windows?):
'python' is not recognized as an internal or external command,
operable program or batch file.

@caronc
Copy link
Owner

caronc commented Oct 6, 2017

Weird, SABnzbd relies on Python, does it not? You could make sure it's a part of your Windows installation; get it here. Then giver another go! :)

@drizzt09
Copy link
Author

drizzt09 commented Oct 6, 2017

ok, python installed. python install directory added to windows path. now python recognized in CMD.
Running your command gives a different error now. a bunch of lines with my keys and then ends with:
2017-10-05 22:55:09,496 - 9124 - ERROR - Could not initialize tweet instance.
2017-10-05 22:55:09,513 - 9124 - DEBUG - Initialization Exception: No user was specified.
2017-10-05 22:55:09,513 - 9124 - DEBUG - Exiting with return code: 0

But i had python Notify.py -D -s tweet://sickbeard9/key/secret/key/secret

@drizzt09
Copy link
Author

drizzt09 commented Oct 6, 2017

Server parsed to: {'host': 'sickbeard9', 'user': None, 'query': None, 'url': 'tweet://sickbeard9/
is the user going into the wrong field? seems like it thinks the user is the host and the user is blank

@drizzt09
Copy link
Author

drizzt09 commented Oct 6, 2017

I restarted the PC and test passed in Sab, but nothing arrived in Twitter.
I ran an actual download and automated the script and got this:
2017-10-06 00:10:52,345 - sabnzbd-notify - 6976 - ERROR - Invalid specified (argument 1)
Syntax: sabnzbd-notify.py <Title> url1[,url2[,urlN]]

  • The can be one of the following:
    complete: Job Finished
    startup: Startup/Shutdown
    warning: Warning
    download: Added NZB
    queue_done: Queue Finished
    disk_full: Disk Full
    pp: Post-Processing Started
    new_login: User Logged In
    failed: Job Failed
    other: Other Messages
    error: Error
  • The <Title> and are self explanitory. If the <Title> is however left
    blank, then the description of the is used instead.
  • All remaining arguments are treated as URLs. You can also delimit multiple
    URLs in a single string/argument with the use of a comma (,).

but same error as before from CMD:
2017-10-06 00:16:38,447 - 5876 - DEBUG - Server parsed to: {'host': 'sickbeard9', 'user': None, 'query': None, 'url': 'tweet://sickbeard9/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/', 'path': '/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/', 'fullpath': '/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/', 'password': None, 'port': None, 'qsd': {}, 'schema': 'tweet'}
2017-10-06 00:16:38,447 - 5876 - ERROR - Could not initialize tweet instance.
2017-10-06 00:16:38,447 - 5876 - DEBUG - Initialization Exception: No user was specified.
2017-10-06 00:16:38,447 - 5876 - DEBUG - Exiting with return code: 0

@caronc
Copy link
Owner

caronc commented Oct 6, 2017

But i had python Notify.py -D -s tweet://sickbeard9/key/secret/key/secret

Your problem is here. Try this instead

# Note that the user you dm (sickbeard9 in this case)
# must have an @ symbol following it, not a slash (/)
Notify.py -D -s tweet://sickbeard9@key/secret/key/secret

@drizzt09
Copy link
Author

drizzt09 commented Oct 6, 2017 via email

@drizzt09
Copy link
Author

drizzt09 commented Oct 7, 2017

ok downloads work, get the DM successfully.
everything in Sab completes but it gives an error even though it worked. Looks like Sab is complaining about the format?
2017-10-06 20:44:23,622 - sabnzbd-notify - 5980 - ERROR - Invalid specified (argument 1)
Syntax: sabnzbd-notify.py <Title> url1[,url2[,urlN]]

  • The can be one of the following:
    complete: Job Finished
    startup: Startup/Shutdown
    warning: Warning
    download: Added NZB
    queue_done: Queue Finished
    disk_full: Disk Full
    pp: Post-Processing Started
    new_login: User Logged In
    failed: Job Failed
    other: Other Messages
    error: Error
  • The <Title> and are self explanitory. If the <Title> is however left
    blank, then the description of the is used instead.
  • All remaining arguments are treated as URLs. You can also delimit multiple
    URLs in a single string/argument with the use of a comma (,).

@caronc
Copy link
Owner

caronc commented Oct 7, 2017

Hmm, this is really weird... so first it works... but then it spits out an error that it didn't 😕

What version of SABnzbd are you using? 2.3.0?

What do you have in the other Notify.py fields? Perhaps you have a space somewhere or more content in your Arguments entry? It accepts more then one (so you can notify more then 1 thing) if you just keep adding more urls. Perhaps there is a bad url at the end?

I might need more time to figure this out because you have me scratching my head. Hopefully I'll have figured it out sometime this weekend. Do you have any other details you can throw at me while i try to reproduce this? Anything at all is useful at this point...

@drizzt09
Copy link
Author

drizzt09 commented Oct 7, 2017

I have no other strings in that parameter field. I will check for spaces at beginning or end but it looks like it's complaining about a comma which ibdont have.
I have all other notification options off. Only have complete and failed downloads checked.
Yes version 2.3 64bit. On win10

@caronc
Copy link
Owner

caronc commented Oct 7, 2017

I'm unable to reproduce your problem at all. I keep getting all of the notifications as expected (just like you said you are). But the difference is, I don't see any errors in my logs. ☹️

One thing you could do is:

  1. Capture your logs that surround the error.
  2. Let the awesome people in the SABnzbd forum know what's going on.

The fact that the main notifications are working tells me that SABnzbd just isn't passing in the correct parameters for some strange scenario. I have to assume that your logs have a lot of successful notification messages surrounding the one your inquiring about?

@drizzt09
Copy link
Author

drizzt09 commented Oct 8, 2017

thanks for the help and it has been working perfectly since.
I finally got around to adding a post in Sab forums https://forums.sabnzbd.org/viewtopic.php?f=9&t=23022
Busy here with Canadian thanksgiving

@caronc
Copy link
Owner

caronc commented Oct 9, 2017

I'm from Canada too! Happy Thanksgiving! 😄

I'm going to close off this ticket now. Feel free to reopen it or create another if you have any more questions or issues!

@caronc caronc closed this as completed Oct 9, 2017
@drizzt09
Copy link
Author

solved the issue on the SAb forums.
I had set NZB-notify both as a post processing script and as a notification script.
post was the one it was failing on.

Did you look into Zapier? https://zapier.com/app/explore

@caronc
Copy link
Owner

caronc commented Oct 14, 2017

Briefly, i ended up solving your request using another library that gives you unlimited posts to Twitter. But i did check Zapier out! It looks like they have lots of apps they can plug you into!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants