Permalink
Browse files

mylistgrout "add" is same as "list"

  • Loading branch information...
1 parent 0cb36b6 commit b60c3f698ab98878f8284a5e326bdd577fd817c2 @hiroaki committed Apr 18, 2012
Showing with 35 additions and 12 deletions.
  1. +1 −0 MANIFEST
  2. +13 −2 README
  3. +5 −5 lib/Net/NicoVideo.pm
  4. +4 −1 lib/Net/NicoVideo/Response/MylistGroup.pm
  5. +10 −3 lib/Net/NicoVideo/UserAgent.pm
  6. +2 −1 t/00_compile.t
View
@@ -1,6 +1,7 @@
Changes
lib/Net/NicoVideo.pm
lib/Net/NicoVideo/Content/Flv.pm
+lib/Net/NicoVideo/Content/Mylist.pm
lib/Net/NicoVideo/Content/MylistRSS.pm
lib/Net/NicoVideo/Content/MylistGroup.pm
lib/Net/NicoVideo/Content/Thread.pm
View
15 README
@@ -25,6 +25,12 @@ SYNOPSIS
$nnv->fetch_watch( $video_id );
$nnv->fetch_video( $flv, $save_path );
+
+ if( -s $save_path == $info->size_high ){
+ print "ok\n";
+ }else{
+ print "finished, but it may have broken.\n";
+ }
}
DESCRIPTION
@@ -102,8 +108,12 @@ FETCH METHOD
fetch_thread(flv, \%options)
Get an instance of Net::NicoVideo::Content::Thread for video_id.
- fetch_mylist(mylist_id)
- Get an instance of Net::NicoVideo::Content::Mylist for mylist_id.
+ fetch_mylistrss(mylist)
+ fetch_mylistrss(mylist_id)
+ Get an instance of Net::NicoVideo::Content::MylistRSS for mylist.
+
+ fetch_mylistgroup([group_id])
+ Get an instance of Net::NicoVideo::Content::MylistGroup for user own
fetch_watch(video_id)
Get an instance of Net::NicoVideo::Content::Watch for video_id.
@@ -125,6 +135,7 @@ FETCH METHOD
value then it means that the file path to store contents.
UTILITY METHOD
+ through_login(ua)
download(video_id, file)
This is a shortcut to download video that is identified by video_id.
View
@@ -3,7 +3,7 @@ package Net::NicoVideo;
use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.01_15';
+$VERSION = '0.01_16';
use base qw(Class::Accessor::Fast);
@@ -90,17 +90,17 @@ sub fetch_thread {
}
sub fetch_mylistgroup {
- my $self = shift;
+ my ($self, $group_id) = @_;
my $ua = $self->get_user_agent;
- my $res = $ua->request_mylistgroup;
+ my $res = $ua->request_mylistgroup($group_id);
croak "Request 'request_mylistgroup' is error: @{[ $res->status_line ]}"
if( $res->is_error );
unless( $res->is_content_success ){
if( $res->is_error_noauth ){
# try again
- $res = $self->through_login($ua)->request_mylistgroup;
+ $res = $self->through_login($ua)->request_mylistgroup($group_id);
unless( $res->is_content_success ){
if( $res->is_error_noauth ){
croak "Cannot login because specified account is something wrong";
@@ -325,7 +325,7 @@ Get an instance of Net::NicoVideo::Content::Thread for video_id.
Get an instance of Net::NicoVideo::Content::MylistRSS for mylist.
-=head2 fetch_mylistgroup
+=head2 fetch_mylistgroup([group_id])
Get an instance of Net::NicoVideo::Content::MylistGroup for user own
@@ -3,7 +3,7 @@ package Net::NicoVideo::Response::MylistGroup;
use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.01_13';
+$VERSION = '0.01_16';
use base qw/Net::NicoVideo::Response/;
@@ -29,6 +29,9 @@ sub parsed_content { # implement
if( $json->{error} );
my @mylists = ();
+ if( ref( $json->{mylistgroup} ) ne 'ARRAY' ){
+ $json->{mylistgroup} = [$json->{mylistgroup}];
+ }
for my $ml ( @{$json->{mylistgroup}} ){
push @mylists, Net::NicoVideo::Content::Mylist->new($ml);
}
@@ -3,7 +3,7 @@ package Net::NicoVideo::UserAgent;
use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.01_14';
+$VERSION = '0.01_16';
use base qw(Net::NicoVideo::Decorator);
@@ -89,10 +89,17 @@ sub request_mylistrss {
}
sub request_mylistgroup { # for user own
- my ($self) = @_;
+ my ($self, $mylist) = @_; # mylist or mylist_id (group_id)
my $url = 'http://www.nicovideo.jp/api/mylistgroup/list';
+ my $params;
+ if( defined $mylist ){
+ $mylist = $mylist->id if( ref($mylist) and $mylist->isa('Net::NicoVideo::Content::Mylist'));
+ $url = 'http://www.nicovideo.jp/api/mylistgroup/get';
+ $params = [ group_id => $mylist ];
+ }
require Net::NicoVideo::Response::MylistGroup;
- Net::NicoVideo::Response::MylistGroup->new( $self->request(GET $url) );
+ Net::NicoVideo::Response::MylistGroup->new(
+ $self->request(POST $url, $params));
}
sub request_get {
View
@@ -1,10 +1,11 @@
use strict;
use warnings;
-use Test::More tests => 19;
+use Test::More tests => 20;
BEGIN {
use_ok 'Net::NicoVideo';
use_ok 'Net::NicoVideo::Content::Flv';
+ use_ok 'Net::NicoVideo::Content::Mylist';
use_ok 'Net::NicoVideo::Content::MylistRSS';
use_ok 'Net::NicoVideo::Content::MylistGroup';
use_ok 'Net::NicoVideo::Content::Thread';

0 comments on commit b60c3f6

Please sign in to comment.