From ce0d3ef1d36d104e3f33bfdcea64b46a3a993384 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Mon, 3 Oct 2005 23:10:47 +0000 Subject: [PATCH] added get_tweekn, parsebanlist and modified svnfix for gaim --- get_tweekin | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ parse_banlist | 54 ++++++++++++++++++++++++++++++++++++++++++++++ svnfix | 4 ++++ 3 files changed, 117 insertions(+) create mode 100755 get_tweekin create mode 100755 parse_banlist diff --git a/get_tweekin b/get_tweekin new file mode 100755 index 0000000..68be38f --- /dev/null +++ b/get_tweekin @@ -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*\s*#s, <$summary_fh>; + +for my $entry (@summary) { + next unless $entry =~ m##; + my %entry; + @entry{qw(catnum mp3 artist title label price genre country format)} + = map {s#]*>##; + if (m##) { + $_ = $1; + } + $_ = decode_entities($_); + s/^\s*//s; + s/\s*$//s; + $_; + } split m#\s*]*>#, $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 index 0000000..a077435 --- /dev/null +++ b/parse_banlist @@ -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 c063b9b..f3273e0 100755 --- 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 -- 2.39.2