Twitter recording status

From MythTV Official Wiki
Revision as of 17:12, 29 April 2009 by Iamlindoro (talk | contribs)

Jump to: navigation, search

It's fairly simple to set up a user job to send out recording status updates via Twitter. Paste the following code into a file (for example, twitter.pl)

#!/usr/bin/perl
use LWP::UserAgent;
my $output = shift @ARGV;
 
my $browser = LWP::UserAgent->new;
my $url = 'http://twitter.com/statuses/update.json';
$browser->credentials('twitter.com:80', 'Twitter API', 'username', 'password');
$response = $browser->get("http://twitter.com/account/verify_credentials.json");
my $response = $browser->post($url, {status => $output});

Edit the username and password to match your twitter user and password. Save the file, make it executable, and put it somewhere in your path. In this example we'll put the file in /usr/bin.

chmod +x twitter.pl
cp twitter.pl /usr/bin/

Stop your backend and run mythtv-setup. In step 1, General, you must adjust two options. First, you must allow the new user job to be run on this backend. For example, if your new User Job is the first one, tick the "Allow User Job #1 on this backend." On the User Job setup page, give your job a name, such as "Post-record Twitter." Then you can use something like the following command line:

/usr/bin/twitter.pl "Finished recording %TITLE% on %CHANNAME%.  Backend was %HOSTNAME%."

You can insert information as you wish, using any of the variables from User Jobs. Complete the setup and you will now have a user job which you can set to run at the end of individual or all recording rules. you can now edit your recording rules and set the user job to run at the end of each recording to update your twitter status.