Changeset 2054

Show
Ignore:
Timestamp:
12/04/08 01:55:48
Author:
youpy
Message:

added support for sharebee.com

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plagger/assets/plugins/Filter-FindEnclosures/zshare.pl

    r2024 r2054  
    11sub handle { 
    22    my ($self, $url) = @_; 
    3     $url =~ qr!http://www.zshare.net/(download|audio)/[0-9a-f]+!
     3    ($url =~ qr!http://www\.zshare\.net/(download|audio)/[0-9a-f]+!) || ($url =~ qr!^http://sharebee\.com/[0-9a-f]+!)
    44} 
    55 
    66sub find { 
    77    my($self, $args) = @_; 
    8      
     8    my $response; 
    99    my $uri = $args->{url}; 
     10 
     11    if($uri =~ /sharebee/) { 
     12        $response = LWP::UserAgent->new->get($uri); 
     13        if($response->content =~ m!(http://www\.zshare\.net/download/[0-9a-f]+/)!) { 
     14            $uri = $1; 
     15        } 
     16    } 
     17 
    1018    $uri =~ s/audio/download/; 
    11     my $response = LWP::UserAgent->new->get($uri); 
    12     if($response->content =~ m/link = '(http:\/\/.+\.zshare\.net\/download\/[^']+?)';/) { 
    13         my $enclosure_url = $1; 
     19    $response = LWP::UserAgent->new->post( 
     20        $uri, 
     21        ['download' => 1]); 
     22    if($response->content =~ m/('h','t','t','p'.+?')\);link/) { 
     23        my $enclosure_url = $1; 
     24        $enclosure_url =~ s/[',]//g; 
    1425        my $enclosure = Plagger::Enclosure->new; 
    1526        $enclosure->url($enclosure_url); 
  • trunk/plagger/t/plugins/Filter-FindEnclosures/zshare.t

    r1985 r2054  
    55test_requires_network 'www.zshare.net:80'; 
    66 
    7 plan tests => 2
     7plan tests => 3
    88run_eval_expected; 
    99 
     
    2121          link: http://buycheapviagraonlinenow.com/1 
    2222          body: | 
    23             Here's a link to zShare. <a href="http://www.zshare.net/download/4385403840872c/">test</a> 
     23            Here's a link to zShare. <a href="http://www.zshare.net/download/52199786e5e37595/">test</a> 
    2424        - title: Test 2 
    2525          link: http://buycheapviagraonlinenow.com/2 
    2626          body: | 
    27             Here's a link to zShare. <a href="http://www.zshare.net/audio/4385403840872c/">test</a> 
     27            Here's a link to zShare. <a href="http://www.zshare.net/audio/52199786e5e37595/">test</a> 
     28        - title: Test 3 
     29          link: http://buycheapviagraonlinenow.com/3 
     30          body: | 
     31            Here's a link to ShareBee. <a href="http://sharebee.com/786015ba">test</a> 
    2832 
    2933  - module: Filter::FindEnclosures 
    3034--- expected 
    31 like $context->update->feeds->[0]->entries->[0]->enclosure->url, qr!http://upsilon.zshare.net/download/[0-9a-f]+/[0-9]+/4385403/test.txt!; 
    32 like $context->update->feeds->[0]->entries->[1]->enclosure->url, qr!http://upsilon.zshare.net/download/[0-9a-f]+/[0-9]+/4385403/test.txt!; 
     35like $context->update->feeds->[0]->entries->[0]->enclosure->url, qr!http://[\d\w]+\.zshare\.net/download/[0-9a-f]+/\d+/\d+/test.txt!; 
     36like $context->update->feeds->[0]->entries->[1]->enclosure->url, qr!http://[\d\w]+\.zshare\.net/download/[0-9a-f]+/\d+/\d+/test.txt!; 
     37like $context->update->feeds->[0]->entries->[2]->enclosure->url, qr!http://[\d\w]+\.zshare\.net/download/[0-9a-f]+/\d+/\d+/test.txt!;