#!/usr/bin/perl
# -*- cperl -*-
use strict;
use warnings;
use URI;
use RssC::DB;
use RssC::Checker;
use RssC::Formatter;

if (!$ARGV[0]) {
    print "\n";
    print "Usage: $0 http://www.example.org/\n";
    print "\n";
    exit 0;
}

my $uri = URI->new($ARGV[0]);
$uri->fragment(undef);
$uri = $uri->canonical;
my ($lastmod, $title) = RssC::Checker->check($uri);

# user_titleを見る
my ($user_title) = DB->selectrow_array(q{
    SELECT user_title
      FROM user_title
      LEFT JOIN uri USING (uri_id)
     WHERE uri = ?
}, undef, $uri->as_string);
    
$user_title and
  $title = $user_title;

my $fm = RssC::Formatter->new(
    $uri, $lastmod, $title);
print $fm->format;
