sf2slash

| | Comments (0)
#!perl -w
use strict;
use LWP::Simple;
use Slash::DB;
use Slash::Utility;

createEnvironment('useperl');
my $url = 'http://sourceforge.net/developer/diary.php?diary_user=3660&diary_id=';
my @ids = qw(2477 2418 2356 2312 2261 2244 2152 2126 2082 1952 1936
    1857 1848 1777 1753 1738 1724 1643 1637 1542 1536 1527 1488
    1461 1427 1394 1384 1318 1297 1282 1272);

my $slashdb = getCurrentDB();

for (@ids) {
    my($date, $subj, $body);
    $_ = get($url . $_);

    s/\015//g;
    m|<TD colspan=2><TR><TD COLSPAN=2><B>Date:</B> (.+?)<BR>|s;
    $date = $1;
    m|<B>Subject:</B> (.+?)<P>|s;
    $subj = $1;
    m|<B>Body:</B><BR>(.+?)</TD></TR>|s;
    ($body = $1) =~ s/<br>\n<br>\n/\n\n/g;
    $body =~ s/<br>\n//g;

    for ($date, $subj, $body) {
        s/^\s+//;
        s/\s+$//;
    }

    $slashdb->sqlInsert('journals', {
        uid        => 1,
        description    => $subj,
        date        => $date,
        posttype    => 1,
    });

    my($id) = $slashdb->sqlSelect('LAST_INSERT_ID()');
    $slashdb->sqlInsert('journals_text', {
        id        => $id,
        article     => strip_plaintext($body),
    });

    print "Inserted $id\n";

}

__END__ use.perl.org

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on April 20, 2001 5:00 PM.

Fixes and changes was the previous entry in this site.

Switchover is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.