/usr/share/irssi/scripts/imdb.pl is in irssi-scripts 20131030.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | use Irssi;
use LWP::UserAgent;
use strict;
use vars qw($VERSION %IRSSI $cache);
$VERSION = '1.01';
%IRSSI = (
authors => 'Eric Jansen',
contact => 'chaos@sorcery.net',
name => 'imdb',
description => 'Automatically lookup IMDB-numbers in nicknames',
license => 'GPL',
modules => 'LWP::UserAgent',
url => 'http://xyrion.org/irssi/',
changed => 'Sat Mar 1 12:39:49 CET 2003'
);
my $ua = new LWP::UserAgent;
$ua->agent('Irssi; ' . $ua->agent);
# Set the timeout to one second, so it won't freeze the client too long on laggy connections
$ua->timeout(1);
sub event_nickchange {
my ($channel, $nick, $old_nick) = @_;
# Lookup any 7-digit number in someone elses nick
if($nick->{'nick'} ne $channel->{'ownnick'}->{'nick'} && $nick->{'nick'} =~ /\D(\d{7})(?:\D|$)/) {
my $id = $1;
# See if we know the title already
if(defined $cache->{$id}) {
# Print it
$channel->printformat(MSGLEVEL_CRAP, 'imdb_lookup', $old_nick, $cache->{$id}->{'title'}, $cache->{$id}->{'year'});
}
# Otherwise, contact IMDB
else {
# Fetch the movie detail page
my $req = new HTTP::Request(GET => "http://us.imdb.com/Title?$id");
my $res = $ua->request($req);
# Get the title and year from the fetched page
if($res->is_success && $res->content =~ /<title>(.+?) \((\d+)\)<\/title>/) {
my ($title, $year) = ($1, $2);
# Decode special characters in the title
$title =~ s/&#(\d+);/pack('U*', $1)/eg;
# Print it
$channel->printformat(MSGLEVEL_CRAP, 'imdb_lookup', $old_nick, $title, $year);
# And cache it
$cache->{$id} = {
'title' => $title,
'year' => $year
};
}
}
}
}
Irssi::theme_register([
'imdb_lookup', '{nick $0} is watching {hilight $1} ($2)'
]);
Irssi::signal_add('nicklist changed', 'event_nickchange');
|