Twitter Notification

Come up with a useful post-processing script? Share it here!
Post Reply
badboy123
Newbie
Newbie
Posts: 7
Joined: March 13th, 2011, 11:28 am

Twitter Notification

Post by badboy123 »

Are there any scripts out there where a notification is sent to twitter telling me that the file I am downloading has completed downloading?

Or, is there a way to write to a text file as soon as a file had completed downloading, similar to 'history' but in a list format as a txt file?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Twitter Notification

Post by shypike »

You might have looked around a bit in this section:
http://forums.sabnzbd.org/viewtopic.php?f=9&t=9397
badboy123
Newbie
Newbie
Posts: 7
Joined: March 13th, 2011, 11:28 am

Re: Twitter Notification

Post by badboy123 »

Thanks for the quick reply...I should gave been more specific.

I am after a script for windows. That script posted is for linux only.
badboy123
Newbie
Newbie
Posts: 7
Joined: March 13th, 2011, 11:28 am

Re: Twitter Notification

Post by badboy123 »

After doing some searching I across the following project:

hybridauth.sourceforge.net

I am not sure if that project can be used for what I want it to do. As I have next to 0 level knowledge of programming, I am not sure how I would go about implementing it.

There is an example for signing onto twitter here:

hybridauth.sourceforge.net/userguide/Integrating_HybridAuth_SignIn.html

and an example of how to update the twitter status here:

hybridauth.sourceforge.net/userguide/Profile_Data_User_Status.html

Am I going down the right path to implement the twitter notification? All help is much appreciated.
welkom_fs
Newbie
Newbie
Posts: 7
Joined: November 22nd, 2011, 1:52 pm

Re: Twitter Notification

Post by welkom_fs »

Hi, It should be fairly easy with either php-cli or vb script
Look at these pages
http://scottdesapio.com/VBScriptOAuth/
https://github.com/sdesapio/Classic-ASP-VBScript-OAuth
and my favorite http://nullinfo.wordpress.com/oauth-twitter/

Good luck
badboy123
Newbie
Newbie
Posts: 7
Joined: March 13th, 2011, 11:28 am

Re: Twitter Notification

Post by badboy123 »

I am 90% of the way there using a very crude method of tweeting.

I found a small PHP script that allows me to update twitter with only a few lines of code:

code.google.com/p/twitter-php/

I then created a batch script in windows that creates a new text file with the name of the file downloaded and whether it was successful or not. The batch script then executes a send.php script which reads the text file and updates the status with whatever is in the text file. I implemented it this was because it is the only way I know how (I am not sure how to implement sabnzbd user-scripts in PHP). This is the code I am using for my batch script (bare in mind, I have very little knowledge of scripting):

CLS
SET status=%7
SET zero=0
SET filename=%3
IF %status% EQU %zero% (GOTO :SUCCESS) ELSE (GOTO :FAIL)
:SUCCESS
ECHO Sabnzbd - Successfully downloaded %filename% > filename.txt
php -f send.php
EXIT
:FAIL
ECHO Sabnzbd - Failed to download %filename% > filename.txt
php -f send.php
EXIT

This is my send.php script:

<?php
require_once 'twitter.class.php';

$twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);

//Read the data of the text file
$textfile = 'filename.txt';
$textopen = fopen($textfile, 'r');
$filename = fread($textopen, filesize($textfile));
fclose($textopen);

//tweet the data in the text file
$status = $twitter->send($filename);

echo $status ? 'OK' : 'ERROR';


By modifying the status and the filename variable, I can manually run the batch script and it updates twitter without an issue.
However, I am having issues running this as a postprocessing script (even though in the log it says it has run the script). Twitter or the filename.txt does not update when the batch file is set as the postprocessing script.

Any ideas why this could be?
badboy123
Newbie
Newbie
Posts: 7
Joined: March 13th, 2011, 11:28 am

Re: Twitter Notification

Post by badboy123 »

I've managed too get this working with slight modification...

The reason the text file wasn't updating was because an extra 'space' was required in the batch file after % filename%.

The reason twitter was not updating wad because sabnzbd was trying to run send.php from the wrong folder. I fixed that by adding the path of send.php after the php -f command.
drizzt09
Newbie
Newbie
Posts: 22
Joined: July 11th, 2012, 9:21 pm

Re: Twitter Notification

Post by drizzt09 »

did you ever get this script finished and how do we use/implement it?
Post Reply