| 1 | package Net::NicoVideo::Content::NicoAPI; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | $VERSION = '0.28'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use base qw(Net::NicoVideo::Content Class::Accessor::Fast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use JSON 2.01; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use vars qw(@Members); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | @Members = qw( | |||||||||||||||||||||||||||
| 13 | id | ||||||||||||||||||||||||||||
| 14 | mylistgroup | ||||||||||||||||||||||||||||
| 15 | mylistitem | ||||||||||||||||||||||||||||
| 16 | error | ||||||||||||||||||||||||||||
| 17 | status | ||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 1 | __PACKAGE__->mk_accessors(@Members); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub members { # implement | ||||||||||||||||||||||||||
|
Subroutine
members: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 0 | @Members; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub parse { # implement | ||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | 0 | ▶ | $self->load($_[0]) if( defined $_[0] ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | my $json = decode_json( $self->_decoded_content ); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # member "status" exists in all case | ||||||||||||||||||||||||||||
| 33 | 0 | $self->status( $json->{status} ); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # member "error" exists when error occurs in all case | ||||||||||||||||||||||||||||
| 36 | $self->error( Net::NicoVideo::Content::NicoAPI::Error->new($json->{error}) ) | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if( $json->{error} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # member "id" in a case /mylist/add | ||||||||||||||||||||||||||||
| 40 | $self->id( $json->{id} ) | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if( exists $json->{id} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # member "mylistgroup" in case /mylistgroup/list or /mylistgroup/get | ||||||||||||||||||||||||||||
| 44 | 0 | my @mg = (); | |||||||||||||||||||||||||||
| 45 | 0 | ▶ | if( exists $json->{mylistgroup} ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if( ref( $json->{mylistgroup} ) ne 'ARRAY' ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 0 | $json->{mylistgroup} = [$json->{mylistgroup}]; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 0 | for my $mg ( @{$json->{mylistgroup}} ){ | |||||||||||||||||||||||||||
| 50 | 0 | push @mg, Net::NicoVideo::Content::NicoAPI::MylistGroup->new($mg); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | 0 | $self->mylistgroup(\@mg); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # TODO member "mylistitem" | ||||||||||||||||||||||||||||
| 56 | 0 | my @mi = (); | |||||||||||||||||||||||||||
| 57 | 0 | ▶ | if( exists $json->{mylistitem} ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if( ref( $json->{mylistitem} ) ne 'ARRAY' ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | 0 | $json->{mylistitem} = [$json->{mylistitem}]; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 0 | for my $mi ( @{$json->{mylistitem}} ){ | |||||||||||||||||||||||||||
| 62 | 0 | my $item = Net::NicoVideo::Content::NicoAPI::MylistItem->new($mi); | |||||||||||||||||||||||||||
| 63 | 0 | $item->item_data( Net::NicoVideo::Content::NicoAPI::MylistItem::ItemData->new($mi->{item_data}) ); | |||||||||||||||||||||||||||
| 64 | 0 | push @mi, $item; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 0 | $self->mylistitem(\@mi); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # status | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if( $self->is_status_ok ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 0 | $self->set_status_success; | |||||||||||||||||||||||||||
| 72 | }else{ | ||||||||||||||||||||||||||||
| 73 | 0 | $self->set_status_error; | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | return $self; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub is_status_ok { | ||||||||||||||||||||||||||
|
Subroutine
is_status_ok: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 80 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 81 | 0 | ▶ | $self->status and lc($self->status) eq 'ok'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub error_code { | ||||||||||||||||||||||||||
|
Subroutine
error_code: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 85 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 86 | 0 | ▶ | $self->error and $self->error->code; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub error_description { | ||||||||||||||||||||||||||
|
Subroutine
error_description: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 91 | 0 | ▶ | $self->error and $self->error->description; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | ▶ | sub is_error_noauth { | ||||||||||||||||||||||||||
|
Subroutine
is_error_noauth: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 95 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 96 | 0 | ▶ | $self->error and $self->error->code and uc($self->error->code) eq 'NOAUTH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->error and $self->error->code
MC/DC0%0/2
$self->error and $self->error->code
$self->error
$self->error->code
Truth table0%0/3
A and B
A= $self->errorB= $self->error->code
| |||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | package Net::NicoVideo::Content::NicoAPI::Error; | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 103 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 104 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 105 | 1 | $VERSION = '0.28'; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 1 | ▶ | use base qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 108 | 1 | ▶ | use vars qw(@Members); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 109 | 1 | @Members = qw( | |||||||||||||||||||||||||||
| 110 | code | ||||||||||||||||||||||||||||
| 111 | description | ||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 1 | __PACKAGE__->mk_accessors(@Members); | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub members { | ||||||||||||||||||||||||||
|
Subroutine
members: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 117 | 0 | @Members; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | package Net::NicoVideo::Content::NicoAPI::MylistGroup; | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 124 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 125 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 126 | 1 | $VERSION = '0.28'; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 1 | ▶ | use base qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 129 | 1 | ▶ | use vars qw(@Members); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 130 | 1 | @Members = qw( | |||||||||||||||||||||||||||
| 131 | id | ||||||||||||||||||||||||||||
| 132 | user_id | ||||||||||||||||||||||||||||
| 133 | name | ||||||||||||||||||||||||||||
| 134 | description | ||||||||||||||||||||||||||||
| 135 | public | ||||||||||||||||||||||||||||
| 136 | default_sort | ||||||||||||||||||||||||||||
| 137 | create_time | ||||||||||||||||||||||||||||
| 138 | update_time | ||||||||||||||||||||||||||||
| 139 | sort_order | ||||||||||||||||||||||||||||
| 140 | icon_id | ||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 1 | __PACKAGE__->mk_accessors(@Members); | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub members { | ||||||||||||||||||||||||||
|
Subroutine
members: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 146 | 0 | @Members; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | package Net::NicoVideo::Content::NicoAPI::MylistItem; | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 153 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 154 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 155 | 1 | $VERSION = '0.28'; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 1 | ▶ | use base qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 158 | 1 | ▶ | use vars qw(@Members); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 159 | 1 | @Members = qw( | |||||||||||||||||||||||||||
| 160 | item_type | ||||||||||||||||||||||||||||
| 161 | item_id | ||||||||||||||||||||||||||||
| 162 | description | ||||||||||||||||||||||||||||
| 163 | item_data | ||||||||||||||||||||||||||||
| 164 | watch | ||||||||||||||||||||||||||||
| 165 | create_time | ||||||||||||||||||||||||||||
| 166 | update_time | ||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 1 | __PACKAGE__->mk_accessors(@Members); | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub members { | ||||||||||||||||||||||||||
|
Subroutine
members: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 172 | 0 | @Members; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | package Net::NicoVideo::Content::NicoAPI::MylistItem::ItemData; | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 179 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 180 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 181 | 1 | $VERSION = '0.28'; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 1 | ▶ | use base qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 184 | 1 | ▶ | use vars qw(@Members); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 185 | 1 | @Members = qw( | |||||||||||||||||||||||||||
| 186 | video_id | ||||||||||||||||||||||||||||
| 187 | title | ||||||||||||||||||||||||||||
| 188 | thumbnail_url | ||||||||||||||||||||||||||||
| 189 | first_retrieve | ||||||||||||||||||||||||||||
| 190 | update_time | ||||||||||||||||||||||||||||
| 191 | view_counter | ||||||||||||||||||||||||||||
| 192 | mylist_counter | ||||||||||||||||||||||||||||
| 193 | num_res | ||||||||||||||||||||||||||||
| 194 | group_type | ||||||||||||||||||||||||||||
| 195 | length_seconds | ||||||||||||||||||||||||||||
| 196 | deleted | ||||||||||||||||||||||||||||
| 197 | last_res_body | ||||||||||||||||||||||||||||
| 198 | watch_id | ||||||||||||||||||||||||||||
| 199 | ); | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 1 | __PACKAGE__->mk_accessors(@Members); | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub members { | ||||||||||||||||||||||||||
|
Subroutine
members: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 204 | 0 | @Members; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 1 | 1; | |||||||||||||||||||||||||||
| 209 | __END__ | ||||||||||||||||||||||||||||