typester (owner)

Forks

Revisions

gist: 45043 Download_button fork
public
Public Clone URL: git://gist.github.com/45043.git
Embed All Files: show embed
outputz-growl.pl #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env perl
 
use strict;
use warnings;
 
use Config::Pit;
use Net::Growl;
use WWW::Mechanize;
 
my $conf = pit_get('outputz.com', require => { key => 'your outputz secret key' });
my $mech = WWW::Mechanize->new( stack_depth => 1 );
 
$mech->get('http://outputz.com/daily');
$mech->follow_link(url_regex => qr/config/);
 
$mech->submit_form(
    fields => {
        magic_word => $conf->{key},
    },
);
 
unless ($mech->content =~ /$conf->{key}/) {
    die 'login failed';
}
 
$mech->get('http://outputz.com/daily');
 
my ($rank, $info) = $mech->content =~ m!<p class="ranking">(\d+)<span class="ranking_info">(.*?)</span></p>!;
die 'html parse failes' unless $rank && $info;
 
my $gconf = pit_get('growl', require => { password => 'your growl network password' });
 
register(
    host => '127.0.0.1',
    application => 'outputz notifier',
    password => $gconf->{password},
);
 
notify(
    application => 'outputz notifier',
    title => 'this hour outputz rank',
    description => $rank . $info,
    password => $gconf->{password},
);