Posted: Sat Oct 06, 2007 6:13 am
Someone informed me that Trillian has a log export function that results in plan text files; these might be a *lot* easier to parse, or might be the exact opposite 
For anybody who found this via google like i did:mbrtis wrote:Hi pheller,
About 2 years after your generous post I'm just now making the switch from Windows to Mac. I've got years of Trillian chat history that I want to move over to Adium, is it possible you could update your perl script to write into Adium's current XMLLogFormat?
Thanks.
Code: Select all
#!/usr/bin/perl
use File::Basename;
use Date::Manip;
use IO::File;
use strict;
my $adiumlogdir = ".";
foreach my $file (@ARGV) {
my $theirbuddyname = basename($file);
$theirbuddyname =~ s/\.log$//;
$theirbuddyname = lc($theirbuddyname);
my $me;
my $them;
my $oh;
my @data = `cat '$file'`;
foreach my $line (@data) {
my $entry;
$line =~ s/[\r|\n]//g;
if ($line =~ /Session Start \((.*):(.*)\): (.*)/) {
$me = $1;
$them = $2;
my $fn = UnixDate(ParseDate($3),"$adiumlogdir/$theirbuddyname/$theirbuddyname\ \(%Y\|%m\|\%d\).AdiumHTMLLog");
print "full: $fn\n";
if (-e $fn) {
print "exists: $fn!\n";
next;
} else {
`mkdir $theirbuddyname`;
undef $oh;
$oh = new IO::File;
$oh->open($fn,"w");
}
} elsif ($line =~ /\d+-\d+\s (\d\d:\d\d:\d\d) (.*): (.*)/) {
my $timestamp = UnixDate(ParseDate($1),"%i:%M:%S %p");
my $from = $2;
my $message = $3;
$entry = "<div ";
if (($from ne $theirbuddyname) && ($from ne $them)) {
$entry .= "class="send">";
} else {
$from = $theirbuddyname;
$entry .= "class="receive">";
}
$entry .= "<span class="timestamp">$timestamp</span> ";
$entry .= "<span class="sender">$from: </span>";
$entry .= "<pre class="message">$message</pre>\n";
}
print $oh $entry;
}
}