Changeset 570

Show
Ignore:
Timestamp:
04/10/06 23:29:15
Author:
miyagawa
Message:

Subscription::Planet: allow multi keywords; support non-UTF-8 uri escape

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/lib/Plagger/Plugin/Subscription/Planet.pm

    r526 r570  
    33use base qw( Plagger::Plugin::Subscription::Config ); 
    44 
     5use Encode; 
     6use URI::Escape; 
     7 
     8my @sites = ( 
     9    'http://www.blogpulse.com/rss?query=%s&sort=date&operator=and', 
     10    'http://www.feedster.com/search/type/rss/%s', 
     11    'http://blogsearch.google.com/blogsearch_feeds?hl=en&q=%s&scoring=d&ie=utf-8&num=100&output=rss', 
     12    'http://blog-search.yahoo.co.jp/rss?p=%s:euc-jp', 
     13    'http://blog.goo.ne.jp/search/search.php?status=select&tg=all&st=time&dc=10&dp=all&bu=&ts=all&MT=%s:euc-jp&da=all&rss=1', 
     14    'http://www.namaan.net/rss?namaan=NAMA&ty=5&query=%s', 
     15    'http://search.msn.co.jp/results.aspx?q=%s&format=rss&FORM=RSRE', 
     16    'http://bulkfeeds.net/app/search2.rdf?q=%s', 
     17    'http://rss.sf.livedoor.com/search?q=%s&sf=update_date&start=0', 
     18    'http://b.hatena.ne.jp/t/%s?mode=rss&sort=eid&threshold=1', 
     19    'http://d.hatena.ne.jp/keyworddiary/%s?mode=rss', 
     20); 
     21 
    522sub load { 
    623    my($self, $context) = @_; 
    724 
    8     map { 
    9         s/%s/$self->conf->{keyword}/eg; 
    10         push @{$self->conf->{feed}}, { url => $_ } 
    11     } @{[ 
    12         'http://www.blogpulse.com/rss?query=%s&sort=date&operator=and', 
    13         'http://www.feedster.com/search/type/rss/%s', 
    14         'http://blogsearch.google.com/blogsearch_feeds?hl=en&q=%s&scoring=d&ie=utf-8&num=100&output=rss', 
    15         'http://blog-search.yahoo.co.jp/rss?p=%s', 
    16         'http://blog.goo.ne.jp/search/search.php?status=select&tg=all&st=time&dc=10&dp=all&bu=&ts=all&MT=%s&da=all&rss=1', 
    17         'http://www.namaan.net/rss?namaan=NAMA&ty=5&query=%s', 
    18         'http://search.msn.co.jp/results.aspx?q=%s&format=rss&FORM=RSRE', 
    19         'http://bulkfeeds.net/app/search2.rdf?q=%s', 
    20         'http://rss.sf.livedoor.com/search?q=%s&sf=update_date&start=0', 
    21         'http://b.hatena.ne.jp/t/%s?mode=rss&sort=eid&threshold=1', 
    22         'http://d.hatena.ne.jp/keyworddiary/%s?mode=rss', 
    23     ]}; 
     25    my $keyword = $self->conf->{keyword}; 
     26       $keyword = [ $keyword ] unless ref $keyword; 
     27 
     28    for my $kw (@$keyword) { 
     29        for my $site (@sites) { 
     30            $site =~ s{%s(?::([\w\-]+))?}{ 
     31                my $query = $kw; 
     32                if ($1) { 
     33                    Encode::from_to($query, "utf-8" => $1); 
     34                } 
     35                URI::Escape::uri_escape($query); 
     36            }eg; 
     37            push @{$self->conf->{feed}}, { url => $site } 
     38        } 
     39    } 
    2440 
    2541    $self->SUPER::load($context);