2009-04-02, 02:17
Not sure if this should go here or in a more general XBMC forum, if it is in the wrong place please let me know and I will post it in the correct place!.
I have written a very basic perl notification script for use with XBMC and some form of mail pipe.
What does it do?
It simply takes an incoming standard in (stdin) pipe of a mail message and splits the subject and body parts, these parts are then passed to XBMC using the web interface to produce an a notify message on the screen.
I have written two versions, one very generic and one tailored to SABNZBd newsgroup email alerts.
They are very rough and I am sure could be improved but they work in testing and thought I would share.
Here is the script source for the generic version
email.pl
And the script for the SABNZBd version
newsgroup.pl
I have used postfix on my XBMC box to pipe an alias address to these script(s)
My alias file now contains these lines
How you pipe mail from other mail servers I have no idea.
I know this information is brief but its gone 1am here and thought I would share and maybe this will help people write more advanced scripts or take this and extend it.
Hope this is of use, can update with more information tomorrow or at the weekend if people find it would help.
Blake
I have written a very basic perl notification script for use with XBMC and some form of mail pipe.
What does it do?
It simply takes an incoming standard in (stdin) pipe of a mail message and splits the subject and body parts, these parts are then passed to XBMC using the web interface to produce an a notify message on the screen.
I have written two versions, one very generic and one tailored to SABNZBd newsgroup email alerts.
They are very rough and I am sure could be improved but they work in testing and thought I would share.
Here is the script source for the generic version
email.pl
Code:
#!/usr/bin/perl
use LWP::Simple;
use URI::Escape;
my $titleENC;
my $subjENC;
while (<STDIN>){
if (m/Subject:\s*(.*)/s) {
$titleENC = uri_escape($1);
}
$string .= $_;
}
@array = split(/\n{2,}/, $string);
$subjENC= uri_escape($array[1]);
$content = get("http://192.168.0.1:9099/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification($titleENC,$subjENC,12000))");
And the script for the SABNZBd version
newsgroup.pl
Code:
#!/usr/bin/perl
use LWP::Simple;
use URI::Escape;
while (<STDIN>){
if (m/Subject: SABnzbd has completed job \s*(.*)/s) {
$subjENC = uri_escape($1);
$titleENC = uri_escape("Download Finished");
$content = get("http://192.168.0.1:9099/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification($titleENC,$subjENC,12000))");
}
}
I have used postfix on my XBMC box to pipe an alias address to these script(s)
My alias file now contains these lines
Code:
newsgroup: "| /usr/share/xbmc/eventscripts/newsgroup.pl"
alerts: "| /usr/share/xbmc/eventscripts/email.pl"
How you pipe mail from other mail servers I have no idea.
I know this information is brief but its gone 1am here and thought I would share and maybe this will help people write more advanced scripts or take this and extend it.
Hope this is of use, can update with more information tomorrow or at the weekend if people find it would help.
Blake