New post processing script to send tweets.

Come up with a useful post-processing script? Share it here!
Post Reply
welkom_fs
Newbie
Newbie
Posts: 7
Joined: November 22nd, 2011, 1:52 pm

New post processing script to send tweets.

Post by welkom_fs »

Hi. I created this to send tweets to my twitter account.

Get the tarball, which need minimal tweaking to get everything working (see later)

Follow these steps:
1. Create a twitter account at http://www.twitter.com

2. Register your application with Twitter here.
You click on this link and follow the steps to register a new application with twitter.
Start of by selecting Create an application
Fill in the relevant stuff (make it up as you go) and leave the Callback URL empty. Click on create when you are finished.
When it is created change the Access level which is currently Read-only, to Read and Write by clicking on Settings at the top and then change the Application Type to
Read and Write. Update it and wait a few seconds for the update to register. Repeat if necessary.
Now click on details.
Confirm that the Access is Read and Write.
Click at the bottom on Create my access token
Keep that page open to copy and paste stuff from there.

3. Untar the tarball to a directory in your Post-Processing Script directory. (mine is /data/nzb/pps)
The md5sum for this tarball is 9a6f7e5e5ec0faf6fc20ac1443e9f711
Didn't know where else to make file available ):
Thus /data/nzb/pps/Twitter

4. In there will be four files namely: OAuth.sh, TwitterOAuth.sh, tcli.sh and a hidden file tcli.rc.
Populate this last file with the detail displayed on the web page above (the one that is still open):

oauth_consumer_key="Consumer key"
oauth_consumer_secret="Consumer secret"

oauth_token='Access token'
oauth_token_secret='Access token secret'

save and close this file.

5. Change one directory level up (mine is /data/nzb/pps) and do the following

nano twitter
copy and paste the following in there:

#!/bin/bash
##
## This is fast and crude, please dont flame me.

admin () {
#Change these to what you have...
twitterDIR="/data/nzb/pps/Twitter"
logsDIR="/data/nzb/pps/logs"
bigLOG=$logsDIR"/bigLOG"
twitLOG=$logsDIR"/twitLOG"
mkdir -p $logsDIR
touch $bigLOG
touch $twitLOG
}

prepare_msg () {
case $7 in
0)
Message="OK"
;;
1)
Message="Failed verification!"
;;
2)
Message="Failed unpack!"
;;
3)
Message="Failed verification and unpack!"
;;
*)
Message="Unknown?"
;;
esac
d=$(date +%d%b%y" "%R)

#Check string lenghts, change as you like
msg1="#SABnzbd finished downloading $3 from the newsgroup $6 [$d - Status: $Message]"
msg2="#SABnzbd finished with $3 from $6 [$d - Status: $Message]"
msg3="#SABnzbd finished $3 at $d - $Message]"
msg4="#SABnzbd Script error!"

msg=$msg1
msg_length=`expr length "$msg"`

if [ "$msg_length" -gt 140 ]
then
msg=$msg2
msg_length=`expr length "$msg"`
fi

if [ "$msg_length" -gt 140 ]
then
msg=$msg3
msg_length=`expr length "$msg"`
fi

if [ "$msg_length" -gt 140 ]
then
msg=$msg4
msg_length=`expr length "$msg"`
fi

}

update () {
echo $msg "Length: "$msg_length "was tweeted.">> $bigLOG
cd $twitterDIR
./tcli.sh -c statuses_update -s "$msg" >> $twitLOG
cd ..
}

admin
prepare_msg "$1" "$2" "$3" "$4" "$5" "$6" "$7"
update
exit 0

Save this file

7. Change file with chmod +x twitter to make it executable
8. Log into your SABnzbd application and activate the post-processing script 'twitter'

ENJOY

PS. I got my info from here: http://tinyurl.com/cnn885h and from here: http://blog.yjl.im/2010/05/bash-oauth.html and just simplified it.
Tell me what you think and please share anything to make it better.
Yes this is linux only ):
exussum
Jr. Member
Jr. Member
Posts: 79
Joined: November 18th, 2010, 2:51 am

Re: New post processing script to send tweets.

Post by exussum »

Looks good - except people know what youve downloaded.

I can see your currently downloading CSI ? Maybe would work better with protected tweets ?

Also as youve already set up the app, You could probably make it customisable enough so everyone can use your sabnzb_tweet rather than making their own /

Other than that good work !
welkom_fs
Newbie
Newbie
Posts: 7
Joined: November 22nd, 2011, 1:52 pm

Re: New post processing script to send tweets.

Post by welkom_fs »

exussum wrote:Looks good - except people know what youve downloaded.

I can see your currently downloading CSI ? Maybe would work better with protected tweets ?

Also as youve already set up the app, You could probably make it customisable enough so everyone can use your sabnzb_tweet rather than making their own /

Other than that good work !
Thanks, I made it private now.
User avatar
Mar2zz
Jr. Member
Jr. Member
Posts: 85
Joined: February 4th, 2011, 8:30 am
Contact:

Re: New post processing script to send tweets.

Post by Mar2zz »

Is this working? In the script above I see you have several sabnzbdpassed variables inside a function, but you didn't tell the script to store these variables, thus inside a function those will be empty... You should save it first as jobstatus=$7 or something like that, and then use $jobstatus inside the function.
exussum
Jr. Member
Jr. Member
Posts: 79
Joined: November 18th, 2010, 2:51 am

Re: New post processing script to send tweets.

Post by exussum »

looking at twitter before they were private it looked like it worked fine
travanx
Newbie
Newbie
Posts: 5
Joined: February 12th, 2012, 4:14 am

Re: New post processing script to send tweets.

Post by travanx »

Why would you want to tweet this stuff?
mathewparet
Newbie
Newbie
Posts: 9
Joined: January 10th, 2014, 11:57 am

Re: New post processing script to send tweets.

Post by mathewparet »

This doesn't work anymore. It says version 1 is expired.
Post Reply