rendered paste body#!/usr/bin/perl
use strict;
use Irssi;
use Irssi::Irc;
use warnings;
use vars qw($VERSION %IRSSI);
# --------------------------------------
# GFTirssi
#
# 0.5
# Fixed bot name checks for new site
# Added filter blocks for missing sections
#
# 0.4
# Fixed bot name checks
#
# 0.3b
# Added category-based filtering
#
# 0.2
# Update for changed (improved!) announce format
#
# 0.1
# launch -- based on reboot's original script
# new download routine to enable downloading with no downloadid in announce
# --------------------------------------
##### CONFIGURATION SECTION #####
# You can find your passkey in your User CP
my $passkey = 'sekrit';
# This is your default watch directory.
my $defaultwatch = '/home/chrisbeebops/watch/';
# Filters. All categories have 4 fields:
# cat_on should be 'yes' or 'no'.
# If 'no', script will ignore all announces of that category
# cat_true is the regex_true expression filtered by qr/$cat_true/i
# It is case insensitive
# See examples
# Set to '' to pass everything
# cat_false is the regex_false expression filtered by qr/$cat_true/i
# It is case insensitive
# See examples
# Set to '' to pass everything
# cat_watch is the watch directory for that category
# eg '/home/username/files/watch/category/'
# if your client only supports 1 watch directory, leave at $defaultwatch
my %filterset = (
# 0DAY
'0DAY' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Anime
'Anime' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# APPS
'APPS' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Carrib Corner
'Carrib Corner' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# E-Learning
'E-Learning' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Foreign
'Foreign' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Games/NDS
'Games/NDS' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Games/PC
'Games/PC' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Games/PS3
'Games/PS3' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Games/PSP
'Games/PSP' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Games/WII
'Games/WII' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Games/XBOX360
'Games/XBOX360' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# GFT Gems
'TV/Gems' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
'Games/Gems' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
'Misc/Gems' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
'Movies/Gems' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
'Music/Gems' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
'XXX/Gems' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Misc
'Misc' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Movies/DVDR
'Movies/DVDR' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Movies/X264
'Movies/X264' => {
cat_on => 'no',
cat_true => '720p|1080p',
cat_false => '',
cat_watch => $defaultwatch,
},
# Movies/XVID
'Movies/XVID' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# Music
'Music/MP3' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
'Music/FLAC' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# MVID
'Music/Vids' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# TV/BLURAY
'TV/BLURAY' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# TV/DVDRIP
'TV/DVDRIP' => {
cat_on => 'no',
cat_true => '^(Batman.The.Brave)',
cat_false => '',
cat_watch => $defaultwatch,
},
'TV/DVDR' => {
cat_on => 'no',
cat_true => '^(Batman.The.Brave)',
cat_false => '',
cat_watch => $defaultwatch,
},
# TV/X264
'TV/X264' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# TV/XVID
'TV/XVID' => {
cat_on => 'no',
cat_true => '',
cat_false => 'TVRiP',
cat_watch => $defaultwatch,
},
# XXX/0DAY
'XXX/0DAY' => {
cat_on => 'no',
cat_true => 'IMAGESET',
cat_false => '',
cat_watch => $defaultwatch,
},
# XXX/DVDR
'XXX/DVDR' => {
cat_on => 'no',
cat_true => '',
cat_false => '',
cat_watch => $defaultwatch,
},
# XXX/HD
'XXX/HD' => {
cat_on => 'no',
cat_true => '720p',
cat_false => '',
cat_watch => $defaultwatch,
},
# XXX/XVID
'XXX/XVID' => {
cat_on => 'no',
cat_true => '',
cat_false => 'German',
cat_watch => $defaultwatch,
}
);
##### END CONFIGURATION SECTION #####
##### DO NOT MODIFY BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING #####
$VERSION="0.4";
%IRSSI = (
authors=> 'chrisbeebops',
contact=> 'forums',
name=> 'GFTirssi',
description=> 'An IRSSI dl script for GFT',
license=> 'Beerware',
);
my $botname = "Spannage";
my $channel = "#GFTracker-spam";
sub event_message {
#FORMAT: NEW :: $release :: $category :: $url :: $pretime
my ($server, $text, $nick, $address, $target) = @_;
if (lc($target) eq lc($channel) && lc($nick) eq lc($botname)) {
print "##### GFTirssi DEBUG: $server / $text / $nick / $address / $target";
my $text = Irssi::strip_codes($text);
if ($text =~ /^NEW :: (.*) :: (.*) :: http:\/\/www\.thegft\.org\/details\.php\?id=([0-9]+) :: /) {
my ($release, $category, $id) = ($1, $2, $3);
print "Announce: $release";
print "Category: $category";
print "TorrentID: $id";
# Check for match
my ($matchcheck, $watchdir) = match($category, $release);
if ($matchcheck eq 'yes') {
print "Downloading: $release";
print "----------";
download($release, $id, $watchdir);
}
else {
print "Not a match.";
print "----------";
}
}
}
}
sub match {
my ($category, $release) = @_;
if ($filterset{$category}{'cat_on'} eq 'yes') {
print "Filter $category on: yes";
if(($filterset{$category}{'cat_true'} eq '') || ($release =~ qr/$filterset{$category}{'cat_true'}/i )) {
print "Filter $category true: pass";
if(($filterset{$category}{'cat_false'} eq '') || ($release !~ qr/$filterset{$category}{'cat_false'}/i )) {
print "Filter $category false: pass";
return ('yes', $filterset{$category}{'cat_watch'});
}
else {
print "Filter $category false: fail";
}
}
else {
print "Filter $category true: fail";
}
}
else {
print "Filter $category on: no";
}
return ('no', $defaultwatch);
}
sub download {
my ($release, $id, $watchdir) = @_;
my $dlurl = 'http://www.thegft.org/download.php?torrent='.$id.'&passkey='.$passkey;
my $file = $watchdir . $release . ".torrent";
my $url = "-q --no-check-certificate -O '" . $file . "' '" . $dlurl."'";
system("wget $url &");
}
Irssi::signal_add("message public", "event_message");