Twitter recording status

From MythTV Official Wiki
Revision as of 13:14, 11 November 2009 by Juski (talk | contribs) (Add note about overuse of #mythTV hashtag in tweets)

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,

use LWP::UserAgent;
my $output = shift @ARGV;
my $browser = LWP::UserAgent->new;
my $url = '';
$browser->credentials('', 'Twitter API', 'username', 'password');
$response = $browser->get("");
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
cp /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/ "Finished recording %TITLE% (%SUBTITLE%) on %CHANID% at %ENDTIMEISO%.  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.

NOTE: Some people regard Twitter as a handy news resource and search on tags based on things they like to keep up on - say MythTV for example. Inserting #MythTV in your userjob twitter script makes all your recording tweets appear in the search feed meaning that people who genuinely want to follow real news items have to add the username your script uses to their filter. As of 11th November 2009 the filter string is quite short but as time goes by it'll get longer. PLEASE choose a different tag, or no tag at all. The majority of people wanting to follow #MythTV items are probably not interested in what you record or watch ;-)