]> git.donarmstrong.com Git - bin.git/commitdiff
added get_tweekn, parsebanlist and modified svnfix for gaim
authorDon Armstrong <don@donarmstrong.com>
Mon, 3 Oct 2005 23:10:47 +0000 (23:10 +0000)
committerDon Armstrong <don@donarmstrong.com>
Mon, 3 Oct 2005 23:10:47 +0000 (23:10 +0000)
get_tweekin [new file with mode: 0755]
parse_banlist [new file with mode: 0755]
svnfix

diff --git a/get_tweekin b/get_tweekin
new file mode 100755 (executable)
index 0000000..68be38f
--- /dev/null
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use IO::File;
+use IO::Handle;
+use POSIX qw(strftime);
+use HTML::Entities qw(decode_entities);
+use File::Basename qw(basename);
+use DB_File;
+use Storable qw(freeze);
+
+my $OUTDIR=q(/home/don/records/tweekin);
+
+my $DATE=strftime(q(%Y_%m_%d),localtime(time));
+
+my %tw_db;
+tie %tw_db, 'DB_File', "$OUTDIR/tweekin.db" or die "Unable to tie file: $!";
+
+system('mkdir','-p',"$OUTDIR/tweekin_$DATE") == 0 or die "Unable to mkdir: $!";
+
+chdir qq($OUTDIR/tweekin_$DATE);
+
+# get weekly summary
+system('wget','--quiet','-c','http://www.tweekin.com/weeklysummary.htm');
+
+my $summary_fh = new IO::File q(weeklysummary.htm),'r';
+
+my @files_to_get;
+
+local $/ = undef;
+my @summary = split m#\s*</tr>\s*<tr>#s, <$summary_fh>;
+
+for my $entry (@summary) {
+     next unless $entry =~ m#<a\s+href=".+\.mp3">#;
+     my %entry;
+     @entry{qw(catnum mp3 artist title label price genre country format)}
+         = map {s#</?td[^>]*>##;
+                if (m#<a\s+href="([^\"]+)">#) {
+                     $_ = $1;
+                }
+                $_ = decode_entities($_);
+                s/^\s*//s;
+                s/\s*$//s;
+                $_;
+           } split m#</td>\s*<td[^>]*>#, $entry;
+     next if exists $tw_db{$entry{catnum}};
+     push @files_to_get, $entry{mp3};
+     $entry{mp3} = qq(tweekin_$DATE/).basename($entry{mp3});
+     $tw_db{$entry{catnum}} = freeze({%entry});
+}
+
+untie %tw_db;
+
+my $wget = new IO::Handle;
+open $wget, '|-',qw(wget -i - -nH -nd);
+print {$wget} join("\n",@files_to_get);
+close $wget;
diff --git a/parse_banlist b/parse_banlist
new file mode 100755 (executable)
index 0000000..a077435
--- /dev/null
@@ -0,0 +1,54 @@
+#! /usr/bin/perl
+
+use warnings;
+use strict;
+
+
+use IO::File;
+use Getopt::Std;
+
+my $conf = {bans           => 'bans.txt',
+            bans_to_remove => 'bans_to_remove.txt',
+            bans_to_keep   => 'bans_to_keep.txt',
+           minimum_age    => 1209600, # two weeks
+           max_ubans      => 4,
+           };
+
+my $options = {};
+getopt('b:k:r:a:',$options);
+
+$conf->{bans} = $options->{b} || $conf->{bans};
+$conf->{bans_to_remove} = $options->{r} || $conf->{bans_to_remove};
+$conf->{bans_to_keep} = $options->{k} || $conf->{bans_to_keep};
+$conf->{minimum_age} = $options->{a} || $conf->{minimum_age};
+
+my $bans_fh = new IO::File $conf->{bans}, 'r' or die "Unable to open file $conf->{bans} for reading: $!";;
+
+my $bans_r_fh = new IO::File $conf->{bans_to_remove}, 'w' or
+     die "Unable to open file $conf->{bans_to_remove} for writing: $!";
+
+my $bans_k_fh = new IO::File $conf->{bans_to_keep}, 'w' or
+     die "Unable to open file $conf->{bans_to_keep} for writing: $!";
+
+my @bans_to_remove;
+
+while (<$bans_fh>) {
+     # pull the ban and the times.
+     print {$bans_k_fh} $_ and next unless my ($channel, $banmask, $time) = 
+         $_ =~ /(\#\w+)\:\s+ban\s+([\w\d\*\@\%\!\-\_\.]+)\s+\[by\s*.*?\,\s+(\d+)\s+secs/;
+     print {$bans_k_fh} $_ and next unless $time > $conf->{minimum_age};
+
+     # Ignore bans against specific users.
+     print {$bans_k_fh} $_ and next if $banmask =~ /^\%?\w/;
+
+     # Ignore wide bans
+     print {$bans_k_fh} $_ and next if $banmask =~ /\*\!.*?\@.*\*.*/;
+
+     push @bans_to_remove, $banmask;
+}
+
+
+while (my @unbans = splice(@bans_to_remove,0,$conf->{max_ubans})) {
+     print {$bans_r_fh} q(/mode -), q(b) x ($#unbans+1), q( ), join(' ',@unbans);
+     print {$bans_r_fh} qq(\n);
+}
diff --git a/svnfix b/svnfix
index c063b9b8702884c5a71285f8c3d9b67d5b9c96e6..f3273e09e919f3c718c62cf63445e00f4cd81d93 100755 (executable)
--- a/svnfix
+++ b/svnfix
@@ -6,4 +6,8 @@ fi;
 
 if [ -e ~/.hide/todo ]; then
     ln -sf ~/.hide/todo ~/.todo
+fi;
+
+if [ -e ~/.hide/gaim_accounts.xml ] && [ -d .gaim ]; then
+    ln -sf ~/.hide/gaim_accounts.xml ~/.gaim/accounts.xml;
 fi;
\ No newline at end of file