| 1 | package WWW::Spotify; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use Moo 2.002004; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | our $VERSION = '0.017'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | ▶ | use Carp qw( carp ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Data::Dumper qw( Dumper ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use IO::CaptureOutput qw( capture ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use JSON::Path (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use JSON::MaybeXS qw( decode_json encode_json ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use MIME::Base64 qw( encode_base64 ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | ▶ | use Types::Standard qw( Bool InstanceOf Int Str CodeRef ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use HTTP::Status qw( HTTP_OK is_success ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 6 | ▶ | use URI::Escape qw( uri_escape uri_escape_utf8 ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | has 'oauth_authorize_url' => ( | |||||||||||||||||||||||||||||||||||||||||
| 18 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 19 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | default => 'https://accounts.spotify.com/authorize' | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | has 'oauth_token_url' => ( | |||||||||||||||||||||||||||||||||||||||||
| 24 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 26 | default => 'https://accounts.spotify.com/api/token' | ||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | has 'oauth_redirect_uri' => ( | |||||||||||||||||||||||||||||||||||||||||
| 30 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 32 | default => 'http://www.spotify.com' | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | has 'oauth_client_id' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 36 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 37 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | ▶ | default => $ENV{SPOTIFY_CLIENT_ID} || q{} | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'SPOTIFY_CLIENT_ID'} || ''
MC/DC0%0/1
$ENV{'SPOTIFY_CLIENT_ID'} || ''
$ENV{'SPOTIFY_CLIENT_ID'}
Truth table50%1/2
A
A= $ENV{'SPOTIFY_CLIENT_ID'}
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | has 'oauth_client_secret' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 42 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 6 | ▶ | default => $ENV{SPOTIFY_CLIENT_SECRET} || q{} | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'SPOTIFY_CLIENT_SECRET'} || ''
MC/DC0%0/1
$ENV{'SPOTIFY_CLIENT_SECRET'} || ''
$ENV{'SPOTIFY_CLIENT_SECRET'}
Truth table50%1/2
A
A= $ENV{'SPOTIFY_CLIENT_SECRET'}
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | has 'current_oath_code' => ( | |||||||||||||||||||||||||||||||||||||||||
| 48 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 49 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | default => q{} | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | has 'current_access_token' => ( | |||||||||||||||||||||||||||||||||||||||||
| 54 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 55 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | default => q{} | ||||||||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | has 'refresh_token' => ( | |||||||||||||||||||||||||||||||||||||||||
| 60 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 61 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | default => q{} | ||||||||||||||||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 6 | has 'result_format' => ( | |||||||||||||||||||||||||||||||||||||||||
| 66 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 67 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 68 | default => 'json' | ||||||||||||||||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 6 | has 'grab_response_header' => ( | |||||||||||||||||||||||||||||||||||||||||
| 72 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 73 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 6 | has 'results' => ( | |||||||||||||||||||||||||||||||||||||||||
| 78 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 79 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | default => '15' | ||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 6 | has 'debug' => ( | |||||||||||||||||||||||||||||||||||||||||
| 84 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 85 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||
| 86 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 6 | has 'uri_scheme' => ( | |||||||||||||||||||||||||||||||||||||||||
| 90 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 91 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | default => 'https' | ||||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | 6 | has 'current_client_credentials' => ( | |||||||||||||||||||||||||||||||||||||||||
| 96 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 97 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 98 | default => q{} | ||||||||||||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 6 | has 'force_client_auth' => ( | |||||||||||||||||||||||||||||||||||||||||
| 102 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 103 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | default => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 105 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 6 | has 'uri_hostname' => ( | |||||||||||||||||||||||||||||||||||||||||
| 108 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 109 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 110 | default => 'api.spotify.com' | ||||||||||||||||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 6 | has 'uri_domain_path' => ( | |||||||||||||||||||||||||||||||||||||||||
| 114 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 115 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 116 | default => 'api' | ||||||||||||||||||||||||||||||||||||||||||
| 117 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 6 | has 'call_type' => ( | |||||||||||||||||||||||||||||||||||||||||
| 120 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 121 | isa => Str | ||||||||||||||||||||||||||||||||||||||||||
| 122 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 6 | has 'auto_json_decode' => ( | |||||||||||||||||||||||||||||||||||||||||
| 125 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 128 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | has 'last_result' => ( | |||||||||||||||||||||||||||||||||||||||||
| 131 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 132 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 133 | default => q{} | ||||||||||||||||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 6 | has 'last_error' => ( | |||||||||||||||||||||||||||||||||||||||||
| 137 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 138 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | default => q{} | ||||||||||||||||||||||||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 6 | has 'response_headers' => ( | |||||||||||||||||||||||||||||||||||||||||
| 143 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 144 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | default => q{} | ||||||||||||||||||||||||||||||||||||||||||
| 146 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 6 | has 'problem' => ( | |||||||||||||||||||||||||||||||||||||||||
| 149 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 150 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | default => q{} | ||||||||||||||||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | has 'ua' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 155 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 156 | isa => InstanceOf ['LWP::UserAgent'], | ||||||||||||||||||||||||||||||||||||||||||
| 157 | handles => { _mech => 'clone' }, | ||||||||||||||||||||||||||||||||||||||||||
| 158 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | default => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | require WWW::Mechanize; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | WWW::Mechanize->new( autocheck => 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 162 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | ); | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 6 | has 'response_status' => ( | |||||||||||||||||||||||||||||||||||||||||
| 166 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 167 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||
| 168 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 6 | has 'response_content_type' => ( | |||||||||||||||||||||||||||||||||||||||||
| 172 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 173 | isa => Str, | ||||||||||||||||||||||||||||||||||||||||||
| 174 | default => q{} | ||||||||||||||||||||||||||||||||||||||||||
| 175 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 6 | has 'custom_request_handler' => ( | |||||||||||||||||||||||||||||||||||||||||
| 178 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 179 | isa => CodeRef, | ||||||||||||||||||||||||||||||||||||||||||
| 180 | predicate => '_has_custom_request_handler', | ||||||||||||||||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 6 | has 'custom_request_handler_result' => ( | |||||||||||||||||||||||||||||||||||||||||
| 184 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 185 | writer => '_set_custom_request_handler_result' | ||||||||||||||||||||||||||||||||||||||||||
| 186 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 6 | has 'die_on_response_error' => ( | |||||||||||||||||||||||||||||||||||||||||
| 189 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 190 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 192 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 6 | has 'token_expires_at' => ( | |||||||||||||||||||||||||||||||||||||||||
| 195 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 196 | isa => Int, | ||||||||||||||||||||||||||||||||||||||||||
| 197 | default => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 198 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 6 | my @api_call_options = ( | |||||||||||||||||||||||||||||||||||||||||
| 201 | { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | path => '/v1/albums/{id}', | ||||||||||||||||||||||||||||||||||||||||||
| 203 | info => 'Get an album', | ||||||||||||||||||||||||||||||||||||||||||
| 204 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 205 | method => 'album' | ||||||||||||||||||||||||||||||||||||||||||
| 206 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | { | ||||||||||||||||||||||||||||||||||||||||||
| 209 | path => '/v1/audiobooks/{id}', | ||||||||||||||||||||||||||||||||||||||||||
| 210 | info => 'Get an audiobook', | ||||||||||||||||||||||||||||||||||||||||||
| 211 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 212 | method => 'get_audiobook', | ||||||||||||||||||||||||||||||||||||||||||
| 213 | params => ['market'] | ||||||||||||||||||||||||||||||||||||||||||
| 214 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||||||||||||||||
| 217 | path => '/v1/audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 218 | info => 'Get several audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 219 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 220 | method => 'get_several_audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 221 | params => [ 'ids', 'market' ] | ||||||||||||||||||||||||||||||||||||||||||
| 222 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | path => '/v1/audiobooks/{id}/chapters', | ||||||||||||||||||||||||||||||||||||||||||
| 226 | info => 'Get Audiobook Chapters', | ||||||||||||||||||||||||||||||||||||||||||
| 227 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 228 | method => 'get_audiobook_chapters', | ||||||||||||||||||||||||||||||||||||||||||
| 229 | params => [ 'id', 'market', 'limit', 'offset' ] | ||||||||||||||||||||||||||||||||||||||||||
| 230 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||||||||||||||||
| 233 | path => '/v1/me/audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 234 | info => 'Get User\'s Saved Audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 235 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 236 | method => 'get_users_saved_audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 237 | params => [ 'limit', 'offset' ] | ||||||||||||||||||||||||||||||||||||||||||
| 238 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | { | ||||||||||||||||||||||||||||||||||||||||||
| 241 | path => '/v1/me/audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 242 | info => 'Save Audiobooks for Current User', | ||||||||||||||||||||||||||||||||||||||||||
| 243 | type => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||
| 244 | method => 'save_audiobooks_for_current_user', | ||||||||||||||||||||||||||||||||||||||||||
| 245 | params => ['ids'] | ||||||||||||||||||||||||||||||||||||||||||
| 246 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | { | ||||||||||||||||||||||||||||||||||||||||||
| 249 | path => '/v1/me/audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 250 | info => 'Remove User\'s Saved Audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 251 | type => 'DELETE', | ||||||||||||||||||||||||||||||||||||||||||
| 252 | method => 'remove_users_saved_audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 253 | params => ['ids'] | ||||||||||||||||||||||||||||||||||||||||||
| 254 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | { | ||||||||||||||||||||||||||||||||||||||||||
| 257 | path => '/v1/me/audiobooks/contains', | ||||||||||||||||||||||||||||||||||||||||||
| 258 | info => 'Check User\'s Saved Audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 259 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 260 | method => 'check_users_saved_audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 261 | params => ['ids'] | ||||||||||||||||||||||||||||||||||||||||||
| 262 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | { | ||||||||||||||||||||||||||||||||||||||||||
| 265 | path => '/v1/me/shows', | ||||||||||||||||||||||||||||||||||||||||||
| 266 | info => 'Get User\'s Saved Shows', | ||||||||||||||||||||||||||||||||||||||||||
| 267 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 268 | method => 'get_users_saved_shows', | ||||||||||||||||||||||||||||||||||||||||||
| 269 | params => [ 'limit', 'offset' ] | ||||||||||||||||||||||||||||||||||||||||||
| 270 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | { | ||||||||||||||||||||||||||||||||||||||||||
| 273 | path => '/v1/me/shows', | ||||||||||||||||||||||||||||||||||||||||||
| 274 | info => 'Save Shows for Current User', | ||||||||||||||||||||||||||||||||||||||||||
| 275 | type => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||
| 276 | method => 'save_shows_for_current_user', | ||||||||||||||||||||||||||||||||||||||||||
| 277 | params => ['ids'] | ||||||||||||||||||||||||||||||||||||||||||
| 278 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||
| 281 | path => '/v1/me/shows/contains', | ||||||||||||||||||||||||||||||||||||||||||
| 282 | info => 'Check User\'s Saved Shows', | ||||||||||||||||||||||||||||||||||||||||||
| 283 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 284 | method => 'check_users_saved_shows', | ||||||||||||||||||||||||||||||||||||||||||
| 285 | params => ['ids'] | ||||||||||||||||||||||||||||||||||||||||||
| 286 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | { | ||||||||||||||||||||||||||||||||||||||||||
| 289 | path => '/v1/browse/categories', | ||||||||||||||||||||||||||||||||||||||||||
| 290 | info => 'Get Several Browse Categories', | ||||||||||||||||||||||||||||||||||||||||||
| 291 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 292 | method => 'get_categories', | ||||||||||||||||||||||||||||||||||||||||||
| 293 | params => [ 'country', 'locale', 'limit', 'offset' ] | ||||||||||||||||||||||||||||||||||||||||||
| 294 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | { | ||||||||||||||||||||||||||||||||||||||||||
| 297 | path => '/v1/browse/categories/{category_id}', | ||||||||||||||||||||||||||||||||||||||||||
| 298 | info => 'Get Single Browse Category', | ||||||||||||||||||||||||||||||||||||||||||
| 299 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 300 | method => 'get_category', | ||||||||||||||||||||||||||||||||||||||||||
| 301 | params => [ 'category_id', 'locale' ] | ||||||||||||||||||||||||||||||||||||||||||
| 302 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | path => '/v1/chapters/{id}', | ||||||||||||||||||||||||||||||||||||||||||
| 306 | info => 'Get a Chapter', | ||||||||||||||||||||||||||||||||||||||||||
| 307 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 308 | method => 'get_chapter', | ||||||||||||||||||||||||||||||||||||||||||
| 309 | params => [ 'id', 'market' ] | ||||||||||||||||||||||||||||||||||||||||||
| 310 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | path => '/v1/chapters', | ||||||||||||||||||||||||||||||||||||||||||
| 314 | info => 'Get Several Chapters', | ||||||||||||||||||||||||||||||||||||||||||
| 315 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 316 | method => 'get_several_chapters', | ||||||||||||||||||||||||||||||||||||||||||
| 317 | params => [ 'ids', 'market' ] | ||||||||||||||||||||||||||||||||||||||||||
| 318 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | { | ||||||||||||||||||||||||||||||||||||||||||
| 321 | path => '/v1/recommendations/available-genre-seeds', | ||||||||||||||||||||||||||||||||||||||||||
| 322 | info => 'Get Available Genre Seeds', | ||||||||||||||||||||||||||||||||||||||||||
| 323 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 324 | method => 'get_available_genre_seeds' | ||||||||||||||||||||||||||||||||||||||||||
| 325 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | { | ||||||||||||||||||||||||||||||||||||||||||
| 328 | path => '/v1/markets', | ||||||||||||||||||||||||||||||||||||||||||
| 329 | info => 'Get Available Markets', | ||||||||||||||||||||||||||||||||||||||||||
| 330 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 331 | method => 'get_available_markets' | ||||||||||||||||||||||||||||||||||||||||||
| 332 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | path => '/v1/shows/{id}', | ||||||||||||||||||||||||||||||||||||||||||
| 336 | info => 'Get a Show', | ||||||||||||||||||||||||||||||||||||||||||
| 337 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 338 | method => 'get_show', | ||||||||||||||||||||||||||||||||||||||||||
| 339 | params => ['market'] | ||||||||||||||||||||||||||||||||||||||||||
| 340 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | { | ||||||||||||||||||||||||||||||||||||||||||
| 343 | path => '/v1/shows', | ||||||||||||||||||||||||||||||||||||||||||
| 344 | info => 'Get Several Shows', | ||||||||||||||||||||||||||||||||||||||||||
| 345 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 346 | method => 'get_several_shows', | ||||||||||||||||||||||||||||||||||||||||||
| 347 | params => [ 'ids', 'market' ] | ||||||||||||||||||||||||||||||||||||||||||
| 348 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | { | ||||||||||||||||||||||||||||||||||||||||||
| 351 | path => '/v1/shows/{id}/episodes', | ||||||||||||||||||||||||||||||||||||||||||
| 352 | info => 'Get Show Episodes', | ||||||||||||||||||||||||||||||||||||||||||
| 353 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 354 | method => 'get_show_episodes', | ||||||||||||||||||||||||||||||||||||||||||
| 355 | params => [ 'id', 'market', 'limit', 'offset' ] | ||||||||||||||||||||||||||||||||||||||||||
| 356 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | { | ||||||||||||||||||||||||||||||||||||||||||
| 359 | path => '/v1/albums?ids={ids}', | ||||||||||||||||||||||||||||||||||||||||||
| 360 | info => 'Get several albums', | ||||||||||||||||||||||||||||||||||||||||||
| 361 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 362 | method => 'albums', | ||||||||||||||||||||||||||||||||||||||||||
| 363 | params => [ 'limit', 'offset' ] | ||||||||||||||||||||||||||||||||||||||||||
| 364 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | { | ||||||||||||||||||||||||||||||||||||||||||
| 367 | path => '/v1/playlists/{playlist_id}', | ||||||||||||||||||||||||||||||||||||||||||
| 368 | info => 'Get a playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 369 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 370 | method => 'get_playlist' | ||||||||||||||||||||||||||||||||||||||||||
| 371 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | { | ||||||||||||||||||||||||||||||||||||||||||
| 374 | path => '/v1/playlists/{playlist_id}/items', | ||||||||||||||||||||||||||||||||||||||||||
| 375 | info => 'Get playlist items', | ||||||||||||||||||||||||||||||||||||||||||
| 376 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 377 | method => 'get_playlist_items', | ||||||||||||||||||||||||||||||||||||||||||
| 378 | params => [ 'limit', 'offset', 'market', 'fields' ] | ||||||||||||||||||||||||||||||||||||||||||
| 379 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | { | ||||||||||||||||||||||||||||||||||||||||||
| 382 | path => '/v1/me/playlists', | ||||||||||||||||||||||||||||||||||||||||||
| 383 | info => 'Create a playlist for the current user', | ||||||||||||||||||||||||||||||||||||||||||
| 384 | type => 'POST', | ||||||||||||||||||||||||||||||||||||||||||
| 385 | method => 'create_playlist' | ||||||||||||||||||||||||||||||||||||||||||
| 386 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | { | ||||||||||||||||||||||||||||||||||||||||||
| 389 | path => '/v1/me/playlists', | ||||||||||||||||||||||||||||||||||||||||||
| 390 | info => 'Get current user\'s playlists', | ||||||||||||||||||||||||||||||||||||||||||
| 391 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 392 | method => 'get_current_user_playlists', | ||||||||||||||||||||||||||||||||||||||||||
| 393 | params => [ 'limit', 'offset' ] | ||||||||||||||||||||||||||||||||||||||||||
| 394 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | { | ||||||||||||||||||||||||||||||||||||||||||
| 397 | path => '/v1/playlists/{playlist_id}/items', | ||||||||||||||||||||||||||||||||||||||||||
| 398 | info => 'Add items to a playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 399 | type => 'POST', | ||||||||||||||||||||||||||||||||||||||||||
| 400 | method => 'add_items_to_playlist' | ||||||||||||||||||||||||||||||||||||||||||
| 401 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | { | ||||||||||||||||||||||||||||||||||||||||||
| 404 | path => '/v1/playlists/{playlist_id}/followers', | ||||||||||||||||||||||||||||||||||||||||||
| 405 | info => 'Unfollow (remove) a playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 406 | type => 'DELETE', | ||||||||||||||||||||||||||||||||||||||||||
| 407 | method => 'unfollow_playlist' | ||||||||||||||||||||||||||||||||||||||||||
| 408 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||||||||||||
| 411 | path => '/v1/me/tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 412 | info => 'Remove User\'s Saved Tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 413 | type => 'DELETE', | ||||||||||||||||||||||||||||||||||||||||||
| 414 | method => 'remove_user_saved_tracks' | ||||||||||||||||||||||||||||||||||||||||||
| 415 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | { | ||||||||||||||||||||||||||||||||||||||||||
| 418 | path => '/v1/me/tracks/contains', | ||||||||||||||||||||||||||||||||||||||||||
| 419 | info => 'Check User\'s Saved Tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 420 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 421 | method => 'check_users_saved_tracks' | ||||||||||||||||||||||||||||||||||||||||||
| 422 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | { | ||||||||||||||||||||||||||||||||||||||||||
| 425 | path => '/v1/audio-features', | ||||||||||||||||||||||||||||||||||||||||||
| 426 | info => 'Get Several Tracks\' Audio Features', | ||||||||||||||||||||||||||||||||||||||||||
| 427 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 428 | method => 'get_several_tracks_audio_features' | ||||||||||||||||||||||||||||||||||||||||||
| 429 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||
| 431 | { | ||||||||||||||||||||||||||||||||||||||||||
| 432 | path => '/v1/audio-features/{id}', | ||||||||||||||||||||||||||||||||||||||||||
| 433 | info => 'Get Track\'s Audio Features', | ||||||||||||||||||||||||||||||||||||||||||
| 434 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 435 | method => 'get_track_audio_features' | ||||||||||||||||||||||||||||||||||||||||||
| 436 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | { | ||||||||||||||||||||||||||||||||||||||||||
| 439 | path => '/v1/audio-analysis/{id}', | ||||||||||||||||||||||||||||||||||||||||||
| 440 | info => 'Get Track\'s Audio Analysis', | ||||||||||||||||||||||||||||||||||||||||||
| 441 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 442 | method => 'get_track_audio_analysis' | ||||||||||||||||||||||||||||||||||||||||||
| 443 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | { | ||||||||||||||||||||||||||||||||||||||||||
| 446 | path => '/v1/recommendations', | ||||||||||||||||||||||||||||||||||||||||||
| 447 | info => 'Get Recommendations', | ||||||||||||||||||||||||||||||||||||||||||
| 448 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 449 | method => 'get_recommendations', | ||||||||||||||||||||||||||||||||||||||||||
| 450 | params => [ | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 'seed_artists', 'seed_genres', 'seed_tracks', 'limit', 'market' | ||||||||||||||||||||||||||||||||||||||||||
| 452 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 453 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | { | ||||||||||||||||||||||||||||||||||||||||||
| 456 | path => '/v1/me/following', | ||||||||||||||||||||||||||||||||||||||||||
| 457 | info => 'Get Followed Artists', | ||||||||||||||||||||||||||||||||||||||||||
| 458 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 459 | method => 'get_followed_artists', | ||||||||||||||||||||||||||||||||||||||||||
| 460 | params => [ 'type', 'after', 'limit' ] | ||||||||||||||||||||||||||||||||||||||||||
| 461 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | { | ||||||||||||||||||||||||||||||||||||||||||
| 464 | path => '/v1/me/following', | ||||||||||||||||||||||||||||||||||||||||||
| 465 | info => 'Follow Artists or Users', | ||||||||||||||||||||||||||||||||||||||||||
| 466 | type => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||
| 467 | method => 'follow_artists_or_users', | ||||||||||||||||||||||||||||||||||||||||||
| 468 | params => [ 'type', 'ids' ] | ||||||||||||||||||||||||||||||||||||||||||
| 469 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | { | ||||||||||||||||||||||||||||||||||||||||||
| 472 | path => '/v1/me/following', | ||||||||||||||||||||||||||||||||||||||||||
| 473 | info => 'Unfollow Artists or Users', | ||||||||||||||||||||||||||||||||||||||||||
| 474 | type => 'DELETE', | ||||||||||||||||||||||||||||||||||||||||||
| 475 | method => 'unfollow_artists_or_users', | ||||||||||||||||||||||||||||||||||||||||||
| 476 | params => [ 'type', 'ids' ] | ||||||||||||||||||||||||||||||||||||||||||
| 477 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | { | ||||||||||||||||||||||||||||||||||||||||||
| 480 | path => '/v1/me/following/contains', | ||||||||||||||||||||||||||||||||||||||||||
| 481 | info => 'Check if Current User Follows Artists or Users', | ||||||||||||||||||||||||||||||||||||||||||
| 482 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 483 | method => 'check_if_user_follows_artists_or_users', | ||||||||||||||||||||||||||||||||||||||||||
| 484 | params => [ 'type', 'ids' ] | ||||||||||||||||||||||||||||||||||||||||||
| 485 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | { | ||||||||||||||||||||||||||||||||||||||||||
| 488 | path => '/v1/playlists/{playlist_id}/followers/contains', | ||||||||||||||||||||||||||||||||||||||||||
| 489 | info => 'Check if Current User Follows Playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 490 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 491 | method => 'check_if_user_follows_playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 492 | params => [ 'playlist_id', 'ids' ] | ||||||||||||||||||||||||||||||||||||||||||
| 493 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | { | ||||||||||||||||||||||||||||||||||||||||||
| 496 | path => '/v1/albums/{id}/tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 497 | info => q{Get an album's tracks}, | ||||||||||||||||||||||||||||||||||||||||||
| 498 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 499 | method => 'albums_tracks' | ||||||||||||||||||||||||||||||||||||||||||
| 500 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | { | ||||||||||||||||||||||||||||||||||||||||||
| 503 | path => '/v1/artists/{id}', | ||||||||||||||||||||||||||||||||||||||||||
| 504 | info => 'Get an artist', | ||||||||||||||||||||||||||||||||||||||||||
| 505 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 506 | method => 'artist' | ||||||||||||||||||||||||||||||||||||||||||
| 507 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | { | ||||||||||||||||||||||||||||||||||||||||||
| 510 | path => '/v1/artists?ids={ids}', | ||||||||||||||||||||||||||||||||||||||||||
| 511 | info => 'Get several artists', | ||||||||||||||||||||||||||||||||||||||||||
| 512 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 513 | method => 'artists' | ||||||||||||||||||||||||||||||||||||||||||
| 514 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | { | ||||||||||||||||||||||||||||||||||||||||||
| 517 | path => '/v1/artists/{id}/albums', | ||||||||||||||||||||||||||||||||||||||||||
| 518 | info => q{Get an artist's albums}, | ||||||||||||||||||||||||||||||||||||||||||
| 519 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 520 | method => 'artist_albums', | ||||||||||||||||||||||||||||||||||||||||||
| 521 | params => [ 'limit', 'offset', 'country', 'album_type' ] | ||||||||||||||||||||||||||||||||||||||||||
| 522 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | { | ||||||||||||||||||||||||||||||||||||||||||
| 525 | path => '/v1/artists/{id}/top-tracks?country={country}', | ||||||||||||||||||||||||||||||||||||||||||
| 526 | info => q{Get an artist's top tracks}, | ||||||||||||||||||||||||||||||||||||||||||
| 527 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 528 | method => 'artist_top_tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 529 | params => ['country'] | ||||||||||||||||||||||||||||||||||||||||||
| 530 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | { | ||||||||||||||||||||||||||||||||||||||||||
| 533 | path => '/v1/artists/{id}/related-artists', | ||||||||||||||||||||||||||||||||||||||||||
| 534 | info => q{Get an artist's related artists}, | ||||||||||||||||||||||||||||||||||||||||||
| 535 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 536 | method => 'artist_related_artists', | ||||||||||||||||||||||||||||||||||||||||||
| 537 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | # adding q and type to url unlike example since they are both required | ||||||||||||||||||||||||||||||||||||||||||
| 540 | { | ||||||||||||||||||||||||||||||||||||||||||
| 541 | path => '/v1/search?q={q}&type={type}', | ||||||||||||||||||||||||||||||||||||||||||
| 542 | info => 'Search for an item', | ||||||||||||||||||||||||||||||||||||||||||
| 543 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 544 | method => 'search', | ||||||||||||||||||||||||||||||||||||||||||
| 545 | params => [ 'limit', 'offset', 'q', 'type' ] | ||||||||||||||||||||||||||||||||||||||||||
| 546 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | { | ||||||||||||||||||||||||||||||||||||||||||
| 549 | path => '/v1/tracks/{id}', | ||||||||||||||||||||||||||||||||||||||||||
| 550 | info => 'Get a track', | ||||||||||||||||||||||||||||||||||||||||||
| 551 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 552 | method => 'track' | ||||||||||||||||||||||||||||||||||||||||||
| 553 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | { | ||||||||||||||||||||||||||||||||||||||||||
| 556 | path => '/v1/tracks?ids={ids}', | ||||||||||||||||||||||||||||||||||||||||||
| 557 | info => 'Get several tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 558 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 559 | method => 'tracks' | ||||||||||||||||||||||||||||||||||||||||||
| 560 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||
| 562 | { | ||||||||||||||||||||||||||||||||||||||||||
| 563 | path => '/v1/users/{user_id}', | ||||||||||||||||||||||||||||||||||||||||||
| 564 | info => q{Get a user's profile}, | ||||||||||||||||||||||||||||||||||||||||||
| 565 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 566 | method => 'user' | ||||||||||||||||||||||||||||||||||||||||||
| 567 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | { | ||||||||||||||||||||||||||||||||||||||||||
| 570 | path => '/v1/me', | ||||||||||||||||||||||||||||||||||||||||||
| 571 | info => q{Get current user's profile}, | ||||||||||||||||||||||||||||||||||||||||||
| 572 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 573 | method => 'me' | ||||||||||||||||||||||||||||||||||||||||||
| 574 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | { | ||||||||||||||||||||||||||||||||||||||||||
| 577 | path => '/v1/users/{user_id}/playlists', | ||||||||||||||||||||||||||||||||||||||||||
| 578 | info => q{Get a list of a user's playlists}, | ||||||||||||||||||||||||||||||||||||||||||
| 579 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 580 | method => 'user_playlist' | ||||||||||||||||||||||||||||||||||||||||||
| 581 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | { | ||||||||||||||||||||||||||||||||||||||||||
| 584 | path => '/v1/browse/featured-playlists', | ||||||||||||||||||||||||||||||||||||||||||
| 585 | info => 'Get a list of featured playlists', | ||||||||||||||||||||||||||||||||||||||||||
| 586 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 587 | method => 'browse_featured_playlists' | ||||||||||||||||||||||||||||||||||||||||||
| 588 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | { | ||||||||||||||||||||||||||||||||||||||||||
| 591 | path => '/v1/browse/new-releases', | ||||||||||||||||||||||||||||||||||||||||||
| 592 | info => 'Get a list of new releases', | ||||||||||||||||||||||||||||||||||||||||||
| 593 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 594 | method => 'browse_new_releases' | ||||||||||||||||||||||||||||||||||||||||||
| 595 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | # February 2026 consolidated library endpoints. These take Spotify | ||||||||||||||||||||||||||||||||||||||||||
| 598 | # URIs (spotify:track:{id}, spotify:show:{id}, ...) rather than bare | ||||||||||||||||||||||||||||||||||||||||||
| 599 | # ids, passed as a "uris" query parameter on every verb. | ||||||||||||||||||||||||||||||||||||||||||
| 600 | { | ||||||||||||||||||||||||||||||||||||||||||
| 601 | path => '/v1/me/library?uris={uris}', | ||||||||||||||||||||||||||||||||||||||||||
| 602 | info => 'Save Items to Library', | ||||||||||||||||||||||||||||||||||||||||||
| 603 | type => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||
| 604 | method => 'save_library_items', | ||||||||||||||||||||||||||||||||||||||||||
| 605 | params => ['uris'] | ||||||||||||||||||||||||||||||||||||||||||
| 606 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | { | ||||||||||||||||||||||||||||||||||||||||||
| 609 | path => '/v1/me/library?uris={uris}', | ||||||||||||||||||||||||||||||||||||||||||
| 610 | info => 'Remove Items from Library', | ||||||||||||||||||||||||||||||||||||||||||
| 611 | type => 'DELETE', | ||||||||||||||||||||||||||||||||||||||||||
| 612 | method => 'remove_library_items', | ||||||||||||||||||||||||||||||||||||||||||
| 613 | params => ['uris'] | ||||||||||||||||||||||||||||||||||||||||||
| 614 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | { | ||||||||||||||||||||||||||||||||||||||||||
| 617 | path => '/v1/me/library/contains?uris={uris}', | ||||||||||||||||||||||||||||||||||||||||||
| 618 | info => 'Check Items in Library', | ||||||||||||||||||||||||||||||||||||||||||
| 619 | type => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 620 | method => 'check_library_items', | ||||||||||||||||||||||||||||||||||||||||||
| 621 | params => ['uris'] | ||||||||||||||||||||||||||||||||||||||||||
| 622 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 623 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | # Methods whose endpoints were removed or consolidated by Spotify's | ||||||||||||||||||||||||||||||||||||||||||
| 626 | # February 2026 API changes (plus the November 2024 deprecations). The | ||||||||||||||||||||||||||||||||||||||||||
| 627 | # methods are kept for backwards compatibility; calling one warns once | ||||||||||||||||||||||||||||||||||||||||||
| 628 | # per process and the request is still sent (Spotify will reject it). | ||||||||||||||||||||||||||||||||||||||||||
| 629 | 6 | my %method_deprecated = ( | |||||||||||||||||||||||||||||||||||||||||
| 630 | albums => | ||||||||||||||||||||||||||||||||||||||||||
| 631 | 'GET /v1/albums?ids= removed Feb 2026; fetch albums individually with album()', | ||||||||||||||||||||||||||||||||||||||||||
| 632 | artists => | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 'GET /v1/artists?ids= removed Feb 2026; fetch artists individually with artist()', | ||||||||||||||||||||||||||||||||||||||||||
| 634 | tracks => | ||||||||||||||||||||||||||||||||||||||||||
| 635 | 'GET /v1/tracks?ids= removed Feb 2026; fetch tracks individually with track()', | ||||||||||||||||||||||||||||||||||||||||||
| 636 | get_several_shows => | ||||||||||||||||||||||||||||||||||||||||||
| 637 | 'GET /v1/shows removed Feb 2026; use get_show() per id', | ||||||||||||||||||||||||||||||||||||||||||
| 638 | get_several_audiobooks => | ||||||||||||||||||||||||||||||||||||||||||
| 639 | 'GET /v1/audiobooks removed Feb 2026; use get_audiobook() per id', | ||||||||||||||||||||||||||||||||||||||||||
| 640 | get_several_chapters => | ||||||||||||||||||||||||||||||||||||||||||
| 641 | 'GET /v1/chapters removed Feb 2026; use get_chapter() per id', | ||||||||||||||||||||||||||||||||||||||||||
| 642 | get_several_tracks_audio_features => | ||||||||||||||||||||||||||||||||||||||||||
| 643 | 'GET /v1/audio-features removed Feb 2026', | ||||||||||||||||||||||||||||||||||||||||||
| 644 | get_track_audio_features => | ||||||||||||||||||||||||||||||||||||||||||
| 645 | 'GET /v1/audio-features/{id} deprecated by Spotify (Nov 2024)', | ||||||||||||||||||||||||||||||||||||||||||
| 646 | get_track_audio_analysis => | ||||||||||||||||||||||||||||||||||||||||||
| 647 | 'GET /v1/audio-analysis/{id} deprecated by Spotify (Nov 2024)', | ||||||||||||||||||||||||||||||||||||||||||
| 648 | get_recommendations => | ||||||||||||||||||||||||||||||||||||||||||
| 649 | 'GET /v1/recommendations deprecated by Spotify (Nov 2024)', | ||||||||||||||||||||||||||||||||||||||||||
| 650 | get_available_genre_seeds => | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 'GET /v1/recommendations/available-genre-seeds removed', | ||||||||||||||||||||||||||||||||||||||||||
| 652 | browse_featured_playlists => | ||||||||||||||||||||||||||||||||||||||||||
| 653 | 'GET /v1/browse/featured-playlists removed by Spotify (Nov 2024)', | ||||||||||||||||||||||||||||||||||||||||||
| 654 | browse_new_releases => 'GET /v1/browse/new-releases removed Feb 2026', | ||||||||||||||||||||||||||||||||||||||||||
| 655 | get_categories => 'GET /v1/browse/categories removed Feb 2026', | ||||||||||||||||||||||||||||||||||||||||||
| 656 | get_category => 'GET /v1/browse/categories/{id} removed Feb 2026', | ||||||||||||||||||||||||||||||||||||||||||
| 657 | artist_top_tracks => 'GET /v1/artists/{id}/top-tracks removed Feb 2026', | ||||||||||||||||||||||||||||||||||||||||||
| 658 | artist_related_artists => | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 'GET /v1/artists/{id}/related-artists removed by Spotify (Nov 2024)', | ||||||||||||||||||||||||||||||||||||||||||
| 660 | user => 'GET /v1/users/{user_id} deprecated/removed Feb 2026', | ||||||||||||||||||||||||||||||||||||||||||
| 661 | remove_user_saved_tracks => | ||||||||||||||||||||||||||||||||||||||||||
| 662 | 'DELETE /v1/me/tracks removed Feb 2026; use remove_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 663 | check_users_saved_tracks => | ||||||||||||||||||||||||||||||||||||||||||
| 664 | 'GET /v1/me/tracks/contains removed Feb 2026; use check_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 665 | save_shows_for_current_user => | ||||||||||||||||||||||||||||||||||||||||||
| 666 | 'PUT /v1/me/shows removed Feb 2026; use save_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 667 | check_users_saved_shows => | ||||||||||||||||||||||||||||||||||||||||||
| 668 | 'GET /v1/me/shows/contains removed Feb 2026; use check_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 669 | save_audiobooks_for_current_user => | ||||||||||||||||||||||||||||||||||||||||||
| 670 | 'PUT /v1/me/audiobooks removed Feb 2026; use save_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 671 | remove_users_saved_audiobooks => | ||||||||||||||||||||||||||||||||||||||||||
| 672 | 'DELETE /v1/me/audiobooks removed Feb 2026; use remove_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 673 | check_users_saved_audiobooks => | ||||||||||||||||||||||||||||||||||||||||||
| 674 | 'GET /v1/me/audiobooks/contains removed Feb 2026; use check_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 675 | follow_artists_or_users => | ||||||||||||||||||||||||||||||||||||||||||
| 676 | 'PUT /v1/me/following removed Feb 2026; use save_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 677 | unfollow_artists_or_users => | ||||||||||||||||||||||||||||||||||||||||||
| 678 | 'DELETE /v1/me/following removed Feb 2026; use remove_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 679 | check_if_user_follows_artists_or_users => | ||||||||||||||||||||||||||||||||||||||||||
| 680 | 'GET /v1/me/following/contains removed Feb 2026; use check_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 681 | check_if_user_follows_playlist => | ||||||||||||||||||||||||||||||||||||||||||
| 682 | 'GET /v1/playlists/{id}/followers/contains removed Feb 2026; use check_library_items()', | ||||||||||||||||||||||||||||||||||||||||||
| 683 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | 6 | my %deprecation_warned; | |||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | 6 | my %method_to_uri = (); | |||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | 6 | foreach my $entry (@api_call_options) { | |||||||||||||||||||||||||||||||||||||||||
| 690 | 330 | ▶ | next if $entry->{method} eq q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 691 | warn | ||||||||||||||||||||||||||||||||||||||||||
| 692 | "WWW::Spotify: duplicate method '$entry->{method}' in \@api_call_options\n" | ||||||||||||||||||||||||||||||||||||||||||
| 693 | 330 | ▶ | if exists $method_to_uri{ $entry->{method} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 330 | $method_to_uri{ $entry->{method} } = $entry->{path}; | |||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | # _build_url: construct the request URL from an attributes hashref. | ||||||||||||||||||||||||||||||||||||||||||
| 698 | # | ||||||||||||||||||||||||||||||||||||||||||
| 699 | # For send_get_request the URL-building logic is richer (query_full_url | ||||||||||||||||||||||||||||||||||||||||||
| 700 | # passthrough, search substitution, extras appended as query params). That | ||||||||||||||||||||||||||||||||||||||||||
| 701 | # full logic stays in send_get_request. _build_url handles the simpler | ||||||||||||||||||||||||||||||||||||||||||
| 702 | # pattern shared by POST / PUT / DELETE. | ||||||||||||||||||||||||||||||||||||||||||
| 703 | sub _build_url { | ||||||||||||||||||||||||||||||||||||||||||
| 704 | 18 | ▶ | my ( $self, $attributes ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_url: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | 18 | my $url = $self->uri_scheme() . '://' . $self->uri_hostname(); | |||||||||||||||||||||||||||||||||||||||||
| 707 | 18 | my $path = $method_to_uri{ $attributes->{method} }; | |||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||
| 709 | # Params consumed by a {placeholder} in the path are removed from | ||||||||||||||||||||||||||||||||||||||||||
| 710 | # %unused so the request body only carries what the URL did not. | ||||||||||||||||||||||||||||||||||||||||||
| 711 | 18 | ▶ | my %unused = %{ $attributes->{params} || {} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | 18 | ▶ | if ($path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | 18 | my ( $path_part, $query_part ) = split /\?/, $path, 2; | |||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | # Path-segment placeholders: fully escape the value. | ||||||||||||||||||||||||||||||||||||||||||
| 717 | 18 | $path_part =~ s/\{([^}]+)\}/ | |||||||||||||||||||||||||||||||||||||||||
| 718 | 6 | my $v = delete $unused{$1}; | |||||||||||||||||||||||||||||||||||||||||
| 719 | 6 | ▶ | defined $v ? uri_escape($v) : q{} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | /ge; | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | 18 | ▶ | if ( defined $query_part ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | # Query-string placeholders: substitute raw. Callers are | ||||||||||||||||||||||||||||||||||||||||||
| 725 | # responsible for any encoding needed (e.g. _uris_param pre-escapes | ||||||||||||||||||||||||||||||||||||||||||
| 726 | # Spotify URIs; search() pre-escapes q and type). | ||||||||||||||||||||||||||||||||||||||||||
| 727 | 2 | $query_part =~ s/\{([^}]+)\}/ | |||||||||||||||||||||||||||||||||||||||||
| 728 | 2 | my $v = delete $unused{$1}; | |||||||||||||||||||||||||||||||||||||||||
| 729 | 2 | ▶ | defined $v ? $v : q{} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 730 | /ge; | ||||||||||||||||||||||||||||||||||||||||||
| 731 | 2 | $path = $path_part . '?' . $query_part; | |||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||
| 733 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 734 | 16 | $path = $path_part; | |||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | 18 | $url .= $path; | |||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||
| 740 | 18 | ▶ | warn "$url\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 741 | 18 | ▶ | return wantarray ? ( $url, \%unused ) : $url; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||
| 744 | # _send_request: shared machinery for every HTTP verb. | ||||||||||||||||||||||||||||||||||||||||||
| 745 | # | ||||||||||||||||||||||||||||||||||||||||||
| 746 | # Parameters: | ||||||||||||||||||||||||||||||||||||||||||
| 747 | # $verb - 'get' | 'post' | 'put' | 'delete' | ||||||||||||||||||||||||||||||||||||||||||
| 748 | # $url - fully-formed request URL | ||||||||||||||||||||||||||||||||||||||||||
| 749 | # $attributes - original attributes hashref (used for auth flag) | ||||||||||||||||||||||||||||||||||||||||||
| 750 | # $body - optional request body (undef for GET) | ||||||||||||||||||||||||||||||||||||||||||
| 751 | sub _send_request { | ||||||||||||||||||||||||||||||||||||||||||
| 752 | 50 | ▶ | my ( $self, $verb, $url, $attributes, $body ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_send_request: called CC=12 SCAR=25.3
| |||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | 50 | ▶ | my $method = $attributes->{method} // q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attributes->{"method"} // ""
MC/DC0%0/1
$attributes->{"method"} // ""
$attributes->{"method"}
Truth table50%1/2
A
A= $attributes->{"method"}
| |||||||||||||||||||||||||||||||||||||||||||
| 755 | 50 | ▶ | if ( my $reason = $method_deprecated{$method} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 756 | carp | ||||||||||||||||||||||||||||||||||||||||||
| 757 | "WWW::Spotify: $method() targets a removed/deprecated Spotify endpoint: $reason" | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 16 | ▶ | unless $deprecation_warned{$method}++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | 50 | my $mech = $self->_mech; | |||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | 50 | ▶ | if ( $attributes->{client_auth_required} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$attributes->{"client_auth_required"} or $self->force_client_auth != 0
MC/DC100%2/2
$attributes->{"client_auth_required"} or $self->force_client_auth != 0
$attributes->{"client_auth_required"}
$self->force_client_auth != 0
Truth table100%3/3
A or B
A= $attributes->{"client_auth_required"}B= $self->force_client_auth != 0
| |||||||||||||||||||||||||||||||||||||||||||
| 764 | || $self->force_client_auth() != 0 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 765 | 26 | ▶ | if ( $self->current_access_token() eq q{} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->current_access_token eq "" or time >= $self->token_expires_at
MC/DC50%1/2
$self->current_access_token eq "" or time >= $self->token_expires_at
$self->current_access_token eq ""
time >= $self->token_expires_at
Truth table66%2/3
A or B
A= $self->current_access_token eq ""B= time >= $self->token_expires_at
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | || time() >= $self->token_expires_at() ) { | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 1 | ▶ | warn "Needed to get access token\n" if $self->debug(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 768 | 1 | $self->current_access_token(q{}); | |||||||||||||||||||||||||||||||||||||||||
| 769 | 1 | $self->get_client_credentials(); | |||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||
| 771 | $mech->add_header( | ||||||||||||||||||||||||||||||||||||||||||
| 772 | 26 | 'Authorization' => 'Bearer ' . $self->current_access_token() ); | |||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||
| 775 | 50 | ▶ | if ( defined $body ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 776 | 18 | $mech->add_header( 'Content-Type' => 'application/json' ); | |||||||||||||||||||||||||||||||||||||||||
| 777 | 18 | $mech->$verb( $url, Content => $body ); | |||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||
| 779 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 780 | 32 | $mech->$verb($url); | |||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | 50 | ▶ | if ( $self->grab_response_header() == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | $self->_set_response_headers($mech); | |||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | 50 | $self->response_status( $mech->status() ); | |||||||||||||||||||||||||||||||||||||||||
| 788 | 50 | $self->response_content_type( $mech->content_type() ); | |||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||
| 790 | 50 | ▶ | if ( $self->_has_custom_request_handler() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 791 | 0 | $self->_set_custom_request_handler_result( | |||||||||||||||||||||||||||||||||||||||||
| 792 | $self->custom_request_handler()->($mech) ); | ||||||||||||||||||||||||||||||||||||||||||
| 793 | } | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | 50 | return $mech; | |||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | sub send_post_request { | ||||||||||||||||||||||||||||||||||||||||||
| 799 | 7 | ▶ | my ( $self, $attributes ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_post_request: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | 7 | $self->last_error(q{}); | |||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | 7 | my ( $url, $body_params ) = $self->_build_url($attributes); | |||||||||||||||||||||||||||||||||||||||||
| 804 | 7 | ▶ | my $body = %{$body_params} ? encode_json($body_params) : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 805 | 7 | my $mech = $self->_send_request( 'post', $url, $attributes, $body ); | |||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | 7 | ▶ | if ( $self->response_content_type() =~ /application\/json/i | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->response_content_type =~ m[application/json]i and $self->response_status != 200
MC/DC50%1/2
$self->response_content_type =~ m[application/json]i and $self->response_status != 200
$self->response_content_type =~ m[application/json]i
$self->response_status != 200
Truth table66%2/3
A and B
A= $self->response_content_type =~ m[application/json]iB= $self->response_status != 200
| |||||||||||||||||||||||||||||||||||||||||||
| 808 | && $self->response_status() != HTTP_OK ) { | ||||||||||||||||||||||||||||||||||||||||||
| 809 | 1 | ▶ | warn "content type is ", $self->response_content_type(), "\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 810 | if $self->debug(); | ||||||||||||||||||||||||||||||||||||||||||
| 811 | 1 | $self->last_error( "request failed, status(" | |||||||||||||||||||||||||||||||||||||||||
| 812 | . $self->response_status() | ||||||||||||||||||||||||||||||||||||||||||
| 813 | . ") examine last_result for details" ); | ||||||||||||||||||||||||||||||||||||||||||
| 814 | } | ||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | 7 | ▶ | if ( $self->die_on_response_error() == 1 && $self->last_error ne '' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->die_on_response_error == 1 and $self->last_error ne ""
MC/DC50%1/2
$self->die_on_response_error == 1 and $self->last_error ne ""
$self->die_on_response_error == 1
$self->last_error ne ""
Truth table66%2/3
A and B
A= $self->die_on_response_error == 1B= $self->last_error ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 817 | 1 | die $self->last_error(); | |||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||
| 820 | 6 | return $self->format_results( | |||||||||||||||||||||||||||||||||||||||||
| 821 | $mech->content, $mech->ct(), | ||||||||||||||||||||||||||||||||||||||||||
| 822 | $mech->status() | ||||||||||||||||||||||||||||||||||||||||||
| 823 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 824 | } | ||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||
| 826 | sub send_delete_request { | ||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | # Internal method used to send DELETE requests to the Spotify API. | ||||||||||||||||||||||||||||||||||||||||||
| 829 | 6 | ▶ | my ( $self, $attributes ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_delete_request: called CC=6 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | 6 | $self->last_error(q{}); | |||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||
| 833 | 6 | my ( $url, $body_params ) = $self->_build_url($attributes); | |||||||||||||||||||||||||||||||||||||||||
| 834 | 6 | ▶ | my $body = %{$body_params} ? encode_json($body_params) : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 835 | 6 | my $mech = $self->_send_request( 'delete', $url, $attributes, $body ); | |||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||
| 837 | 6 | ▶ | if ( !is_success( $self->response_status() ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | warn "Delete request failed with status ", $self->response_status(), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 839 | "\n" | ||||||||||||||||||||||||||||||||||||||||||
| 840 | if $self->debug(); | ||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | $self->last_error( "Delete request failed, status(" | |||||||||||||||||||||||||||||||||||||||||
| 842 | . $self->response_status() | ||||||||||||||||||||||||||||||||||||||||||
| 843 | . ") examine last_result for details" ); | ||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | 6 | ▶ | if ( $self->die_on_response_error() == 1 && $self->last_error ne '' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->die_on_response_error == 1 and $self->last_error ne ""
MC/DC0%0/2
$self->die_on_response_error == 1 and $self->last_error ne ""
$self->die_on_response_error == 1
$self->last_error ne ""
Truth table33%1/3
A and B
A= $self->die_on_response_error == 1B= $self->last_error ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | die $self->last_error(); | |||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | 6 | return $self->format_results( | |||||||||||||||||||||||||||||||||||||||||
| 851 | $mech->content, $mech->ct(), | ||||||||||||||||||||||||||||||||||||||||||
| 852 | $mech->status() | ||||||||||||||||||||||||||||||||||||||||||
| 853 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 854 | } | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | sub send_put_request { | ||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | # Internal method used to send PUT requests to the Spotify API. | ||||||||||||||||||||||||||||||||||||||||||
| 859 | 5 | ▶ | my ( $self, $attributes ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_put_request: called CC=6 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | 5 | $self->last_error(q{}); | |||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | 5 | my ( $url, $body_params ) = $self->_build_url($attributes); | |||||||||||||||||||||||||||||||||||||||||
| 864 | 5 | ▶ | my $body = %{$body_params} ? encode_json($body_params) : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 865 | 5 | my $mech = $self->_send_request( 'put', $url, $attributes, $body ); | |||||||||||||||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||||||||||||||||
| 867 | 5 | ▶ | if ( !is_success( $self->response_status() ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | ▶ | warn "Put request failed with status ", $self->response_status(), "\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 869 | if $self->debug(); | ||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | $self->last_error( "Put request failed, status(" | |||||||||||||||||||||||||||||||||||||||||
| 871 | . $self->response_status() | ||||||||||||||||||||||||||||||||||||||||||
| 872 | . ") examine last_result for details" ); | ||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | 5 | ▶ | if ( $self->die_on_response_error() == 1 && $self->last_error ne '' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->die_on_response_error == 1 and $self->last_error ne ""
MC/DC0%0/2
$self->die_on_response_error == 1 and $self->last_error ne ""
$self->die_on_response_error == 1
$self->last_error ne ""
Truth table33%1/3
A and B
A= $self->die_on_response_error == 1B= $self->last_error ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | die $self->last_error(); | |||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | 5 | return $self->format_results( | |||||||||||||||||||||||||||||||||||||||||
| 880 | $mech->content, $mech->ct(), | ||||||||||||||||||||||||||||||||||||||||||
| 881 | $mech->status() | ||||||||||||||||||||||||||||||||||||||||||
| 882 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||
| 885 | sub send_get_request { | ||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||
| 887 | # need to build the URL here | ||||||||||||||||||||||||||||||||||||||||||
| 888 | 32 | ▶ | my ( $self, $attributes ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_get_request: called CC=20 SCAR=30.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | 32 | my $uri_params = q{}; | |||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | # reset last error | ||||||||||||||||||||||||||||||||||||||||||
| 893 | 32 | $self->last_error(q{}); | |||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||
| 895 | 32 | ▶ | if ( defined $attributes->{extras} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $attributes->{"extras"} and ref $attributes->{"extras"} eq "HASH"
MC/DC50%1/2
defined $attributes->{"extras"} and ref $attributes->{"extras"} eq "HASH"
defined $attributes->{"extras"}
ref $attributes->{"extras"} eq "HASH"
Truth table66%2/3
A and B
A= defined $attributes->{"extras"}B= ref $attributes->{"extras"} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 896 | and ref $attributes->{extras} eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 897 | 4 | my @tmp = (); | |||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||
| 899 | 4 | foreach my $key ( keys %{ $attributes->{extras} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 900 | 8 | push @tmp, "$key=" . uri_escape( $attributes->{extras}{$key} ); | |||||||||||||||||||||||||||||||||||||||||
| 901 | } | ||||||||||||||||||||||||||||||||||||||||||
| 902 | 4 | $uri_params = join( '&', @tmp ); | |||||||||||||||||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | 32 | ▶ | if ( exists $attributes->{format} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $attributes->{"format"} and $attributes->{"format"} =~ /json|jsonp/
MC/DC0%0/2
exists $attributes->{"format"} and $attributes->{"format"} =~ /json|jsonp/
exists $attributes->{"format"}
$attributes->{"format"} =~ /json|jsonp/
Truth table33%1/3
A and B
A= exists $attributes->{"format"}B= $attributes->{"format"} =~ /json|jsonp/
| |||||||||||||||||||||||||||||||||||||||||||
| 906 | && $attributes->{format} =~ /json|jsonp/ ) { | ||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | $self->result_format( $attributes->{format} ); | |||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | delete $attributes->{format}; | |||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | 32 | my $url; | |||||||||||||||||||||||||||||||||||||||||
| 912 | 32 | ▶ | if ( $attributes->{method} eq 'query_full_url' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | 2 | $url = $attributes->{url}; | |||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||
| 915 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 916 | 30 | $url = $self->uri_scheme() . '://' . $self->uri_hostname(); | |||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | 30 | my $path = $method_to_uri{ $attributes->{method} }; | |||||||||||||||||||||||||||||||||||||||||
| 919 | 30 | ▶ | if ($path) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | 30 | ▶ | warn "raw: $path" if $self->debug(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||
| 923 | 30 | ▶ | if ( $attributes->{params} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | # Split on '?' so we only uri_escape values that appear in the | ||||||||||||||||||||||||||||||||||||||||||
| 926 | # path segment. Query-string placeholder values (comma-lists, | ||||||||||||||||||||||||||||||||||||||||||
| 927 | # pre-escaped URIs, etc.) must be left as-is. | ||||||||||||||||||||||||||||||||||||||||||
| 928 | 29 | my ( $path_part, $query_part ) = split /\?/, $path, 2; | |||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | 29 | $path_part | |||||||||||||||||||||||||||||||||||||||||
| 931 | 18 | =~ s/\{([^}]+)\}/uri_escape( $attributes->{params}{$1} )/ge; | |||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||
| 933 | 29 | ▶ | if ( defined $query_part ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | # Substitute raw - callers pre-escape what needs escaping. | ||||||||||||||||||||||||||||||||||||||||||
| 936 | 7 | $query_part =~ s/\{([^}]+)\}/$attributes->{params}{$1}/ge; | |||||||||||||||||||||||||||||||||||||||||
| 937 | 7 | $path = $path_part . '?' . $query_part; | |||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||
| 939 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 940 | 22 | $path = $path_part; | |||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||
| 944 | 30 | ▶ | warn "modified: $path\n" if $self->debug(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||
| 947 | 30 | $url .= $path; | |||||||||||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | # append "extras" as query params if present | ||||||||||||||||||||||||||||||||||||||||||
| 951 | 32 | ▶ | if ($uri_params) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 952 | 4 | ▶ | my $start_with = $url =~ /\?/ ? '&' : '?'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 953 | 4 | $url .= $start_with . $uri_params; | |||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||||||||||||
| 956 | 32 | ▶ | warn "$url\n" if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||
| 958 | 32 | my $mech = $self->_send_request( 'get', $url, $attributes, undef ); | |||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | # the original code did not provide adequate built in validation | ||||||||||||||||||||||||||||||||||||||||||
| 961 | # of the response for an API call. | ||||||||||||||||||||||||||||||||||||||||||
| 962 | # Adding a new method (die_on_response_error) with a default of 0 to avoid | ||||||||||||||||||||||||||||||||||||||||||
| 963 | # breaking/changing existing code using older versions of this module. | ||||||||||||||||||||||||||||||||||||||||||
| 964 | 32 | ▶ | if ( $self->response_content_type() =~ /application\/json/i | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->response_content_type =~ m[application/json]i and $self->response_status != 200
MC/DC50%1/2
$self->response_content_type =~ m[application/json]i and $self->response_status != 200
$self->response_content_type =~ m[application/json]i
$self->response_status != 200
Truth table66%2/3
A and B
A= $self->response_content_type =~ m[application/json]iB= $self->response_status != 200
| |||||||||||||||||||||||||||||||||||||||||||
| 965 | && $self->response_status() != HTTP_OK ) { | ||||||||||||||||||||||||||||||||||||||||||
| 966 | 1 | ▶ | warn "content type is ", $self->response_content_type(), "\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 967 | if $self->debug(); | ||||||||||||||||||||||||||||||||||||||||||
| 968 | 1 | $self->last_error( "request failed, status(" | |||||||||||||||||||||||||||||||||||||||||
| 969 | . $self->response_status() | ||||||||||||||||||||||||||||||||||||||||||
| 970 | . ") examine last_result for details" ); | ||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | 32 | ▶ | if ( $self->die_on_response_error() == 1 && $self->last_error ne '' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->die_on_response_error == 1 and $self->last_error ne ""
MC/DC50%1/2
$self->die_on_response_error == 1 and $self->last_error ne ""
$self->die_on_response_error == 1
$self->last_error ne ""
Truth table66%2/3
A and B
A= $self->die_on_response_error == 1B= $self->last_error ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 974 | 1 | die $self->last_error(); | |||||||||||||||||||||||||||||||||||||||||
| 975 | } | ||||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||
| 977 | 31 | return $self->format_results( | |||||||||||||||||||||||||||||||||||||||||
| 978 | $mech->content, $mech->ct(), | ||||||||||||||||||||||||||||||||||||||||||
| 979 | $mech->status() | ||||||||||||||||||||||||||||||||||||||||||
| 980 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 981 | } | ||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||
| 983 | sub _set_response_headers { | ||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_response_headers: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | my $mech = shift; | |||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||
| 987 | 0 | my $hd; | |||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | ▶ | capture { $mech->dump_headers(); } \$hd; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 989 | |||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | $self->response_headers($hd); | |||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||||||||||||||||
| 994 | sub format_results { | ||||||||||||||||||||||||||||||||||||||||||
| 995 | 48 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
format_results: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 996 | 48 | my $content = shift; | |||||||||||||||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||||||||||||||||
| 998 | # want to store the result in case | ||||||||||||||||||||||||||||||||||||||||||
| 999 | # we want to interact with it via a helper method | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | 48 | $self->last_result($content); | |||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 48 | ▶ | if ( $self->auto_json_decode && $self->result_format eq 'json' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->auto_json_decode and $self->result_format eq "json"
MC/DC50%1/2
$self->auto_json_decode and $self->result_format eq "json"
$self->auto_json_decode
$self->result_format eq "json"
Truth table66%2/3
A and B
A= $self->auto_json_decodeB= $self->result_format eq "json"
| |||||||||||||||||||||||||||||||||||||||||||
| 1003 | 2 | my $decoded = eval { decode_json($content) }; | |||||||||||||||||||||||||||||||||||||||||
| 1004 | 2 | ▶ | die "format_results: last_result is not valid JSON: $@\n" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1005 | 1 | return $decoded; | |||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | # results are not altered in this case and would be | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | # json instead of a perl data structure | ||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||
| 1011 | 46 | return $content; | |||||||||||||||||||||||||||||||||||||||||
| 1012 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||
| 1014 | sub get_oauth_authorize { | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_oauth_authorize: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||
| 1017 | # If an OAuth code was previously stored, return it immediately. | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | 2 | ▶ | if ( $self->current_oath_code() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1019 | 1 | return $self->current_oath_code(); | |||||||||||||||||||||||||||||||||||||||||
| 1020 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||
| 1022 | # Return the authorization URL for the caller to redirect the user to. | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | # The old implementation fired this URL server-side (fetching a browser | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | # login page) which was both broken and a security concern - the UA was | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | # bypassing all auth-header machinery and the result was discarded HTML. | ||||||||||||||||||||||||||||||||||||||||||
| 1026 | # authorize_url() builds the same URL correctly with proper URI escaping. | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | 1 | return $self->authorize_url(); | |||||||||||||||||||||||||||||||||||||||||
| 1028 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | sub get_client_credentials { | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_client_credentials: called CC=8 SCAR=21.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1032 | 5 | my $scope = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||
| 1034 | 5 | ▶ | if ( $self->current_access_token() ne q{} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1035 | 0 | return $self->current_access_token(); | |||||||||||||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | 5 | ▶ | if ( $self->oauth_client_id() eq q{} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | die "need to set the client oauth parameters\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1039 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | 5 | $self->_assert_token_url(); | |||||||||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||||||||||
| 1042 | 4 | my $grant_type = 'client_credentials'; | |||||||||||||||||||||||||||||||||||||||||
| 1043 | 4 | my $mech = $self->_mech; | |||||||||||||||||||||||||||||||||||||||||
| 1044 | 4 | my $client_and_secret | |||||||||||||||||||||||||||||||||||||||||
| 1045 | = $self->oauth_client_id() . ':' . $self->oauth_client_secret(); | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | 4 | my $encoded = encode_base64($client_and_secret); | |||||||||||||||||||||||||||||||||||||||||
| 1047 | 4 | my $url = $self->oauth_token_url(); | |||||||||||||||||||||||||||||||||||||||||
| 1048 | |||||||||||||||||||||||||||||||||||||||||||
| 1049 | 4 | my $extra = { grant_type => $grant_type }; | |||||||||||||||||||||||||||||||||||||||||
| 1050 | 4 | ▶ | if ($scope) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | $extra->{scope} = $scope; | |||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||
| 1054 | 4 | chomp($encoded); | |||||||||||||||||||||||||||||||||||||||||
| 1055 | 4 | $encoded =~ s/\n//g; | |||||||||||||||||||||||||||||||||||||||||
| 1056 | 4 | $mech->add_header( 'Authorization' => 'Basic ' . $encoded ); | |||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||
| 1058 | 4 | $mech->post( $url, [$extra] ); | |||||||||||||||||||||||||||||||||||||||||
| 1059 | 4 | my $content = $mech->content(); | |||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||
| 1061 | 4 | my $result = eval { decode_json $content }; | |||||||||||||||||||||||||||||||||||||||||
| 1062 | 4 | ▶ | if ( $result && $result->{'access_token'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$result and $result->{"access_token"}
MC/DC50%1/2
$result and $result->{"access_token"}
$result
$result->{"access_token"}
Truth table66%2/3
A and B
A= $resultB= $result->{"access_token"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1063 | 3 | ▶ | warn "setting access token\n" if $self->debug(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1064 | 3 | $self->current_access_token( $result->{'access_token'} ); | |||||||||||||||||||||||||||||||||||||||||
| 1065 | 3 | ▶ | if ( $result->{'expires_in'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 3 | $self->token_expires_at( time() + $result->{'expires_in'} ); | |||||||||||||||||||||||||||||||||||||||||
| 1067 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | 1 | die "get_client_credentials: failed to obtain access token\n"; | |||||||||||||||||||||||||||||||||||||||||
| 1071 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | sub authorize_url { | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | 3 | ▶ | my ( $self, $args ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
authorize_url: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1076 | 3 | ▶ | $args ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args ||= {}
MC/DC100%1/1
$args ||= {}
$args
Truth table100%2/2
A
A= $args
| |||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||
| 1078 | 3 | my @parts = ( | |||||||||||||||||||||||||||||||||||||||||
| 1079 | 'client_id=' . uri_escape( $self->oauth_client_id() ), | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | 'response_type=code', | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | 'redirect_uri=' . uri_escape( $self->oauth_redirect_uri() ), | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | 3 | ▶ | push @parts, 'scope=' . uri_escape( $args->{scope} ) if $args->{scope}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1084 | 3 | ▶ | push @parts, 'state=' . uri_escape( $args->{state} ) if $args->{state}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||
| 1086 | 3 | return $self->oauth_authorize_url() . '?' . join '&', @parts; | |||||||||||||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||
| 1089 | sub _assert_token_url { | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | 10 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_assert_token_url: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1091 | 10 | ▶ | die "oauth_token_url '${\$self->oauth_token_url}' is not allowed - " | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1092 | . "only https://accounts.spotify.com/ URLs are permitted\n" | ||||||||||||||||||||||||||||||||||||||||||
| 1093 | unless $self->oauth_token_url | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | =~ m{\Ahttps://accounts\.spotify\.com/}i; | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||
| 1097 | sub _request_token { | ||||||||||||||||||||||||||||||||||||||||||
| 1098 | 5 | ▶ | my ( $self, $form ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_request_token: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||
| 1100 | 5 | $self->_assert_token_url(); | |||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||
| 1102 | 4 | my $encoded = encode_base64( | |||||||||||||||||||||||||||||||||||||||||
| 1103 | $self->oauth_client_id() . ':' . $self->oauth_client_secret(), q{} ); | ||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||
| 1105 | 4 | my $mech = $self->_mech; | |||||||||||||||||||||||||||||||||||||||||
| 1106 | 4 | $mech->add_header( 'Authorization' => 'Basic ' . $encoded ); | |||||||||||||||||||||||||||||||||||||||||
| 1107 | 4 | $mech->post( $self->oauth_token_url(), [$form] ); | |||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||
| 1109 | 4 | my $result = eval { decode_json( $mech->content() ) }; | |||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | 4 | ▶ | return 0 unless $result && $result->{access_token}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$result and $result->{"access_token"}
MC/DC50%1/2
$result and $result->{"access_token"}
$result
$result->{"access_token"}
Truth table66%2/3
A and B
A= $resultB= $result->{"access_token"}
| |||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||
| 1113 | 3 | $self->current_access_token( $result->{access_token} ); | |||||||||||||||||||||||||||||||||||||||||
| 1114 | $self->token_expires_at( time() + $result->{expires_in} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1115 | 3 | ▶ | if $result->{expires_in}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1116 | $self->refresh_token( $result->{refresh_token} ) | ||||||||||||||||||||||||||||||||||||||||||
| 1117 | 3 | ▶ | if $result->{refresh_token}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1118 | |||||||||||||||||||||||||||||||||||||||||||
| 1119 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||
| 1122 | sub get_access_token { | ||||||||||||||||||||||||||||||||||||||||||
| 1123 | 3 | ▶ | my ( $self, $code ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_access_token: called CC=3 SCAR=12.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||
| 1125 | 3 | ▶ | die "get_access_token requires an authorization code\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $code and length $code
MC/DC0%0/2
defined $code and length $code
defined $code
length $code
Truth table33%1/3
A and B
A= defined $codeB= length $code
| |||||||||||||||||||||||||||||||||||||||||||
| 1126 | unless defined $code && length $code; | ||||||||||||||||||||||||||||||||||||||||||
| 1127 | |||||||||||||||||||||||||||||||||||||||||||
| 1128 | 3 | return $self->_request_token( | |||||||||||||||||||||||||||||||||||||||||
| 1129 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1130 | grant_type => 'authorization_code', | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | code => $code, | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | redirect_uri => $self->oauth_redirect_uri(), | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1134 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||
| 1137 | sub refresh_access_token { | ||||||||||||||||||||||||||||||||||||||||||
| 1138 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh_access_token: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||
| 1140 | 3 | ▶ | die "refresh_access_token requires a stored refresh token\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1141 | unless $self->refresh_token(); | ||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||
| 1143 | 2 | return $self->_request_token( | |||||||||||||||||||||||||||||||||||||||||
| 1144 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1145 | grant_type => 'refresh_token', | ||||||||||||||||||||||||||||||||||||||||||
| 1146 | refresh_token => $self->refresh_token(), | ||||||||||||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1148 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||
| 1151 | sub get { | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||
| 1153 | # This seemed like a simple enough method | ||||||||||||||||||||||||||||||||||||||||||
| 1154 | # but everything I tried resulted in unacceptable | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | # trade offs and explict defining of the structures | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | # The new method, which I hope I remember when I | ||||||||||||||||||||||||||||||||||||||||||
| 1157 | # revisit it, was to use JSON::Path | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | # It is an awesome module, but a little heavy | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | # on dependencies. However I would not have been | ||||||||||||||||||||||||||||||||||||||||||
| 1160 | # able to do this in so few lines without it | ||||||||||||||||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||||||||||||||||
| 1162 | # Making a generalization here | ||||||||||||||||||||||||||||||||||||||||||
| 1163 | # if you use a * you are looking for an array | ||||||||||||||||||||||||||||||||||||||||||
| 1164 | # if you don't have an * you want the first 1 (or should I say you get the first 1) | ||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||
| 1166 | 4 | ▶ | my ( $self, @return ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=8 SCAR=21.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1167 | |||||||||||||||||||||||||||||||||||||||||||
| 1168 | 4 | my @out; | |||||||||||||||||||||||||||||||||||||||||
| 1169 | |||||||||||||||||||||||||||||||||||||||||||
| 1170 | 4 | ▶ | die "get(): no result available - make an API call first\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1171 | unless length $self->last_result(); | ||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||
| 1173 | 3 | my $result = eval { decode_json( $self->last_result() ) }; | |||||||||||||||||||||||||||||||||||||||||
| 1174 | 3 | ▶ | die "get(): last_result is not valid JSON: $@\n" if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||
| 1176 | 2 | my $search_ref = $result; | |||||||||||||||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||||||||||||||||
| 1178 | 2 | ▶ | warn Dumper($result) if $self->debug(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||
| 1180 | 2 | foreach my $key (@return) { | |||||||||||||||||||||||||||||||||||||||||
| 1181 | 2 | my $type = 'value'; | |||||||||||||||||||||||||||||||||||||||||
| 1182 | 2 | ▶ | if ( $key =~ /\*\]/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | $type = 'values'; | |||||||||||||||||||||||||||||||||||||||||
| 1184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1185 | |||||||||||||||||||||||||||||||||||||||||||
| 1186 | 2 | my $jpath = JSON::Path->new("\$.$key"); | |||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||
| 1188 | 2 | my @t_arr = $jpath->$type($result); | |||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||
| 1190 | 2 | ▶ | if ( $type eq 'value' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1191 | 2 | push @out, $t_arr[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1193 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | push @out, \@t_arr; | |||||||||||||||||||||||||||||||||||||||||
| 1195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1197 | 2 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | return @out; | |||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1200 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1201 | 2 | return $out[0]; | |||||||||||||||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||||||||||||||||
| 1204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||
| 1206 | sub build_url_base { | ||||||||||||||||||||||||||||||||||||||||||
| 1207 | |||||||||||||||||||||||||||||||||||||||||||
| 1208 | # first the uri type | ||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_url_base: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | ▶ | my $call_type = shift || $self->call_type(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->call_type
MC/DC0%0/2
shift() || $self->call_type
shift()
$self->call_type
Truth table0%0/3
A || B
A= shift()B= $self->call_type
| |||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||
| 1212 | 0 | my $url = $self->uri_scheme(); | |||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||
| 1214 | # the :// | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | $url .= '://'; | |||||||||||||||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||||||||||||||||
| 1217 | # the domain | ||||||||||||||||||||||||||||||||||||||||||
| 1218 | 0 | $url .= $self->uri_hostname(); | |||||||||||||||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||||||||||||||||
| 1220 | # the path | ||||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | ▶ | if ( $self->uri_domain_path() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | $url .= '/' . $self->uri_domain_path(); | |||||||||||||||||||||||||||||||||||||||||
| 1223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | return $url; | |||||||||||||||||||||||||||||||||||||||||
| 1226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||||||||||||||||
| 1228 | #- may want to move this at some point | ||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||
| 1230 | sub query_full_url { | ||||||||||||||||||||||||||||||||||||||||||
| 1231 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
query_full_url: called CC=5 SCAR=17.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1232 | 3 | my $url = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1233 | 3 | ▶ | my $client_auth_required = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||
| 1235 | # Prevent bearer-token leakage to off-origin hosts. All Spotify API | ||||||||||||||||||||||||||||||||||||||||||
| 1236 | # responses that contain URLs (next/previous paging, href fields) point to | ||||||||||||||||||||||||||||||||||||||||||
| 1237 | # api.spotify.com; anything else is unexpected and potentially malicious. | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | 3 | ▶ | if ( $client_auth_required || $self->force_client_auth() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$client_auth_required or $self->force_client_auth
MC/DC0%0/2
$client_auth_required or $self->force_client_auth
$client_auth_required
$self->force_client_auth
Truth table33%1/3
A or B
A= $client_auth_requiredB= $self->force_client_auth
| |||||||||||||||||||||||||||||||||||||||||||
| 1239 | 3 | ▶ | die "query_full_url: URL '$url' is not allowed - " | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1240 | . "only https://api.spotify.com/ URLs may be called with credentials\n" | ||||||||||||||||||||||||||||||||||||||||||
| 1241 | unless $url =~ m{\Ahttps://api\.spotify\.com/}i; | ||||||||||||||||||||||||||||||||||||||||||
| 1242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||
| 1244 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1245 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1246 | method => 'query_full_url', | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||
| 1248 | client_auth_required => $client_auth_required | ||||||||||||||||||||||||||||||||||||||||||
| 1249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1250 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||||||||||||||||
| 1253 | #-- spotify specific methods | ||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||
| 1255 | sub album { | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
album: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1257 | 4 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||||||||||||||||
| 1259 | 4 | ▶ | die "album id is required\n" unless defined $id && length $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $id and length $id
MC/DC100%2/2
defined $id and length $id
defined $id
length $id
Truth table100%3/3
A and B
A= defined $idB= length $id
| |||||||||||||||||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||||||||||||||||
| 1261 | 2 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1262 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1263 | method => 'album', | ||||||||||||||||||||||||||||||||||||||||||
| 1264 | params => { 'id' => $id }, | ||||||||||||||||||||||||||||||||||||||||||
| 1265 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1267 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1269 | |||||||||||||||||||||||||||||||||||||||||||
| 1270 | sub albums { | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
albums: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1272 | 3 | my $ids = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1273 | |||||||||||||||||||||||||||||||||||||||||||
| 1274 | 3 | ▶ | die "albums ids is required\n" unless defined $ids && length $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ids and length $ids
MC/DC50%1/2
defined $ids and length $ids
defined $ids
length $ids
Truth table66%2/3
A and B
A= defined $idsB= length $ids
| |||||||||||||||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||||||||||||
| 1276 | 2 | ▶ | if ( ref($ids) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1277 | 1 | $ids = join_ids($ids); | |||||||||||||||||||||||||||||||||||||||||
| 1278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||
| 1280 | 2 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1281 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | method => 'albums', | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | params => { 'ids' => $ids }, | ||||||||||||||||||||||||||||||||||||||||||
| 1284 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1286 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1287 | |||||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1289 | |||||||||||||||||||||||||||||||||||||||||||
| 1290 | sub join_ids { | ||||||||||||||||||||||||||||||||||||||||||
| 1291 | 2 | ▶ | my $array = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
join_ids: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1292 | 2 | return join( ',', @$array ); | |||||||||||||||||||||||||||||||||||||||||
| 1293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||
| 1295 | sub albums_tracks { | ||||||||||||||||||||||||||||||||||||||||||
| 1296 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
albums_tracks: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1297 | 3 | my $album_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1298 | 3 | my $extras = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1299 | |||||||||||||||||||||||||||||||||||||||||||
| 1300 | 3 | ▶ | die "album_id is required\n" unless defined $album_id && length $album_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $album_id and length $album_id
MC/DC100%2/2
defined $album_id and length $album_id
defined $album_id
length $album_id
Truth table100%3/3
A and B
A= defined $album_idB= length $album_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||
| 1302 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1303 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1304 | method => 'albums_tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 1305 | params => { 'id' => $album_id }, | ||||||||||||||||||||||||||||||||||||||||||
| 1306 | extras => $extras, | ||||||||||||||||||||||||||||||||||||||||||
| 1307 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1309 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||
| 1311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1312 | |||||||||||||||||||||||||||||||||||||||||||
| 1313 | sub artist { | ||||||||||||||||||||||||||||||||||||||||||
| 1314 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
artist: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1315 | 3 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||||||||||||||||
| 1317 | 3 | ▶ | die "artist id is required\n" unless defined $id && length $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $id and length $id
MC/DC100%2/2
defined $id and length $id
defined $id
length $id
Truth table100%3/3
A and B
A= defined $idB= length $id
| |||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||
| 1319 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1320 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1321 | method => 'artist', | ||||||||||||||||||||||||||||||||||||||||||
| 1322 | params => { 'id' => $id }, | ||||||||||||||||||||||||||||||||||||||||||
| 1323 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1325 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||
| 1327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||
| 1329 | sub artists { | ||||||||||||||||||||||||||||||||||||||||||
| 1330 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
artists: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1331 | 2 | my $artists = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||
| 1333 | 2 | ▶ | die "artists ids is required\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $artists and length $artists
MC/DC50%1/2
defined $artists and length $artists
defined $artists
length $artists
Truth table66%2/3
A and B
A= defined $artistsB= length $artists
| |||||||||||||||||||||||||||||||||||||||||||
| 1334 | unless defined $artists && length $artists; | ||||||||||||||||||||||||||||||||||||||||||
| 1335 | |||||||||||||||||||||||||||||||||||||||||||
| 1336 | 1 | ▶ | if ( ref($artists) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1337 | 0 | $artists = join_ids($artists); | |||||||||||||||||||||||||||||||||||||||||
| 1338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | |||||||||||||||||||||||||||||||||||||||||||
| 1340 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1341 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1342 | method => 'artists', | ||||||||||||||||||||||||||||||||||||||||||
| 1343 | params => { 'ids' => $artists }, | ||||||||||||||||||||||||||||||||||||||||||
| 1344 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1346 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1347 | |||||||||||||||||||||||||||||||||||||||||||
| 1348 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1349 | |||||||||||||||||||||||||||||||||||||||||||
| 1350 | sub artist_albums { | ||||||||||||||||||||||||||||||||||||||||||
| 1351 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
artist_albums: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1352 | 2 | my $artist_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1353 | 2 | my $extras = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||||||||||||||||
| 1355 | 2 | ▶ | die "artist_id is required\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $artist_id and length $artist_id
MC/DC50%1/2
defined $artist_id and length $artist_id
defined $artist_id
length $artist_id
Truth table66%2/3
A and B
A= defined $artist_idB= length $artist_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1356 | unless defined $artist_id && length $artist_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||
| 1358 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1359 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1360 | method => 'artist_albums', | ||||||||||||||||||||||||||||||||||||||||||
| 1361 | params => { 'id' => $artist_id }, | ||||||||||||||||||||||||||||||||||||||||||
| 1362 | extras => $extras, | ||||||||||||||||||||||||||||||||||||||||||
| 1363 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1365 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||||||||||||||||
| 1367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1368 | |||||||||||||||||||||||||||||||||||||||||||
| 1369 | sub artist_top_tracks { | ||||||||||||||||||||||||||||||||||||||||||
| 1370 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
artist_top_tracks: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1371 | 2 | my $artist_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1372 | 2 | my $country = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||||||||||||
| 1374 | 2 | ▶ | die "artist_id is required\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $artist_id and length $artist_id
MC/DC50%1/2
defined $artist_id and length $artist_id
defined $artist_id
length $artist_id
Truth table66%2/3
A and B
A= defined $artist_idB= length $artist_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1375 | unless defined $artist_id && length $artist_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||
| 1377 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1378 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1379 | method => 'artist_top_tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 1380 | params => { | ||||||||||||||||||||||||||||||||||||||||||
| 1381 | 'id' => $artist_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1382 | 'country' => $country, | ||||||||||||||||||||||||||||||||||||||||||
| 1383 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1384 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1386 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | |||||||||||||||||||||||||||||||||||||||||||
| 1388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1389 | |||||||||||||||||||||||||||||||||||||||||||
| 1390 | sub artist_related_artists { | ||||||||||||||||||||||||||||||||||||||||||
| 1391 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
artist_related_artists: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1392 | 2 | my $artist_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||||||||||||
| 1394 | 2 | ▶ | die "artist_id is required\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $artist_id and length $artist_id
MC/DC50%1/2
defined $artist_id and length $artist_id
defined $artist_id
length $artist_id
Truth table66%2/3
A and B
A= defined $artist_idB= length $artist_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1395 | unless defined $artist_id && length $artist_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||
| 1397 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1398 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1399 | method => 'artist_related_artists', | ||||||||||||||||||||||||||||||||||||||||||
| 1400 | params => { 'id' => $artist_id } | ||||||||||||||||||||||||||||||||||||||||||
| 1401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1402 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1403 | |||||||||||||||||||||||||||||||||||||||||||
| 1404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1405 | |||||||||||||||||||||||||||||||||||||||||||
| 1406 | sub me { | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
me: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1409 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1410 | method => 'me', | ||||||||||||||||||||||||||||||||||||||||||
| 1411 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1413 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||
| 1416 | sub next_result_set { | ||||||||||||||||||||||||||||||||||||||||||
| 1417 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_result_set: called CC=4 SCAR=16.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1418 | 1 | my $url = $self->get('next'); | |||||||||||||||||||||||||||||||||||||||||
| 1419 | 1 | ▶ | return unless defined $url && $url ne 'null' && $url ne q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $url and $url ne "null" and $url ne ""
defined $url and $url ne "null"
MC/DC0%0/3
defined $url and $url ne "null" and $url ne ""
defined $url
$url ne "null"
$url ne ""
Truth table25%1/4
A and B and C
A= defined $urlB= $url ne "null"C= $url ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 1420 | 1 | return $self->query_full_url( $url, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 1421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||
| 1423 | sub previous_result_set { | ||||||||||||||||||||||||||||||||||||||||||
| 1424 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
previous_result_set: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1425 | 0 | my $url = $self->get('previous'); | |||||||||||||||||||||||||||||||||||||||||
| 1426 | 0 | ▶ | return unless defined $url && $url ne 'null' && $url ne q{}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $url and $url ne "null" and $url ne ""
defined $url and $url ne "null"
MC/DC0%0/3
defined $url and $url ne "null" and $url ne ""
defined $url
$url ne "null"
$url ne ""
Truth table0%0/4
A and B and C
A= defined $urlB= $url ne "null"C= $url ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 1427 | 0 | return $self->query_full_url( $url, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 1428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||
| 1430 | sub search { | ||||||||||||||||||||||||||||||||||||||||||
| 1431 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
search: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1432 | 5 | my $q = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1433 | 5 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1434 | 5 | my $extras = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||
| 1436 | 5 | ▶ | die "search query (q) is required\n" unless defined $q && length $q; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $q and length $q
MC/DC100%2/2
defined $q and length $q
defined $q
length $q
Truth table100%3/3
A and B
A= defined $qB= length $q
| |||||||||||||||||||||||||||||||||||||||||||
| 1437 | 3 | ▶ | die "search type is required\n" unless defined $type && length $type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $type and length $type
MC/DC100%2/2
defined $type and length $type
defined $type
length $type
Truth table100%3/3
A and B
A= defined $typeB= length $type
| |||||||||||||||||||||||||||||||||||||||||||
| 1438 | |||||||||||||||||||||||||||||||||||||||||||
| 1439 | # looks like search now requires auth | ||||||||||||||||||||||||||||||||||||||||||
| 1440 | # we will force authentication but need to | ||||||||||||||||||||||||||||||||||||||||||
| 1441 | # reset this to the previous value since not | ||||||||||||||||||||||||||||||||||||||||||
| 1442 | # all requests require auth | ||||||||||||||||||||||||||||||||||||||||||
| 1443 | 1 | my $old_force_client_auth = $self->force_client_auth(); | |||||||||||||||||||||||||||||||||||||||||
| 1444 | 1 | $self->force_client_auth(1); | |||||||||||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||||||||||||
| 1446 | 1 | my $response = $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1447 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1448 | method => 'search', | ||||||||||||||||||||||||||||||||||||||||||
| 1449 | params => { | ||||||||||||||||||||||||||||||||||||||||||
| 1450 | q => uri_escape($q), | ||||||||||||||||||||||||||||||||||||||||||
| 1451 | type => uri_escape($type), | ||||||||||||||||||||||||||||||||||||||||||
| 1452 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1453 | extras => $extras, | ||||||||||||||||||||||||||||||||||||||||||
| 1454 | client_auth_required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1455 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1456 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1457 | |||||||||||||||||||||||||||||||||||||||||||
| 1458 | # reset auth to what it was before to avoid overly chatty | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | # requests | ||||||||||||||||||||||||||||||||||||||||||
| 1460 | 1 | $self->force_client_auth($old_force_client_auth); | |||||||||||||||||||||||||||||||||||||||||
| 1461 | 1 | return $response; | |||||||||||||||||||||||||||||||||||||||||
| 1462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||||||||||||||||
| 1464 | sub track { | ||||||||||||||||||||||||||||||||||||||||||
| 1465 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
track: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1466 | 2 | my $id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||
| 1468 | 2 | ▶ | die "track id is required\n" unless defined $id && length $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $id and length $id
MC/DC50%1/2
defined $id and length $id
defined $id
length $id
Truth table66%2/3
A and B
A= defined $idB= length $id
| |||||||||||||||||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||||||||||||||||
| 1470 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1471 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1472 | method => 'track', | ||||||||||||||||||||||||||||||||||||||||||
| 1473 | params => { 'id' => $id } | ||||||||||||||||||||||||||||||||||||||||||
| 1474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1477 | |||||||||||||||||||||||||||||||||||||||||||
| 1478 | sub browse_featured_playlists { | ||||||||||||||||||||||||||||||||||||||||||
| 1479 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
browse_featured_playlists: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1480 | 0 | my $extras = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1481 | |||||||||||||||||||||||||||||||||||||||||||
| 1482 | # locale | ||||||||||||||||||||||||||||||||||||||||||
| 1483 | # country | ||||||||||||||||||||||||||||||||||||||||||
| 1484 | # limit | ||||||||||||||||||||||||||||||||||||||||||
| 1485 | # offset | ||||||||||||||||||||||||||||||||||||||||||
| 1486 | |||||||||||||||||||||||||||||||||||||||||||
| 1487 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1488 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1489 | method => 'browse_featured_playlists', | ||||||||||||||||||||||||||||||||||||||||||
| 1490 | extras => $extras, | ||||||||||||||||||||||||||||||||||||||||||
| 1491 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1493 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1495 | |||||||||||||||||||||||||||||||||||||||||||
| 1496 | sub browse_new_releases { | ||||||||||||||||||||||||||||||||||||||||||
| 1497 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
browse_new_releases: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1498 | 0 | my $extras = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1499 | |||||||||||||||||||||||||||||||||||||||||||
| 1500 | # locale | ||||||||||||||||||||||||||||||||||||||||||
| 1501 | # country | ||||||||||||||||||||||||||||||||||||||||||
| 1502 | # limit | ||||||||||||||||||||||||||||||||||||||||||
| 1503 | # offset | ||||||||||||||||||||||||||||||||||||||||||
| 1504 | |||||||||||||||||||||||||||||||||||||||||||
| 1505 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1506 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1507 | method => 'browse_new_releases', | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | extras => $extras, | ||||||||||||||||||||||||||||||||||||||||||
| 1509 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1510 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1511 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1512 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1513 | |||||||||||||||||||||||||||||||||||||||||||
| 1514 | sub tracks { | ||||||||||||||||||||||||||||||||||||||||||
| 1515 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tracks: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1516 | 2 | my $tracks = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1517 | |||||||||||||||||||||||||||||||||||||||||||
| 1518 | 2 | ▶ | die "tracks ids is required\n" unless defined $tracks && length $tracks; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $tracks and length $tracks
MC/DC50%1/2
defined $tracks and length $tracks
defined $tracks
length $tracks
Truth table66%2/3
A and B
A= defined $tracksB= length $tracks
| |||||||||||||||||||||||||||||||||||||||||||
| 1519 | |||||||||||||||||||||||||||||||||||||||||||
| 1520 | 1 | ▶ | if ( ref($tracks) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1521 | 1 | $tracks = join_ids($tracks); | |||||||||||||||||||||||||||||||||||||||||
| 1522 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1523 | |||||||||||||||||||||||||||||||||||||||||||
| 1524 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1525 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1526 | method => 'tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 1527 | params => { 'ids' => $tracks } | ||||||||||||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1529 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||||||||||||||||
| 1531 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||
| 1533 | sub user { | ||||||||||||||||||||||||||||||||||||||||||
| 1534 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
user: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1535 | 3 | my $user_id = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||||||||||||
| 1537 | 3 | ▶ | die "user_id is required\n" unless defined $user_id && length $user_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $user_id and length $user_id
MC/DC100%2/2
defined $user_id and length $user_id
defined $user_id
length $user_id
Truth table100%3/3
A and B
A= defined $user_idB= length $user_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||
| 1539 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1540 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1541 | method => 'user', | ||||||||||||||||||||||||||||||||||||||||||
| 1542 | params => { 'user_id' => $user_id } | ||||||||||||||||||||||||||||||||||||||||||
| 1543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1544 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1545 | |||||||||||||||||||||||||||||||||||||||||||
| 1546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||
| 1548 | sub get_playlist { | ||||||||||||||||||||||||||||||||||||||||||
| 1549 | 1 | ▶ | my ( $self, $playlist_id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_playlist: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||
| 1551 | 1 | ▶ | die "playlist_id is required\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $playlist_id and length $playlist_id
MC/DC0%0/2
defined $playlist_id and length $playlist_id
defined $playlist_id
length $playlist_id
Truth table33%1/3
A and B
A= defined $playlist_idB= length $playlist_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1552 | unless defined $playlist_id && length $playlist_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1553 | |||||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1555 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1556 | method => 'get_playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 1557 | params => { 'playlist_id' => $playlist_id }, | ||||||||||||||||||||||||||||||||||||||||||
| 1558 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1560 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1561 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1562 | |||||||||||||||||||||||||||||||||||||||||||
| 1563 | sub get_playlist_items { | ||||||||||||||||||||||||||||||||||||||||||
| 1564 | 2 | ▶ | my ( $self, $playlist_id, $extras ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_playlist_items: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||
| 1566 | 2 | ▶ | die "playlist_id is required\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $playlist_id and length $playlist_id
MC/DC50%1/2
defined $playlist_id and length $playlist_id
defined $playlist_id
length $playlist_id
Truth table66%2/3
A and B
A= defined $playlist_idB= length $playlist_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1567 | unless defined $playlist_id && length $playlist_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||||||||||||||||
| 1569 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1570 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1571 | method => 'get_playlist_items', | ||||||||||||||||||||||||||||||||||||||||||
| 1572 | params => { 'playlist_id' => $playlist_id }, | ||||||||||||||||||||||||||||||||||||||||||
| 1573 | client_auth_required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1574 | extras => $extras | ||||||||||||||||||||||||||||||||||||||||||
| 1575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1576 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||||||||||||||||
| 1579 | sub create_playlist { | ||||||||||||||||||||||||||||||||||||||||||
| 1580 | 2 | ▶ | my ( $self, $name, $public, $description ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_playlist: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||
| 1582 | 2 | my %params = ( 'name' => $name ); | |||||||||||||||||||||||||||||||||||||||||
| 1583 | 2 | ▶ | $params{public} = $public ? \1 : \0 if defined $public; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 1584 | 2 | ▶ | $params{description} = $description if defined $description; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||||||||||||||||
| 1586 | 2 | return $self->send_post_request( | |||||||||||||||||||||||||||||||||||||||||
| 1587 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1588 | method => 'create_playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 1589 | client_auth_required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1590 | params => \%params | ||||||||||||||||||||||||||||||||||||||||||
| 1591 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1592 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||
| 1595 | sub get_current_user_playlists { | ||||||||||||||||||||||||||||||||||||||||||
| 1596 | 1 | ▶ | my ( $self, $extras ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_current_user_playlists: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1597 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1598 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1599 | method => 'get_current_user_playlists', | ||||||||||||||||||||||||||||||||||||||||||
| 1600 | client_auth_required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1601 | extras => $extras | ||||||||||||||||||||||||||||||||||||||||||
| 1602 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1603 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1605 | |||||||||||||||||||||||||||||||||||||||||||
| 1606 | sub add_items_to_playlist { | ||||||||||||||||||||||||||||||||||||||||||
| 1607 | 5 | ▶ | my ( $self, $playlist_id, $uris, $position ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_items_to_playlist: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||||||||||||||||
| 1609 | 5 | ▶ | die "playlist_id is required\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $playlist_id and length $playlist_id
MC/DC100%2/2
defined $playlist_id and length $playlist_id
defined $playlist_id
length $playlist_id
Truth table100%3/3
A and B
A= defined $playlist_idB= length $playlist_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1610 | unless defined $playlist_id && length $playlist_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||||||||||||||||
| 1612 | 3 | ▶ | my %params = ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1613 | 'playlist_id' => $playlist_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1614 | 'uris' => ref $uris eq 'ARRAY' ? $uris : [$uris], | ||||||||||||||||||||||||||||||||||||||||||
| 1615 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1616 | 3 | ▶ | $params{position} = $position if defined $position; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||||||||||||||||
| 1618 | 3 | return $self->send_post_request( | |||||||||||||||||||||||||||||||||||||||||
| 1619 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1620 | method => 'add_items_to_playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 1621 | client_auth_required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1622 | params => \%params | ||||||||||||||||||||||||||||||||||||||||||
| 1623 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1624 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1625 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||
| 1627 | sub unfollow_playlist { | ||||||||||||||||||||||||||||||||||||||||||
| 1628 | 4 | ▶ | my ( $self, $playlist_id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unfollow_playlist: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||||||||||||
| 1630 | 4 | ▶ | die "playlist_id is required\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $playlist_id and length $playlist_id
MC/DC100%2/2
defined $playlist_id and length $playlist_id
defined $playlist_id
length $playlist_id
Truth table100%3/3
A and B
A= defined $playlist_idB= length $playlist_id
| |||||||||||||||||||||||||||||||||||||||||||
| 1631 | unless defined $playlist_id && length $playlist_id; | ||||||||||||||||||||||||||||||||||||||||||
| 1632 | |||||||||||||||||||||||||||||||||||||||||||
| 1633 | 2 | return $self->send_delete_request( | |||||||||||||||||||||||||||||||||||||||||
| 1634 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1635 | method => 'unfollow_playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 1636 | client_auth_required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 1637 | params => { 'playlist_id' => $playlist_id } | ||||||||||||||||||||||||||||||||||||||||||
| 1638 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1639 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1640 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1641 | |||||||||||||||||||||||||||||||||||||||||||
| 1642 | sub remove_user_saved_tracks { | ||||||||||||||||||||||||||||||||||||||||||
| 1643 | 0 | ▶ | my ( $self, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_user_saved_tracks: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||||||||||||||||
| 1645 | 0 | ▶ | if ( ref($ids) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | $ids = join_ids($ids); | |||||||||||||||||||||||||||||||||||||||||
| 1647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1648 | |||||||||||||||||||||||||||||||||||||||||||
| 1649 | 0 | return $self->send_delete_request( | |||||||||||||||||||||||||||||||||||||||||
| 1650 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1651 | method => 'remove_user_saved_tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 1652 | params => { 'ids' => $ids } | ||||||||||||||||||||||||||||||||||||||||||
| 1653 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1654 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||||||||||||
| 1657 | sub check_users_saved_tracks { | ||||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | ▶ | my ( $self, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_users_saved_tracks: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1659 | |||||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | ▶ | if ( ref($ids) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1661 | 0 | $ids = join_ids($ids); | |||||||||||||||||||||||||||||||||||||||||
| 1662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1665 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1666 | method => 'check_users_saved_tracks', | ||||||||||||||||||||||||||||||||||||||||||
| 1667 | params => { 'ids' => $ids }, | ||||||||||||||||||||||||||||||||||||||||||
| 1668 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1670 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1671 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||
| 1673 | sub get_several_tracks_audio_features { | ||||||||||||||||||||||||||||||||||||||||||
| 1674 | 0 | ▶ | my ( $self, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_several_tracks_audio_features: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1675 | |||||||||||||||||||||||||||||||||||||||||||
| 1676 | 0 | ▶ | if ( ref($ids) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1677 | 0 | $ids = join_ids($ids); | |||||||||||||||||||||||||||||||||||||||||
| 1678 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1679 | |||||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1681 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1682 | method => 'get_several_tracks_audio_features', | ||||||||||||||||||||||||||||||||||||||||||
| 1683 | params => { 'ids' => $ids }, | ||||||||||||||||||||||||||||||||||||||||||
| 1684 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1686 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1687 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||||||||||||||||
| 1689 | sub get_track_audio_features { | ||||||||||||||||||||||||||||||||||||||||||
| 1690 | 0 | ▶ | my ( $self, $id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_track_audio_features: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1691 | |||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1693 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1694 | method => 'get_track_audio_features', | ||||||||||||||||||||||||||||||||||||||||||
| 1695 | params => { 'id' => $id }, | ||||||||||||||||||||||||||||||||||||||||||
| 1696 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1697 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1698 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1699 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||||||||||||
| 1701 | sub get_track_audio_analysis { | ||||||||||||||||||||||||||||||||||||||||||
| 1702 | 0 | ▶ | my ( $self, $id ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_track_audio_analysis: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1703 | |||||||||||||||||||||||||||||||||||||||||||
| 1704 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1705 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1706 | method => 'get_track_audio_analysis', | ||||||||||||||||||||||||||||||||||||||||||
| 1707 | params => { 'id' => $id }, | ||||||||||||||||||||||||||||||||||||||||||
| 1708 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1710 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1712 | |||||||||||||||||||||||||||||||||||||||||||
| 1713 | sub get_recommendations { | ||||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | ▶ | my ( $self, %params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_recommendations: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||||||||||||||||
| 1716 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1717 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1718 | method => 'get_recommendations', | ||||||||||||||||||||||||||||||||||||||||||
| 1719 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 1720 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1721 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1722 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1723 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||||||||||||||||
| 1725 | sub get_followed_artists { | ||||||||||||||||||||||||||||||||||||||||||
| 1726 | 0 | ▶ | my ( $self, %params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_followed_artists: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||||||||||||
| 1728 | # Ensure 'type' is set to 'artist' as it's the only supported value | ||||||||||||||||||||||||||||||||||||||||||
| 1729 | 0 | $params{type} = 'artist'; | |||||||||||||||||||||||||||||||||||||||||
| 1730 | |||||||||||||||||||||||||||||||||||||||||||
| 1731 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1732 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1733 | method => 'get_followed_artists', | ||||||||||||||||||||||||||||||||||||||||||
| 1734 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 1735 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1736 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1737 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1739 | |||||||||||||||||||||||||||||||||||||||||||
| 1740 | sub follow_artists_or_users { | ||||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | ▶ | my ( $self, $type, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
follow_artists_or_users: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||||||||||||||||
| 1743 | 0 | ▶ | die "Type must be 'artist' or 'user'" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type eq "artist" or $type eq "user"
MC/DC0%0/2
$type eq "artist" or $type eq "user"
$type eq "artist"
$type eq "user"
Truth table0%0/3
A or B
A= $type eq "artist"B= $type eq "user"
| |||||||||||||||||||||||||||||||||||||||||||
| 1744 | unless $type eq 'artist' or $type eq 'user'; | ||||||||||||||||||||||||||||||||||||||||||
| 1745 | |||||||||||||||||||||||||||||||||||||||||||
| 1746 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||||||||||||||||
| 1748 | 0 | return $self->send_put_request( | |||||||||||||||||||||||||||||||||||||||||
| 1749 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1750 | method => 'follow_artists_or_users', | ||||||||||||||||||||||||||||||||||||||||||
| 1751 | params => { | ||||||||||||||||||||||||||||||||||||||||||
| 1752 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||
| 1753 | ids => $id_list | ||||||||||||||||||||||||||||||||||||||||||
| 1754 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1755 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1756 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1757 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1758 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1759 | |||||||||||||||||||||||||||||||||||||||||||
| 1760 | sub unfollow_artists_or_users { | ||||||||||||||||||||||||||||||||||||||||||
| 1761 | 0 | ▶ | my ( $self, $type, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unfollow_artists_or_users: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||||||||||||
| 1763 | 0 | ▶ | die "Type must be 'artist' or 'user'" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type eq "artist" or $type eq "user"
MC/DC0%0/2
$type eq "artist" or $type eq "user"
$type eq "artist"
$type eq "user"
Truth table0%0/3
A or B
A= $type eq "artist"B= $type eq "user"
| |||||||||||||||||||||||||||||||||||||||||||
| 1764 | unless $type eq 'artist' or $type eq 'user'; | ||||||||||||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||||||||||||
| 1766 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||||||||||||||||
| 1768 | 0 | return $self->send_delete_request( | |||||||||||||||||||||||||||||||||||||||||
| 1769 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1770 | method => 'unfollow_artists_or_users', | ||||||||||||||||||||||||||||||||||||||||||
| 1771 | params => { | ||||||||||||||||||||||||||||||||||||||||||
| 1772 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||
| 1773 | ids => $id_list | ||||||||||||||||||||||||||||||||||||||||||
| 1774 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1775 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1776 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1777 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1778 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1779 | |||||||||||||||||||||||||||||||||||||||||||
| 1780 | sub check_if_user_follows_artists_or_users { | ||||||||||||||||||||||||||||||||||||||||||
| 1781 | 0 | ▶ | my ( $self, $type, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_if_user_follows_artists_or_users: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1782 | |||||||||||||||||||||||||||||||||||||||||||
| 1783 | 0 | ▶ | die "Type must be 'artist' or 'user'" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type eq "artist" or $type eq "user"
MC/DC0%0/2
$type eq "artist" or $type eq "user"
$type eq "artist"
$type eq "user"
Truth table0%0/3
A or B
A= $type eq "artist"B= $type eq "user"
| |||||||||||||||||||||||||||||||||||||||||||
| 1784 | unless $type eq 'artist' or $type eq 'user'; | ||||||||||||||||||||||||||||||||||||||||||
| 1785 | |||||||||||||||||||||||||||||||||||||||||||
| 1786 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||
| 1788 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1789 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1790 | method => 'check_if_user_follows_artists_or_users', | ||||||||||||||||||||||||||||||||||||||||||
| 1791 | params => { | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | type => $type, | ||||||||||||||||||||||||||||||||||||||||||
| 1793 | ids => $id_list | ||||||||||||||||||||||||||||||||||||||||||
| 1794 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1795 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1796 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1797 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1798 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||||||||||||
| 1800 | sub check_if_user_follows_playlist { | ||||||||||||||||||||||||||||||||||||||||||
| 1801 | 0 | ▶ | my ( $self, $playlist_id, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_if_user_follows_playlist: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1802 | |||||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | ▶ | die "playlist_id is required" unless $playlist_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | ▶ | die "ids is required" unless $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||||||||||||
| 1806 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||||||||||||||||
| 1808 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1809 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1810 | method => 'check_if_user_follows_playlist', | ||||||||||||||||||||||||||||||||||||||||||
| 1811 | params => { | ||||||||||||||||||||||||||||||||||||||||||
| 1812 | playlist_id => $playlist_id, | ||||||||||||||||||||||||||||||||||||||||||
| 1813 | ids => $id_list | ||||||||||||||||||||||||||||||||||||||||||
| 1814 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1815 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1816 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1817 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1818 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1819 | |||||||||||||||||||||||||||||||||||||||||||
| 1820 | # Spotify URIs contain ':' and commas separate multiple items; both must be | ||||||||||||||||||||||||||||||||||||||||||
| 1821 | # percent-encoded before being spliced into a query string by _build_url / | ||||||||||||||||||||||||||||||||||||||||||
| 1822 | # send_get_request (which perform a raw substitution on the query part). | ||||||||||||||||||||||||||||||||||||||||||
| 1823 | sub _uris_param { | ||||||||||||||||||||||||||||||||||||||||||
| 1824 | 3 | ▶ | my $uris = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_uris_param: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1825 | 3 | ▶ | $uris = join( ',', @{$uris} ) if ref $uris eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1826 | 3 | return uri_escape($uris); | |||||||||||||||||||||||||||||||||||||||||
| 1827 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1828 | |||||||||||||||||||||||||||||||||||||||||||
| 1829 | sub save_library_items { | ||||||||||||||||||||||||||||||||||||||||||
| 1830 | 1 | ▶ | my ( $self, $uris ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save_library_items: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1831 | |||||||||||||||||||||||||||||||||||||||||||
| 1832 | 1 | ▶ | die "Spotify URIs are required" unless $uris; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||||||||||||||||
| 1834 | 1 | return $self->send_put_request( | |||||||||||||||||||||||||||||||||||||||||
| 1835 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1836 | method => 'save_library_items', | ||||||||||||||||||||||||||||||||||||||||||
| 1837 | params => { uris => _uris_param($uris) }, | ||||||||||||||||||||||||||||||||||||||||||
| 1838 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1839 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1840 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1841 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1842 | |||||||||||||||||||||||||||||||||||||||||||
| 1843 | sub remove_library_items { | ||||||||||||||||||||||||||||||||||||||||||
| 1844 | 1 | ▶ | my ( $self, $uris ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_library_items: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1845 | |||||||||||||||||||||||||||||||||||||||||||
| 1846 | 1 | ▶ | die "Spotify URIs are required" unless $uris; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||||||||||||
| 1848 | 1 | return $self->send_delete_request( | |||||||||||||||||||||||||||||||||||||||||
| 1849 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1850 | method => 'remove_library_items', | ||||||||||||||||||||||||||||||||||||||||||
| 1851 | params => { uris => _uris_param($uris) }, | ||||||||||||||||||||||||||||||||||||||||||
| 1852 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1853 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1854 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1855 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1856 | |||||||||||||||||||||||||||||||||||||||||||
| 1857 | sub check_library_items { | ||||||||||||||||||||||||||||||||||||||||||
| 1858 | 1 | ▶ | my ( $self, $uris ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_library_items: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||||||||||||||||
| 1860 | 1 | ▶ | die "Spotify URIs are required" unless $uris; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||||||||||||
| 1862 | 1 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1863 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1864 | method => 'check_library_items', | ||||||||||||||||||||||||||||||||||||||||||
| 1865 | params => { uris => _uris_param($uris) }, | ||||||||||||||||||||||||||||||||||||||||||
| 1866 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1867 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1868 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1869 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1870 | |||||||||||||||||||||||||||||||||||||||||||
| 1871 | sub get_audiobook { | ||||||||||||||||||||||||||||||||||||||||||
| 1872 | 0 | ▶ | my ( $self, $id, $market ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_audiobook: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||||||||||||||||
| 1874 | 0 | ▶ | die "Audiobook ID is required" unless $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||||||||||||||||
| 1876 | 0 | my $params = { id => $id }; | |||||||||||||||||||||||||||||||||||||||||
| 1877 | 0 | ▶ | $params->{market} = $market if $market; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1878 | |||||||||||||||||||||||||||||||||||||||||||
| 1879 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1880 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1881 | method => 'get_audiobook', | ||||||||||||||||||||||||||||||||||||||||||
| 1882 | params => $params, | ||||||||||||||||||||||||||||||||||||||||||
| 1883 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1884 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1885 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1886 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1887 | |||||||||||||||||||||||||||||||||||||||||||
| 1888 | sub get_several_audiobooks { | ||||||||||||||||||||||||||||||||||||||||||
| 1889 | 0 | ▶ | my ( $self, $ids, $market ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_several_audiobooks: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1890 | |||||||||||||||||||||||||||||||||||||||||||
| 1891 | 0 | ▶ | die "Audiobook IDs are required" unless $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||||||||||||||||
| 1893 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1894 | |||||||||||||||||||||||||||||||||||||||||||
| 1895 | 0 | my $params = { ids => $id_list }; | |||||||||||||||||||||||||||||||||||||||||
| 1896 | 0 | ▶ | $params->{market} = $market if $market; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1897 | |||||||||||||||||||||||||||||||||||||||||||
| 1898 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1899 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1900 | method => 'get_several_audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 1901 | params => $params, | ||||||||||||||||||||||||||||||||||||||||||
| 1902 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1904 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1905 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||||||||||||||||
| 1907 | sub get_audiobook_chapters { | ||||||||||||||||||||||||||||||||||||||||||
| 1908 | 0 | ▶ | my ( $self, $id, %params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_audiobook_chapters: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||||||||||||
| 1910 | 0 | ▶ | die "Audiobook ID is required" unless $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1911 | |||||||||||||||||||||||||||||||||||||||||||
| 1912 | 0 | $params{id} = $id; | |||||||||||||||||||||||||||||||||||||||||
| 1913 | |||||||||||||||||||||||||||||||||||||||||||
| 1914 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1915 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1916 | method => 'get_audiobook_chapters', | ||||||||||||||||||||||||||||||||||||||||||
| 1917 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 1918 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1919 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1920 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1921 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1922 | |||||||||||||||||||||||||||||||||||||||||||
| 1923 | sub get_users_saved_audiobooks { | ||||||||||||||||||||||||||||||||||||||||||
| 1924 | 0 | ▶ | my ( $self, $limit, $offset ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_users_saved_audiobooks: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1925 | |||||||||||||||||||||||||||||||||||||||||||
| 1926 | 0 | my $params = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1927 | 0 | ▶ | $params->{limit} = $limit if $limit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1928 | 0 | ▶ | $params->{offset} = $offset if defined $offset; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1929 | |||||||||||||||||||||||||||||||||||||||||||
| 1930 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1931 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1932 | method => 'get_users_saved_audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 1933 | params => $params, | ||||||||||||||||||||||||||||||||||||||||||
| 1934 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1935 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1936 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1937 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1938 | |||||||||||||||||||||||||||||||||||||||||||
| 1939 | sub save_audiobooks_for_current_user { | ||||||||||||||||||||||||||||||||||||||||||
| 1940 | 0 | ▶ | my ( $self, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save_audiobooks_for_current_user: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1941 | |||||||||||||||||||||||||||||||||||||||||||
| 1942 | 0 | ▶ | die "Audiobook IDs are required" unless $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||||||||||||||||
| 1944 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1945 | |||||||||||||||||||||||||||||||||||||||||||
| 1946 | 0 | return $self->send_put_request( | |||||||||||||||||||||||||||||||||||||||||
| 1947 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1948 | method => 'save_audiobooks_for_current_user', | ||||||||||||||||||||||||||||||||||||||||||
| 1949 | params => { ids => $id_list }, | ||||||||||||||||||||||||||||||||||||||||||
| 1950 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1951 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1952 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1953 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1954 | |||||||||||||||||||||||||||||||||||||||||||
| 1955 | sub remove_users_saved_audiobooks { | ||||||||||||||||||||||||||||||||||||||||||
| 1956 | 0 | ▶ | my ( $self, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_users_saved_audiobooks: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||||||||||||
| 1958 | 0 | ▶ | die "Audiobook IDs are required" unless $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||||||||||||
| 1960 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||||||||||||||||
| 1962 | 0 | return $self->send_delete_request( | |||||||||||||||||||||||||||||||||||||||||
| 1963 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1964 | method => 'remove_users_saved_audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 1965 | params => { ids => $id_list }, | ||||||||||||||||||||||||||||||||||||||||||
| 1966 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1967 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1968 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1969 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1970 | |||||||||||||||||||||||||||||||||||||||||||
| 1971 | sub check_users_saved_audiobooks { | ||||||||||||||||||||||||||||||||||||||||||
| 1972 | 0 | ▶ | my ( $self, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_users_saved_audiobooks: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1973 | |||||||||||||||||||||||||||||||||||||||||||
| 1974 | 0 | ▶ | die "Audiobook IDs are required" unless $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||||||||||||||||
| 1976 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||||||||||||||||
| 1978 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1979 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1980 | method => 'check_users_saved_audiobooks', | ||||||||||||||||||||||||||||||||||||||||||
| 1981 | params => { ids => $id_list }, | ||||||||||||||||||||||||||||||||||||||||||
| 1982 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1983 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1984 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1985 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1986 | |||||||||||||||||||||||||||||||||||||||||||
| 1987 | sub get_users_saved_shows { | ||||||||||||||||||||||||||||||||||||||||||
| 1988 | 0 | ▶ | my ( $self, %params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_users_saved_shows: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1989 | |||||||||||||||||||||||||||||||||||||||||||
| 1990 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 1991 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1992 | method => 'get_users_saved_shows', | ||||||||||||||||||||||||||||||||||||||||||
| 1993 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 1994 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 1995 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1996 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1997 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1998 | |||||||||||||||||||||||||||||||||||||||||||
| 1999 | sub save_shows_for_current_user { | ||||||||||||||||||||||||||||||||||||||||||
| 2000 | 0 | ▶ | my ( $self, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save_shows_for_current_user: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2001 | |||||||||||||||||||||||||||||||||||||||||||
| 2002 | 0 | ▶ | die "Show IDs are required" unless $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2003 | |||||||||||||||||||||||||||||||||||||||||||
| 2004 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2005 | |||||||||||||||||||||||||||||||||||||||||||
| 2006 | 0 | return $self->send_put_request( | |||||||||||||||||||||||||||||||||||||||||
| 2007 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2008 | method => 'save_shows_for_current_user', | ||||||||||||||||||||||||||||||||||||||||||
| 2009 | params => { ids => $id_list }, | ||||||||||||||||||||||||||||||||||||||||||
| 2010 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2011 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2012 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2013 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2014 | |||||||||||||||||||||||||||||||||||||||||||
| 2015 | sub check_users_saved_shows { | ||||||||||||||||||||||||||||||||||||||||||
| 2016 | 0 | ▶ | my ( $self, $ids ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_users_saved_shows: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2017 | |||||||||||||||||||||||||||||||||||||||||||
| 2018 | 0 | ▶ | die "Show IDs are required" unless $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2019 | |||||||||||||||||||||||||||||||||||||||||||
| 2020 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2021 | |||||||||||||||||||||||||||||||||||||||||||
| 2022 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2023 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2024 | method => 'check_users_saved_shows', | ||||||||||||||||||||||||||||||||||||||||||
| 2025 | params => { ids => $id_list }, | ||||||||||||||||||||||||||||||||||||||||||
| 2026 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2027 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2028 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2029 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2030 | |||||||||||||||||||||||||||||||||||||||||||
| 2031 | sub get_categories { | ||||||||||||||||||||||||||||||||||||||||||
| 2032 | 0 | ▶ | my ( $self, %params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_categories: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2033 | |||||||||||||||||||||||||||||||||||||||||||
| 2034 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2035 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2036 | method => 'get_categories', | ||||||||||||||||||||||||||||||||||||||||||
| 2037 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 2038 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2039 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2040 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2041 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2042 | |||||||||||||||||||||||||||||||||||||||||||
| 2043 | sub get_category { | ||||||||||||||||||||||||||||||||||||||||||
| 2044 | 0 | ▶ | my ( $self, $category_id, %params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_category: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2045 | |||||||||||||||||||||||||||||||||||||||||||
| 2046 | 0 | ▶ | die "Category ID is required" unless $category_id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2047 | |||||||||||||||||||||||||||||||||||||||||||
| 2048 | 0 | $params{category_id} = $category_id; | |||||||||||||||||||||||||||||||||||||||||
| 2049 | |||||||||||||||||||||||||||||||||||||||||||
| 2050 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2051 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2052 | method => 'get_category', | ||||||||||||||||||||||||||||||||||||||||||
| 2053 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 2054 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2055 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2056 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2057 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2058 | |||||||||||||||||||||||||||||||||||||||||||
| 2059 | sub get_chapter { | ||||||||||||||||||||||||||||||||||||||||||
| 2060 | 0 | ▶ | my ( $self, $id, %params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_chapter: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2061 | |||||||||||||||||||||||||||||||||||||||||||
| 2062 | 0 | ▶ | die "Chapter ID is required" unless $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2063 | |||||||||||||||||||||||||||||||||||||||||||
| 2064 | 0 | $params{id} = $id; | |||||||||||||||||||||||||||||||||||||||||
| 2065 | |||||||||||||||||||||||||||||||||||||||||||
| 2066 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2067 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2068 | method => 'get_chapter', | ||||||||||||||||||||||||||||||||||||||||||
| 2069 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 2070 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2071 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2072 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2073 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2074 | |||||||||||||||||||||||||||||||||||||||||||
| 2075 | sub get_several_chapters { | ||||||||||||||||||||||||||||||||||||||||||
| 2076 | 0 | ▶ | my ( $self, $ids, %params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_several_chapters: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2077 | |||||||||||||||||||||||||||||||||||||||||||
| 2078 | 0 | ▶ | die "Chapter IDs are required" unless $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2079 | |||||||||||||||||||||||||||||||||||||||||||
| 2080 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2081 | |||||||||||||||||||||||||||||||||||||||||||
| 2082 | 0 | $params{ids} = $id_list; | |||||||||||||||||||||||||||||||||||||||||
| 2083 | |||||||||||||||||||||||||||||||||||||||||||
| 2084 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2085 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2086 | method => 'get_several_chapters', | ||||||||||||||||||||||||||||||||||||||||||
| 2087 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 2088 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2089 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2090 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2091 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2092 | |||||||||||||||||||||||||||||||||||||||||||
| 2093 | sub get_available_genre_seeds { | ||||||||||||||||||||||||||||||||||||||||||
| 2094 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_available_genre_seeds: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2095 | |||||||||||||||||||||||||||||||||||||||||||
| 2096 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2097 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2098 | method => 'get_available_genre_seeds', | ||||||||||||||||||||||||||||||||||||||||||
| 2099 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2101 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2103 | |||||||||||||||||||||||||||||||||||||||||||
| 2104 | sub get_available_markets { | ||||||||||||||||||||||||||||||||||||||||||
| 2105 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_available_markets: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2106 | |||||||||||||||||||||||||||||||||||||||||||
| 2107 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2108 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2109 | method => 'get_available_markets', | ||||||||||||||||||||||||||||||||||||||||||
| 2110 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2112 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2114 | |||||||||||||||||||||||||||||||||||||||||||
| 2115 | sub get_show { | ||||||||||||||||||||||||||||||||||||||||||
| 2116 | 0 | ▶ | my ( $self, $id, $market ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_show: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2117 | |||||||||||||||||||||||||||||||||||||||||||
| 2118 | 0 | ▶ | die "Show ID is required" unless $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2119 | |||||||||||||||||||||||||||||||||||||||||||
| 2120 | 0 | my $params = { id => $id }; | |||||||||||||||||||||||||||||||||||||||||
| 2121 | 0 | ▶ | $params->{market} = $market if $market; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2122 | |||||||||||||||||||||||||||||||||||||||||||
| 2123 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2124 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2125 | method => 'get_show', | ||||||||||||||||||||||||||||||||||||||||||
| 2126 | params => $params, | ||||||||||||||||||||||||||||||||||||||||||
| 2127 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2129 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2131 | |||||||||||||||||||||||||||||||||||||||||||
| 2132 | sub get_several_shows { | ||||||||||||||||||||||||||||||||||||||||||
| 2133 | 0 | ▶ | my ( $self, $ids, $market ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_several_shows: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2134 | |||||||||||||||||||||||||||||||||||||||||||
| 2135 | 0 | ▶ | die "Show IDs are required" unless $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2136 | |||||||||||||||||||||||||||||||||||||||||||
| 2137 | 0 | ▶ | my $id_list = ref($ids) eq 'ARRAY' ? join( ',', @$ids ) : $ids; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2138 | |||||||||||||||||||||||||||||||||||||||||||
| 2139 | 0 | my $params = { ids => $id_list }; | |||||||||||||||||||||||||||||||||||||||||
| 2140 | 0 | ▶ | $params->{market} = $market if $market; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2141 | |||||||||||||||||||||||||||||||||||||||||||
| 2142 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2143 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2144 | method => 'get_several_shows', | ||||||||||||||||||||||||||||||||||||||||||
| 2145 | params => $params, | ||||||||||||||||||||||||||||||||||||||||||
| 2146 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2148 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2150 | |||||||||||||||||||||||||||||||||||||||||||
| 2151 | sub get_show_episodes { | ||||||||||||||||||||||||||||||||||||||||||
| 2152 | 0 | ▶ | my ( $self, $id, %params ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_show_episodes: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 2153 | |||||||||||||||||||||||||||||||||||||||||||
| 2154 | 0 | ▶ | die "Show ID is required" unless $id; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 2155 | |||||||||||||||||||||||||||||||||||||||||||
| 2156 | 0 | $params{id} = $id; | |||||||||||||||||||||||||||||||||||||||||
| 2157 | |||||||||||||||||||||||||||||||||||||||||||
| 2158 | 0 | return $self->send_get_request( | |||||||||||||||||||||||||||||||||||||||||
| 2159 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2160 | method => 'get_show_episodes', | ||||||||||||||||||||||||||||||||||||||||||
| 2161 | params => \%params, | ||||||||||||||||||||||||||||||||||||||||||
| 2162 | client_auth_required => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2164 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2166 | |||||||||||||||||||||||||||||||||||||||||||
| 2167 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 2168 | |||||||||||||||||||||||||||||||||||||||||||
| 2169 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 2170 | |||||||||||||||||||||||||||||||||||||||||||
| 2171 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 2172 | |||||||||||||||||||||||||||||||||||||||||||
| 2173 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 2174 | |||||||||||||||||||||||||||||||||||||||||||
| 2175 | WWW::Spotify - Spotify Web API Wrapper | ||||||||||||||||||||||||||||||||||||||||||
| 2176 | |||||||||||||||||||||||||||||||||||||||||||
| 2177 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 2178 | |||||||||||||||||||||||||||||||||||||||||||
| 2179 | version 0.017 | ||||||||||||||||||||||||||||||||||||||||||
| 2180 | |||||||||||||||||||||||||||||||||||||||||||
| 2181 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 2182 | |||||||||||||||||||||||||||||||||||||||||||
| 2183 | use WWW::Spotify (); | ||||||||||||||||||||||||||||||||||||||||||
| 2184 | |||||||||||||||||||||||||||||||||||||||||||
| 2185 | my $spotify = WWW::Spotify->new(); | ||||||||||||||||||||||||||||||||||||||||||
| 2186 | |||||||||||||||||||||||||||||||||||||||||||
| 2187 | my $result; | ||||||||||||||||||||||||||||||||||||||||||
| 2188 | |||||||||||||||||||||||||||||||||||||||||||
| 2189 | $result = $spotify->album('0sNOF9WDwhWunNAHPD3Baj'); | ||||||||||||||||||||||||||||||||||||||||||
| 2190 | |||||||||||||||||||||||||||||||||||||||||||
| 2191 | # $result is a json structure, you can operate on it directly | ||||||||||||||||||||||||||||||||||||||||||
| 2192 | # or you can use the "get" method see below | ||||||||||||||||||||||||||||||||||||||||||
| 2193 | |||||||||||||||||||||||||||||||||||||||||||
| 2194 | $result = $spotify->albums( '41MnTivkwTO3UUJ8DrqEJJ,6JWc4iAiJ9FjyK0B59ABb4,6UXCm6bOO4gFlDQZV5yL37' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2195 | |||||||||||||||||||||||||||||||||||||||||||
| 2196 | $result = $spotify->albums_tracks( '6akEvsycLGftJxYudPjmqK', | ||||||||||||||||||||||||||||||||||||||||||
| 2197 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2198 | limit => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 2199 | offset => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2200 | |||||||||||||||||||||||||||||||||||||||||||
| 2201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2202 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2203 | |||||||||||||||||||||||||||||||||||||||||||
| 2204 | $result = $spotify->artist( '0LcJLqbBmaGUft1e9Mm8HV' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2205 | |||||||||||||||||||||||||||||||||||||||||||
| 2206 | my $artists_multiple = '0oSGxfWSnnOXhD2fKuz2Gy,3dBVyJ7JuOMt4GE9607Qin'; | ||||||||||||||||||||||||||||||||||||||||||
| 2207 | |||||||||||||||||||||||||||||||||||||||||||
| 2208 | $result = $spotify->artists( $artists_multiple ); | ||||||||||||||||||||||||||||||||||||||||||
| 2209 | |||||||||||||||||||||||||||||||||||||||||||
| 2210 | $result = $spotify->artist_albums( '1vCWHaC5f2uS3yhpwWbIA6' , | ||||||||||||||||||||||||||||||||||||||||||
| 2211 | { album_type => 'single', | ||||||||||||||||||||||||||||||||||||||||||
| 2212 | # country => 'US', | ||||||||||||||||||||||||||||||||||||||||||
| 2213 | limit => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 2214 | offset => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 2215 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 2216 | |||||||||||||||||||||||||||||||||||||||||||
| 2217 | $result = $spotify->track( '0eGsygTp906u18L0Oimnem' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2218 | |||||||||||||||||||||||||||||||||||||||||||
| 2219 | $result = $spotify->tracks( '0eGsygTp906u18L0Oimnem,1lDWb6b6ieDQ2xT7ewTC3G' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2220 | |||||||||||||||||||||||||||||||||||||||||||
| 2221 | $result = $spotify->artist_top_tracks( '43ZHCT0cAZBISjO8DG9PnE', # artist id | ||||||||||||||||||||||||||||||||||||||||||
| 2222 | 'SE' # country | ||||||||||||||||||||||||||||||||||||||||||
| 2223 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2224 | |||||||||||||||||||||||||||||||||||||||||||
| 2225 | $result = $spotify->search( | ||||||||||||||||||||||||||||||||||||||||||
| 2226 | 'tania bowra' , | ||||||||||||||||||||||||||||||||||||||||||
| 2227 | 'artist' , | ||||||||||||||||||||||||||||||||||||||||||
| 2228 | { limit => 15 , offset => 0 } | ||||||||||||||||||||||||||||||||||||||||||
| 2229 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2230 | |||||||||||||||||||||||||||||||||||||||||||
| 2231 | $result = $spotify->user( 'glennpmcdonald' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2232 | |||||||||||||||||||||||||||||||||||||||||||
| 2233 | # public play interaction example | ||||||||||||||||||||||||||||||||||||||||||
| 2234 | # NEED TO SET YOUR o_auth client_id and secret for these to work | ||||||||||||||||||||||||||||||||||||||||||
| 2235 | |||||||||||||||||||||||||||||||||||||||||||
| 2236 | $spotify->browse_featured_playlists( country => 'US' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2237 | |||||||||||||||||||||||||||||||||||||||||||
| 2238 | my $link = $spotify->get('playlists.items[*].href'); | ||||||||||||||||||||||||||||||||||||||||||
| 2239 | |||||||||||||||||||||||||||||||||||||||||||
| 2240 | # $link is an arrayfef of the all the playlist urls | ||||||||||||||||||||||||||||||||||||||||||
| 2241 | |||||||||||||||||||||||||||||||||||||||||||
| 2242 | foreach my $playlist (@{$link}) { | ||||||||||||||||||||||||||||||||||||||||||
| 2243 | # make sure the links look valid | ||||||||||||||||||||||||||||||||||||||||||
| 2244 | next if $playlist !~ /playlists/; | ||||||||||||||||||||||||||||||||||||||||||
| 2245 | $spotify->query_full_url($playlist,1); | ||||||||||||||||||||||||||||||||||||||||||
| 2246 | my $pl_name = $spotify->get('name'); | ||||||||||||||||||||||||||||||||||||||||||
| 2247 | my $tracks = $spotify->get('tracks.items[*].track.id'); | ||||||||||||||||||||||||||||||||||||||||||
| 2248 | foreach my $track (@{$tracks}) { | ||||||||||||||||||||||||||||||||||||||||||
| 2249 | print "$track\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 2250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2252 | |||||||||||||||||||||||||||||||||||||||||||
| 2253 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 2254 | |||||||||||||||||||||||||||||||||||||||||||
| 2255 | Wrapper for the Spotify Web API. | ||||||||||||||||||||||||||||||||||||||||||
| 2256 | |||||||||||||||||||||||||||||||||||||||||||
| 2257 | https://developer.spotify.com/web-api/ | ||||||||||||||||||||||||||||||||||||||||||
| 2258 | |||||||||||||||||||||||||||||||||||||||||||
| 2259 | Have access to a JSON viewer to help develop and debug. The Chrome JSON viewer is | ||||||||||||||||||||||||||||||||||||||||||
| 2260 | very good and provides the exact path of the item within the JSON in the lower left | ||||||||||||||||||||||||||||||||||||||||||
| 2261 | of the screen as you mouse over an element. | ||||||||||||||||||||||||||||||||||||||||||
| 2262 | |||||||||||||||||||||||||||||||||||||||||||
| 2263 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 2264 | |||||||||||||||||||||||||||||||||||||||||||
| 2265 | WWW::Spotify - Spotify Web API Wrapper | ||||||||||||||||||||||||||||||||||||||||||
| 2266 | |||||||||||||||||||||||||||||||||||||||||||
| 2267 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 2268 | |||||||||||||||||||||||||||||||||||||||||||
| 2269 | version 0.017 | ||||||||||||||||||||||||||||||||||||||||||
| 2270 | |||||||||||||||||||||||||||||||||||||||||||
| 2271 | =head1 CONSTRUCTOR ARGS | ||||||||||||||||||||||||||||||||||||||||||
| 2272 | |||||||||||||||||||||||||||||||||||||||||||
| 2273 | =head2 ua | ||||||||||||||||||||||||||||||||||||||||||
| 2274 | |||||||||||||||||||||||||||||||||||||||||||
| 2275 | You may provide your own user agent object to the constructor. This should be | ||||||||||||||||||||||||||||||||||||||||||
| 2276 | a L<LWP:UserAgent> or a subclass of it, like L<WWW::Mechanize>. If you are | ||||||||||||||||||||||||||||||||||||||||||
| 2277 | using L<WWW::Mechanize>, you may want to set autocheck off. To get extra | ||||||||||||||||||||||||||||||||||||||||||
| 2278 | debugging information, you can do something like this: | ||||||||||||||||||||||||||||||||||||||||||
| 2279 | |||||||||||||||||||||||||||||||||||||||||||
| 2280 | use LWP::ConsoleLogger::Easy qw( debug_ua ); | ||||||||||||||||||||||||||||||||||||||||||
| 2281 | use WWW::Mechanize (); | ||||||||||||||||||||||||||||||||||||||||||
| 2282 | use WWW::Spotify (); | ||||||||||||||||||||||||||||||||||||||||||
| 2283 | |||||||||||||||||||||||||||||||||||||||||||
| 2284 | my $mech = WWW::Mechanize->new( autocheck => 0 ); | ||||||||||||||||||||||||||||||||||||||||||
| 2285 | debug_ua( $mech ); | ||||||||||||||||||||||||||||||||||||||||||
| 2286 | my $spotify = WWW::Spotify->new( ua => $mech ) | ||||||||||||||||||||||||||||||||||||||||||
| 2287 | |||||||||||||||||||||||||||||||||||||||||||
| 2288 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 2289 | |||||||||||||||||||||||||||||||||||||||||||
| 2290 | =head2 auto_json_decode | ||||||||||||||||||||||||||||||||||||||||||
| 2291 | |||||||||||||||||||||||||||||||||||||||||||
| 2292 | When true results will be returned as JSON instead of a perl data structure | ||||||||||||||||||||||||||||||||||||||||||
| 2293 | |||||||||||||||||||||||||||||||||||||||||||
| 2294 | $spotify->auto_json_decode(1); | ||||||||||||||||||||||||||||||||||||||||||
| 2295 | |||||||||||||||||||||||||||||||||||||||||||
| 2296 | =head2 get | ||||||||||||||||||||||||||||||||||||||||||
| 2297 | |||||||||||||||||||||||||||||||||||||||||||
| 2298 | Returns a specific item or array of items from the JSON result of the | ||||||||||||||||||||||||||||||||||||||||||
| 2299 | last action. | ||||||||||||||||||||||||||||||||||||||||||
| 2300 | |||||||||||||||||||||||||||||||||||||||||||
| 2301 | $result = $spotify->search( | ||||||||||||||||||||||||||||||||||||||||||
| 2302 | 'tania bowra' , | ||||||||||||||||||||||||||||||||||||||||||
| 2303 | 'artist' , | ||||||||||||||||||||||||||||||||||||||||||
| 2304 | { limit => 15 , offset => 0 } | ||||||||||||||||||||||||||||||||||||||||||
| 2305 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2306 | |||||||||||||||||||||||||||||||||||||||||||
| 2307 | my $image_url = $spotify->get( 'artists.items[0].images[0].url' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2308 | |||||||||||||||||||||||||||||||||||||||||||
| 2309 | JSON::Path is the underlying library that actually parses the JSON. | ||||||||||||||||||||||||||||||||||||||||||
| 2310 | |||||||||||||||||||||||||||||||||||||||||||
| 2311 | =head2 query_full_url( $url , [needs o_auth] ) | ||||||||||||||||||||||||||||||||||||||||||
| 2312 | |||||||||||||||||||||||||||||||||||||||||||
| 2313 | Results from some calls (playlist for example) return full urls that can be in their entirety. This method allows you | ||||||||||||||||||||||||||||||||||||||||||
| 2314 | make a call to that url and use all of the o_auth and other features provided. | ||||||||||||||||||||||||||||||||||||||||||
| 2315 | |||||||||||||||||||||||||||||||||||||||||||
| 2316 | $spotify->query_full_url( "https://api.spotify.com/v1/users/spotify/playlists/06U6mm6KPtPIg9D4YGNEnu" , 1 ); | ||||||||||||||||||||||||||||||||||||||||||
| 2317 | |||||||||||||||||||||||||||||||||||||||||||
| 2318 | =head2 album | ||||||||||||||||||||||||||||||||||||||||||
| 2319 | |||||||||||||||||||||||||||||||||||||||||||
| 2320 | equivalent to /v1/albums/{id} | ||||||||||||||||||||||||||||||||||||||||||
| 2321 | |||||||||||||||||||||||||||||||||||||||||||
| 2322 | $spotify->album('0sNOF9WDwhWunNAHPD3Baj'); | ||||||||||||||||||||||||||||||||||||||||||
| 2323 | |||||||||||||||||||||||||||||||||||||||||||
| 2324 | used album vs albums since it is a singular request | ||||||||||||||||||||||||||||||||||||||||||
| 2325 | |||||||||||||||||||||||||||||||||||||||||||
| 2326 | =head2 albums | ||||||||||||||||||||||||||||||||||||||||||
| 2327 | |||||||||||||||||||||||||||||||||||||||||||
| 2328 | equivalent to /v1/albums?ids={ids} | ||||||||||||||||||||||||||||||||||||||||||
| 2329 | |||||||||||||||||||||||||||||||||||||||||||
| 2330 | $spotify->albums( '41MnTivkwTO3UUJ8DrqEJJ,6JWc4iAiJ9FjyK0B59ABb4,6UXCm6bOO4gFlDQZV5yL37' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2331 | |||||||||||||||||||||||||||||||||||||||||||
| 2332 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2333 | |||||||||||||||||||||||||||||||||||||||||||
| 2334 | $spotify->albums( [ '41MnTivkwTO3UUJ8DrqEJJ', | ||||||||||||||||||||||||||||||||||||||||||
| 2335 | '6JWc4iAiJ9FjyK0B59ABb4', | ||||||||||||||||||||||||||||||||||||||||||
| 2336 | '6UXCm6bOO4gFlDQZV5yL37' ] ); | ||||||||||||||||||||||||||||||||||||||||||
| 2337 | |||||||||||||||||||||||||||||||||||||||||||
| 2338 | =head2 albums_tracks | ||||||||||||||||||||||||||||||||||||||||||
| 2339 | |||||||||||||||||||||||||||||||||||||||||||
| 2340 | equivalent to /v1/albums/{id}/tracks | ||||||||||||||||||||||||||||||||||||||||||
| 2341 | |||||||||||||||||||||||||||||||||||||||||||
| 2342 | $spotify->albums_tracks('6akEvsycLGftJxYudPjmqK', | ||||||||||||||||||||||||||||||||||||||||||
| 2343 | { | ||||||||||||||||||||||||||||||||||||||||||
| 2344 | limit => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 2345 | offset => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 2346 | |||||||||||||||||||||||||||||||||||||||||||
| 2347 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2348 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2349 | |||||||||||||||||||||||||||||||||||||||||||
| 2350 | =head2 artist | ||||||||||||||||||||||||||||||||||||||||||
| 2351 | |||||||||||||||||||||||||||||||||||||||||||
| 2352 | equivalent to /v1/artists/{id} | ||||||||||||||||||||||||||||||||||||||||||
| 2353 | |||||||||||||||||||||||||||||||||||||||||||
| 2354 | $spotify->artist( '0LcJLqbBmaGUft1e9Mm8HV' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2355 | |||||||||||||||||||||||||||||||||||||||||||
| 2356 | used artist vs artists since it is a singular request and avoids collision with "artists" method | ||||||||||||||||||||||||||||||||||||||||||
| 2357 | |||||||||||||||||||||||||||||||||||||||||||
| 2358 | =head2 artists | ||||||||||||||||||||||||||||||||||||||||||
| 2359 | |||||||||||||||||||||||||||||||||||||||||||
| 2360 | equivalent to /v1/artists?ids={ids} | ||||||||||||||||||||||||||||||||||||||||||
| 2361 | |||||||||||||||||||||||||||||||||||||||||||
| 2362 | my $artists_multiple = '0oSGxfWSnnOXhD2fKuz2Gy,3dBVyJ7JuOMt4GE9607Qin'; | ||||||||||||||||||||||||||||||||||||||||||
| 2363 | |||||||||||||||||||||||||||||||||||||||||||
| 2364 | $spotify->artists( $artists_multiple ); | ||||||||||||||||||||||||||||||||||||||||||
| 2365 | |||||||||||||||||||||||||||||||||||||||||||
| 2366 | =head2 artist_albums | ||||||||||||||||||||||||||||||||||||||||||
| 2367 | |||||||||||||||||||||||||||||||||||||||||||
| 2368 | equivalent to /v1/artists/{id}/albums | ||||||||||||||||||||||||||||||||||||||||||
| 2369 | |||||||||||||||||||||||||||||||||||||||||||
| 2370 | $spotify->artist_albums( '1vCWHaC5f2uS3yhpwWbIA6' , | ||||||||||||||||||||||||||||||||||||||||||
| 2371 | { album_type => 'single', | ||||||||||||||||||||||||||||||||||||||||||
| 2372 | # country => 'US', | ||||||||||||||||||||||||||||||||||||||||||
| 2373 | limit => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 2374 | offset => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 2375 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 2376 | |||||||||||||||||||||||||||||||||||||||||||
| 2377 | =head2 artist_top_tracks | ||||||||||||||||||||||||||||||||||||||||||
| 2378 | |||||||||||||||||||||||||||||||||||||||||||
| 2379 | equivalent to /v1/artists/{id}/top-tracks | ||||||||||||||||||||||||||||||||||||||||||
| 2380 | |||||||||||||||||||||||||||||||||||||||||||
| 2381 | $spotify->artist_top_tracks( '43ZHCT0cAZBISjO8DG9PnE', # artist id | ||||||||||||||||||||||||||||||||||||||||||
| 2382 | 'SE' # country | ||||||||||||||||||||||||||||||||||||||||||
| 2383 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2384 | |||||||||||||||||||||||||||||||||||||||||||
| 2385 | =head2 artist_related_artists | ||||||||||||||||||||||||||||||||||||||||||
| 2386 | |||||||||||||||||||||||||||||||||||||||||||
| 2387 | equivalent to /v1/artists/{id}/related-artists | ||||||||||||||||||||||||||||||||||||||||||
| 2388 | |||||||||||||||||||||||||||||||||||||||||||
| 2389 | $spotify->artist_related_artists( '43ZHCT0cAZBISjO8DG9PnE' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2390 | |||||||||||||||||||||||||||||||||||||||||||
| 2391 | =head2 search | ||||||||||||||||||||||||||||||||||||||||||
| 2392 | |||||||||||||||||||||||||||||||||||||||||||
| 2393 | equivalent to /v1/search?type=album (etc) | ||||||||||||||||||||||||||||||||||||||||||
| 2394 | |||||||||||||||||||||||||||||||||||||||||||
| 2395 | $spotify->search( | ||||||||||||||||||||||||||||||||||||||||||
| 2396 | 'tania bowra' , | ||||||||||||||||||||||||||||||||||||||||||
| 2397 | 'artist' , | ||||||||||||||||||||||||||||||||||||||||||
| 2398 | { limit => 10 , offset => 0 } | ||||||||||||||||||||||||||||||||||||||||||
| 2399 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2400 | |||||||||||||||||||||||||||||||||||||||||||
| 2401 | Note: as of the February 2026 API changes the maximum C<limit> is 10 | ||||||||||||||||||||||||||||||||||||||||||
| 2402 | (previously 50); use C<offset> to paginate. | ||||||||||||||||||||||||||||||||||||||||||
| 2403 | |||||||||||||||||||||||||||||||||||||||||||
| 2404 | =head2 track | ||||||||||||||||||||||||||||||||||||||||||
| 2405 | |||||||||||||||||||||||||||||||||||||||||||
| 2406 | equivalent to /v1/tracks/{id} | ||||||||||||||||||||||||||||||||||||||||||
| 2407 | |||||||||||||||||||||||||||||||||||||||||||
| 2408 | $spotify->track( '0eGsygTp906u18L0Oimnem' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2409 | |||||||||||||||||||||||||||||||||||||||||||
| 2410 | =head2 tracks | ||||||||||||||||||||||||||||||||||||||||||
| 2411 | |||||||||||||||||||||||||||||||||||||||||||
| 2412 | equivalent to /v1/tracks?ids={ids} | ||||||||||||||||||||||||||||||||||||||||||
| 2413 | |||||||||||||||||||||||||||||||||||||||||||
| 2414 | $spotify->tracks( '0eGsygTp906u18L0Oimnem,1lDWb6b6ieDQ2xT7ewTC3G' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2415 | |||||||||||||||||||||||||||||||||||||||||||
| 2416 | =head2 browse_featured_playlists | ||||||||||||||||||||||||||||||||||||||||||
| 2417 | |||||||||||||||||||||||||||||||||||||||||||
| 2418 | equivalent to /v1/browse/featured-playlists | ||||||||||||||||||||||||||||||||||||||||||
| 2419 | |||||||||||||||||||||||||||||||||||||||||||
| 2420 | $spotify->browse_featured_playlists(); | ||||||||||||||||||||||||||||||||||||||||||
| 2421 | |||||||||||||||||||||||||||||||||||||||||||
| 2422 | requires OAuth | ||||||||||||||||||||||||||||||||||||||||||
| 2423 | |||||||||||||||||||||||||||||||||||||||||||
| 2424 | =head2 browse_new_releases | ||||||||||||||||||||||||||||||||||||||||||
| 2425 | |||||||||||||||||||||||||||||||||||||||||||
| 2426 | equivalent to /v1/browse/new-releases | ||||||||||||||||||||||||||||||||||||||||||
| 2427 | |||||||||||||||||||||||||||||||||||||||||||
| 2428 | requires OAuth | ||||||||||||||||||||||||||||||||||||||||||
| 2429 | |||||||||||||||||||||||||||||||||||||||||||
| 2430 | $spotify->browse_new_releases | ||||||||||||||||||||||||||||||||||||||||||
| 2431 | |||||||||||||||||||||||||||||||||||||||||||
| 2432 | =head2 force_client_auth | ||||||||||||||||||||||||||||||||||||||||||
| 2433 | |||||||||||||||||||||||||||||||||||||||||||
| 2434 | Boolean | ||||||||||||||||||||||||||||||||||||||||||
| 2435 | |||||||||||||||||||||||||||||||||||||||||||
| 2436 | will pass authentication (OAuth) on all requests when set | ||||||||||||||||||||||||||||||||||||||||||
| 2437 | |||||||||||||||||||||||||||||||||||||||||||
| 2438 | $spotify->force_client_auth(1); | ||||||||||||||||||||||||||||||||||||||||||
| 2439 | |||||||||||||||||||||||||||||||||||||||||||
| 2440 | =head2 user | ||||||||||||||||||||||||||||||||||||||||||
| 2441 | |||||||||||||||||||||||||||||||||||||||||||
| 2442 | equivalent to /v1/users/{user_id} | ||||||||||||||||||||||||||||||||||||||||||
| 2443 | |||||||||||||||||||||||||||||||||||||||||||
| 2444 | $spotify->user('glennpmcdonald'); | ||||||||||||||||||||||||||||||||||||||||||
| 2445 | |||||||||||||||||||||||||||||||||||||||||||
| 2446 | =head2 get_playlist | ||||||||||||||||||||||||||||||||||||||||||
| 2447 | |||||||||||||||||||||||||||||||||||||||||||
| 2448 | equivalent to GET /v1/playlists/{playlist_id} | ||||||||||||||||||||||||||||||||||||||||||
| 2449 | |||||||||||||||||||||||||||||||||||||||||||
| 2450 | $spotify->get_playlist('37i9dQZF1DXcBWIGoYBM5M'); | ||||||||||||||||||||||||||||||||||||||||||
| 2451 | |||||||||||||||||||||||||||||||||||||||||||
| 2452 | This method retrieves a playlist owned by a Spotify user. The playlist must be public or owned by the authenticated user. | ||||||||||||||||||||||||||||||||||||||||||
| 2453 | |||||||||||||||||||||||||||||||||||||||||||
| 2454 | =head2 get_playlist_items | ||||||||||||||||||||||||||||||||||||||||||
| 2455 | |||||||||||||||||||||||||||||||||||||||||||
| 2456 | equivalent to /v1/playlists/{playlist_id}/items (renamed from /tracks in the | ||||||||||||||||||||||||||||||||||||||||||
| 2457 | February 2026 API changes) | ||||||||||||||||||||||||||||||||||||||||||
| 2458 | |||||||||||||||||||||||||||||||||||||||||||
| 2459 | $spotify->get_playlist_items('37i9dQZF1DXcBWIGoYBM5M', { limit => 10, offset => 0 }); | ||||||||||||||||||||||||||||||||||||||||||
| 2460 | |||||||||||||||||||||||||||||||||||||||||||
| 2461 | =head2 create_playlist | ||||||||||||||||||||||||||||||||||||||||||
| 2462 | |||||||||||||||||||||||||||||||||||||||||||
| 2463 | equivalent to POST /v1/me/playlists (replaced /v1/users/{user_id}/playlists | ||||||||||||||||||||||||||||||||||||||||||
| 2464 | in the February 2026 API changes) - creates a playlist for the | ||||||||||||||||||||||||||||||||||||||||||
| 2465 | authenticated user | ||||||||||||||||||||||||||||||||||||||||||
| 2466 | |||||||||||||||||||||||||||||||||||||||||||
| 2467 | $spotify->create_playlist('My New Playlist', 1, 'A description of my playlist'); | ||||||||||||||||||||||||||||||||||||||||||
| 2468 | |||||||||||||||||||||||||||||||||||||||||||
| 2469 | =head2 get_current_user_playlists | ||||||||||||||||||||||||||||||||||||||||||
| 2470 | |||||||||||||||||||||||||||||||||||||||||||
| 2471 | equivalent to /v1/me/playlists | ||||||||||||||||||||||||||||||||||||||||||
| 2472 | |||||||||||||||||||||||||||||||||||||||||||
| 2473 | $spotify->get_current_user_playlists({ limit => 20, offset => 0 }); | ||||||||||||||||||||||||||||||||||||||||||
| 2474 | |||||||||||||||||||||||||||||||||||||||||||
| 2475 | =head2 add_items_to_playlist | ||||||||||||||||||||||||||||||||||||||||||
| 2476 | |||||||||||||||||||||||||||||||||||||||||||
| 2477 | equivalent to /v1/playlists/{playlist_id}/items (renamed from /tracks in the | ||||||||||||||||||||||||||||||||||||||||||
| 2478 | February 2026 API changes) | ||||||||||||||||||||||||||||||||||||||||||
| 2479 | |||||||||||||||||||||||||||||||||||||||||||
| 2480 | $spotify->add_items_to_playlist('playlist_id', ['spotify:track:4iV5W9uYEdYUVa79Axb7Rh', 'spotify:track:1301WleyT98MSxVHPZCA6M'], 0); | ||||||||||||||||||||||||||||||||||||||||||
| 2481 | |||||||||||||||||||||||||||||||||||||||||||
| 2482 | =head2 unfollow_playlist | ||||||||||||||||||||||||||||||||||||||||||
| 2483 | |||||||||||||||||||||||||||||||||||||||||||
| 2484 | equivalent to DELETE /v1/playlists/{playlist_id}/followers - removes the | ||||||||||||||||||||||||||||||||||||||||||
| 2485 | playlist from the authenticated user's library (Spotify has no hard | ||||||||||||||||||||||||||||||||||||||||||
| 2486 | playlist delete) | ||||||||||||||||||||||||||||||||||||||||||
| 2487 | |||||||||||||||||||||||||||||||||||||||||||
| 2488 | $spotify->unfollow_playlist('playlist_id'); | ||||||||||||||||||||||||||||||||||||||||||
| 2489 | |||||||||||||||||||||||||||||||||||||||||||
| 2490 | =head2 remove_user_saved_tracks | ||||||||||||||||||||||||||||||||||||||||||
| 2491 | |||||||||||||||||||||||||||||||||||||||||||
| 2492 | equivalent to /v1/me/tracks | ||||||||||||||||||||||||||||||||||||||||||
| 2493 | |||||||||||||||||||||||||||||||||||||||||||
| 2494 | $spotify->remove_user_saved_tracks(['4iV5W9uYEdYUVa79Axb7Rh', '1301WleyT98MSxVHPZCA6M']); | ||||||||||||||||||||||||||||||||||||||||||
| 2495 | |||||||||||||||||||||||||||||||||||||||||||
| 2496 | =head2 check_users_saved_tracks | ||||||||||||||||||||||||||||||||||||||||||
| 2497 | |||||||||||||||||||||||||||||||||||||||||||
| 2498 | equivalent to /v1/me/tracks/contains | ||||||||||||||||||||||||||||||||||||||||||
| 2499 | |||||||||||||||||||||||||||||||||||||||||||
| 2500 | $spotify->check_users_saved_tracks(['4iV5W9uYEdYUVa79Axb7Rh', '1301WleyT98MSxVHPZCA6M']); | ||||||||||||||||||||||||||||||||||||||||||
| 2501 | |||||||||||||||||||||||||||||||||||||||||||
| 2502 | =head2 check_users_saved_shows | ||||||||||||||||||||||||||||||||||||||||||
| 2503 | |||||||||||||||||||||||||||||||||||||||||||
| 2504 | equivalent to GET /v1/me/shows/contains | ||||||||||||||||||||||||||||||||||||||||||
| 2505 | |||||||||||||||||||||||||||||||||||||||||||
| 2506 | $spotify->check_users_saved_shows(['5CfCWKI5pZ28U0uOzXkDHe', '5as3aKmN2k11yfDDDSrvaZ']); | ||||||||||||||||||||||||||||||||||||||||||
| 2507 | |||||||||||||||||||||||||||||||||||||||||||
| 2508 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2509 | |||||||||||||||||||||||||||||||||||||||||||
| 2510 | $spotify->check_users_saved_shows('5CfCWKI5pZ28U0uOzXkDHe,5as3aKmN2k11yfDDDSrvaZ'); | ||||||||||||||||||||||||||||||||||||||||||
| 2511 | |||||||||||||||||||||||||||||||||||||||||||
| 2512 | This method checks if one or more shows are already saved in the current Spotify user's library. | ||||||||||||||||||||||||||||||||||||||||||
| 2513 | |||||||||||||||||||||||||||||||||||||||||||
| 2514 | =head2 get_several_tracks_audio_features | ||||||||||||||||||||||||||||||||||||||||||
| 2515 | |||||||||||||||||||||||||||||||||||||||||||
| 2516 | equivalent to /v1/audio-features | ||||||||||||||||||||||||||||||||||||||||||
| 2517 | |||||||||||||||||||||||||||||||||||||||||||
| 2518 | $spotify->get_several_tracks_audio_features(['4iV5W9uYEdYUVa79Axb7Rh', '1301WleyT98MSxVHPZCA6M']); | ||||||||||||||||||||||||||||||||||||||||||
| 2519 | |||||||||||||||||||||||||||||||||||||||||||
| 2520 | =head2 get_track_audio_features | ||||||||||||||||||||||||||||||||||||||||||
| 2521 | |||||||||||||||||||||||||||||||||||||||||||
| 2522 | equivalent to /v1/audio-features/{id} | ||||||||||||||||||||||||||||||||||||||||||
| 2523 | |||||||||||||||||||||||||||||||||||||||||||
| 2524 | $spotify->get_track_audio_features('4iV5W9uYEdYUVa79Axb7Rh'); | ||||||||||||||||||||||||||||||||||||||||||
| 2525 | |||||||||||||||||||||||||||||||||||||||||||
| 2526 | =head2 get_track_audio_analysis | ||||||||||||||||||||||||||||||||||||||||||
| 2527 | |||||||||||||||||||||||||||||||||||||||||||
| 2528 | equivalent to /v1/audio-analysis/{id} | ||||||||||||||||||||||||||||||||||||||||||
| 2529 | |||||||||||||||||||||||||||||||||||||||||||
| 2530 | $spotify->get_track_audio_analysis('4iV5W9uYEdYUVa79Axb7Rh'); | ||||||||||||||||||||||||||||||||||||||||||
| 2531 | |||||||||||||||||||||||||||||||||||||||||||
| 2532 | =head2 get_recommendations | ||||||||||||||||||||||||||||||||||||||||||
| 2533 | |||||||||||||||||||||||||||||||||||||||||||
| 2534 | equivalent to /v1/recommendations | ||||||||||||||||||||||||||||||||||||||||||
| 2535 | |||||||||||||||||||||||||||||||||||||||||||
| 2536 | $spotify->get_recommendations( | ||||||||||||||||||||||||||||||||||||||||||
| 2537 | seed_artists => '4NHQUGzhtTLFvgF5SZesLK', | ||||||||||||||||||||||||||||||||||||||||||
| 2538 | seed_genres => 'classical,country', | ||||||||||||||||||||||||||||||||||||||||||
| 2539 | seed_tracks => '0c6xIDDpzE81m2q797ordA', | ||||||||||||||||||||||||||||||||||||||||||
| 2540 | limit => 10, | ||||||||||||||||||||||||||||||||||||||||||
| 2541 | market => 'ES' | ||||||||||||||||||||||||||||||||||||||||||
| 2542 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2543 | |||||||||||||||||||||||||||||||||||||||||||
| 2544 | =head2 get_followed_artists | ||||||||||||||||||||||||||||||||||||||||||
| 2545 | |||||||||||||||||||||||||||||||||||||||||||
| 2546 | equivalent to /v1/me/following | ||||||||||||||||||||||||||||||||||||||||||
| 2547 | |||||||||||||||||||||||||||||||||||||||||||
| 2548 | $spotify->get_followed_artists( | ||||||||||||||||||||||||||||||||||||||||||
| 2549 | limit => 20, | ||||||||||||||||||||||||||||||||||||||||||
| 2550 | after => '0I2XqVXqHScXjHhk6AYYRe' | ||||||||||||||||||||||||||||||||||||||||||
| 2551 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2552 | |||||||||||||||||||||||||||||||||||||||||||
| 2553 | Note: This method always sets the 'type' parameter to 'artist' as it's the only supported value. | ||||||||||||||||||||||||||||||||||||||||||
| 2554 | |||||||||||||||||||||||||||||||||||||||||||
| 2555 | =head2 follow_artists_or_users | ||||||||||||||||||||||||||||||||||||||||||
| 2556 | |||||||||||||||||||||||||||||||||||||||||||
| 2557 | equivalent to PUT /v1/me/following | ||||||||||||||||||||||||||||||||||||||||||
| 2558 | |||||||||||||||||||||||||||||||||||||||||||
| 2559 | $spotify->follow_artists_or_users('artist', ['2CIMQHirSU0MQqyYHq0eOx', '57dN52uHvrHOxijzpIgu3E']); | ||||||||||||||||||||||||||||||||||||||||||
| 2560 | |||||||||||||||||||||||||||||||||||||||||||
| 2561 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2562 | |||||||||||||||||||||||||||||||||||||||||||
| 2563 | $spotify->follow_artists_or_users('user', '2CIMQHirSU0MQqyYHq0eOx,57dN52uHvrHOxijzpIgu3E'); | ||||||||||||||||||||||||||||||||||||||||||
| 2564 | |||||||||||||||||||||||||||||||||||||||||||
| 2565 | =head2 unfollow_artists_or_users | ||||||||||||||||||||||||||||||||||||||||||
| 2566 | |||||||||||||||||||||||||||||||||||||||||||
| 2567 | equivalent to DELETE /v1/me/following | ||||||||||||||||||||||||||||||||||||||||||
| 2568 | |||||||||||||||||||||||||||||||||||||||||||
| 2569 | $spotify->unfollow_artists_or_users('artist', ['2CIMQHirSU0MQqyYHq0eOx', '57dN52uHvrHOxijzpIgu3E']); | ||||||||||||||||||||||||||||||||||||||||||
| 2570 | |||||||||||||||||||||||||||||||||||||||||||
| 2571 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2572 | |||||||||||||||||||||||||||||||||||||||||||
| 2573 | $spotify->unfollow_artists_or_users('user', '2CIMQHirSU0MQqyYHq0eOx,57dN52uHvrHOxijzpIgu3E'); | ||||||||||||||||||||||||||||||||||||||||||
| 2574 | |||||||||||||||||||||||||||||||||||||||||||
| 2575 | =head2 check_if_user_follows_artists_or_users | ||||||||||||||||||||||||||||||||||||||||||
| 2576 | |||||||||||||||||||||||||||||||||||||||||||
| 2577 | equivalent to GET /v1/me/following/contains | ||||||||||||||||||||||||||||||||||||||||||
| 2578 | |||||||||||||||||||||||||||||||||||||||||||
| 2579 | $spotify->check_if_user_follows_artists_or_users('artist', ['2CIMQHirSU0MQqyYHq0eOx', '57dN52uHvrHOxijzpIgu3E']); | ||||||||||||||||||||||||||||||||||||||||||
| 2580 | |||||||||||||||||||||||||||||||||||||||||||
| 2581 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2582 | |||||||||||||||||||||||||||||||||||||||||||
| 2583 | $spotify->check_if_user_follows_artists_or_users('user', '2CIMQHirSU0MQqyYHq0eOx,57dN52uHvrHOxijzpIgu3E'); | ||||||||||||||||||||||||||||||||||||||||||
| 2584 | |||||||||||||||||||||||||||||||||||||||||||
| 2585 | =head2 check_if_user_follows_playlist | ||||||||||||||||||||||||||||||||||||||||||
| 2586 | |||||||||||||||||||||||||||||||||||||||||||
| 2587 | equivalent to GET /v1/playlists/{playlist_id}/followers/contains | ||||||||||||||||||||||||||||||||||||||||||
| 2588 | |||||||||||||||||||||||||||||||||||||||||||
| 2589 | $spotify->check_if_user_follows_playlist('3cEYpjA9oz9GiPac4AsH4n', 'jmperezperez'); | ||||||||||||||||||||||||||||||||||||||||||
| 2590 | |||||||||||||||||||||||||||||||||||||||||||
| 2591 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2592 | |||||||||||||||||||||||||||||||||||||||||||
| 2593 | $spotify->check_if_user_follows_playlist('3cEYpjA9oz9GiPac4AsH4n', ['jmperezperez']); | ||||||||||||||||||||||||||||||||||||||||||
| 2594 | |||||||||||||||||||||||||||||||||||||||||||
| 2595 | =head2 save_library_items | ||||||||||||||||||||||||||||||||||||||||||
| 2596 | |||||||||||||||||||||||||||||||||||||||||||
| 2597 | equivalent to PUT /v1/me/library (February 2026 consolidated library | ||||||||||||||||||||||||||||||||||||||||||
| 2598 | endpoint; replaces the removed PUT /v1/me/tracks, /v1/me/albums, | ||||||||||||||||||||||||||||||||||||||||||
| 2599 | /v1/me/episodes, /v1/me/shows, /v1/me/audiobooks, /v1/me/following and | ||||||||||||||||||||||||||||||||||||||||||
| 2600 | /v1/playlists/{id}/followers endpoints) | ||||||||||||||||||||||||||||||||||||||||||
| 2601 | |||||||||||||||||||||||||||||||||||||||||||
| 2602 | Takes Spotify URIs (not bare ids), as a comma-separated string or an | ||||||||||||||||||||||||||||||||||||||||||
| 2603 | array reference. Maximum 40 URIs. | ||||||||||||||||||||||||||||||||||||||||||
| 2604 | |||||||||||||||||||||||||||||||||||||||||||
| 2605 | $spotify->save_library_items( [ 'spotify:track:7a3LWj5xSFhFRYmztS8wgK', | ||||||||||||||||||||||||||||||||||||||||||
| 2606 | 'spotify:album:4aawyAB9vmqN3uQ7FjRGTy' ] ); | ||||||||||||||||||||||||||||||||||||||||||
| 2607 | |||||||||||||||||||||||||||||||||||||||||||
| 2608 | =head2 remove_library_items | ||||||||||||||||||||||||||||||||||||||||||
| 2609 | |||||||||||||||||||||||||||||||||||||||||||
| 2610 | equivalent to DELETE /v1/me/library (February 2026 consolidated library | ||||||||||||||||||||||||||||||||||||||||||
| 2611 | endpoint; replaces the removed per-type DELETE endpoints) | ||||||||||||||||||||||||||||||||||||||||||
| 2612 | |||||||||||||||||||||||||||||||||||||||||||
| 2613 | $spotify->remove_library_items( 'spotify:track:7a3LWj5xSFhFRYmztS8wgK' ); | ||||||||||||||||||||||||||||||||||||||||||
| 2614 | |||||||||||||||||||||||||||||||||||||||||||
| 2615 | =head2 check_library_items | ||||||||||||||||||||||||||||||||||||||||||
| 2616 | |||||||||||||||||||||||||||||||||||||||||||
| 2617 | equivalent to GET /v1/me/library/contains (February 2026 consolidated | ||||||||||||||||||||||||||||||||||||||||||
| 2618 | library endpoint; replaces the removed per-type */contains endpoints) | ||||||||||||||||||||||||||||||||||||||||||
| 2619 | |||||||||||||||||||||||||||||||||||||||||||
| 2620 | $spotify->check_library_items( [ 'spotify:track:7a3LWj5xSFhFRYmztS8wgK' ] ); | ||||||||||||||||||||||||||||||||||||||||||
| 2621 | |||||||||||||||||||||||||||||||||||||||||||
| 2622 | =head2 DEPRECATED METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 2623 | |||||||||||||||||||||||||||||||||||||||||||
| 2624 | Spotify's November 2024 and February 2026 API changes removed or | ||||||||||||||||||||||||||||||||||||||||||
| 2625 | deprecated a number of endpoints. The corresponding methods are kept | ||||||||||||||||||||||||||||||||||||||||||
| 2626 | for backwards compatibility but warn once per process when called, and | ||||||||||||||||||||||||||||||||||||||||||
| 2627 | Spotify will reject the request: | ||||||||||||||||||||||||||||||||||||||||||
| 2628 | |||||||||||||||||||||||||||||||||||||||||||
| 2629 | batch fetch (removed - fetch individually instead): C<albums>, C<artists>, | ||||||||||||||||||||||||||||||||||||||||||
| 2630 | C<tracks>, C<get_several_shows>, C<get_several_audiobooks>, | ||||||||||||||||||||||||||||||||||||||||||
| 2631 | C<get_several_chapters>, C<get_several_tracks_audio_features> | ||||||||||||||||||||||||||||||||||||||||||
| 2632 | |||||||||||||||||||||||||||||||||||||||||||
| 2633 | browse/artist (removed): C<browse_featured_playlists>, | ||||||||||||||||||||||||||||||||||||||||||
| 2634 | C<browse_new_releases>, C<get_categories>, C<get_category>, | ||||||||||||||||||||||||||||||||||||||||||
| 2635 | C<artist_top_tracks>, C<artist_related_artists> | ||||||||||||||||||||||||||||||||||||||||||
| 2636 | |||||||||||||||||||||||||||||||||||||||||||
| 2637 | audio/recommendations (deprecated): C<get_track_audio_features>, | ||||||||||||||||||||||||||||||||||||||||||
| 2638 | C<get_track_audio_analysis>, C<get_recommendations>, | ||||||||||||||||||||||||||||||||||||||||||
| 2639 | C<get_available_genre_seeds> | ||||||||||||||||||||||||||||||||||||||||||
| 2640 | |||||||||||||||||||||||||||||||||||||||||||
| 2641 | library (consolidated into /v1/me/library - use C<save_library_items>, | ||||||||||||||||||||||||||||||||||||||||||
| 2642 | C<remove_library_items>, C<check_library_items>): | ||||||||||||||||||||||||||||||||||||||||||
| 2643 | C<remove_user_saved_tracks>, C<check_users_saved_tracks>, | ||||||||||||||||||||||||||||||||||||||||||
| 2644 | C<save_shows_for_current_user>, C<check_users_saved_shows>, | ||||||||||||||||||||||||||||||||||||||||||
| 2645 | C<save_audiobooks_for_current_user>, C<remove_users_saved_audiobooks>, | ||||||||||||||||||||||||||||||||||||||||||
| 2646 | C<check_users_saved_audiobooks>, C<follow_artists_or_users>, | ||||||||||||||||||||||||||||||||||||||||||
| 2647 | C<unfollow_artists_or_users>, C<check_if_user_follows_artists_or_users>, | ||||||||||||||||||||||||||||||||||||||||||
| 2648 | C<check_if_user_follows_playlist> | ||||||||||||||||||||||||||||||||||||||||||
| 2649 | |||||||||||||||||||||||||||||||||||||||||||
| 2650 | other: C<user> (GET /v1/users/{user_id} deprecated/removed) | ||||||||||||||||||||||||||||||||||||||||||
| 2651 | |||||||||||||||||||||||||||||||||||||||||||
| 2652 | =head2 get_audiobook | ||||||||||||||||||||||||||||||||||||||||||
| 2653 | |||||||||||||||||||||||||||||||||||||||||||
| 2654 | equivalent to GET /v1/audiobooks/{id} | ||||||||||||||||||||||||||||||||||||||||||
| 2655 | |||||||||||||||||||||||||||||||||||||||||||
| 2656 | $spotify->get_audiobook('7iHfbu1YPACw6oZPAFJtqe'); | ||||||||||||||||||||||||||||||||||||||||||
| 2657 | |||||||||||||||||||||||||||||||||||||||||||
| 2658 | or with market parameter: | ||||||||||||||||||||||||||||||||||||||||||
| 2659 | |||||||||||||||||||||||||||||||||||||||||||
| 2660 | $spotify->get_audiobook('7iHfbu1YPACw6oZPAFJtqe', 'US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2661 | |||||||||||||||||||||||||||||||||||||||||||
| 2662 | =head2 get_users_saved_audiobooks | ||||||||||||||||||||||||||||||||||||||||||
| 2663 | |||||||||||||||||||||||||||||||||||||||||||
| 2664 | equivalent to GET /v1/me/audiobooks | ||||||||||||||||||||||||||||||||||||||||||
| 2665 | |||||||||||||||||||||||||||||||||||||||||||
| 2666 | $spotify->get_users_saved_audiobooks(20, 0); | ||||||||||||||||||||||||||||||||||||||||||
| 2667 | |||||||||||||||||||||||||||||||||||||||||||
| 2668 | =head2 remove_users_saved_audiobooks | ||||||||||||||||||||||||||||||||||||||||||
| 2669 | |||||||||||||||||||||||||||||||||||||||||||
| 2670 | equivalent to DELETE /v1/me/audiobooks | ||||||||||||||||||||||||||||||||||||||||||
| 2671 | |||||||||||||||||||||||||||||||||||||||||||
| 2672 | $spotify->remove_users_saved_audiobooks(['18yVqkdbdRvS24c0Ilj2ci', '1HGw3J3NxZO1TP1BTtVhpZ']); | ||||||||||||||||||||||||||||||||||||||||||
| 2673 | |||||||||||||||||||||||||||||||||||||||||||
| 2674 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2675 | |||||||||||||||||||||||||||||||||||||||||||
| 2676 | $spotify->remove_users_saved_audiobooks('18yVqkdbdRvS24c0Ilj2ci,1HGw3J3NxZO1TP1BTtVhpZ'); | ||||||||||||||||||||||||||||||||||||||||||
| 2677 | |||||||||||||||||||||||||||||||||||||||||||
| 2678 | This method removes one or more audiobooks from the current user's library. | ||||||||||||||||||||||||||||||||||||||||||
| 2679 | |||||||||||||||||||||||||||||||||||||||||||
| 2680 | =head2 get_available_genre_seeds | ||||||||||||||||||||||||||||||||||||||||||
| 2681 | |||||||||||||||||||||||||||||||||||||||||||
| 2682 | equivalent to GET /v1/recommendations/available-genre-seeds | ||||||||||||||||||||||||||||||||||||||||||
| 2683 | |||||||||||||||||||||||||||||||||||||||||||
| 2684 | $spotify->get_available_genre_seeds(); | ||||||||||||||||||||||||||||||||||||||||||
| 2685 | |||||||||||||||||||||||||||||||||||||||||||
| 2686 | This method retrieves a list of available genres seed parameter values for recommendations. | ||||||||||||||||||||||||||||||||||||||||||
| 2687 | |||||||||||||||||||||||||||||||||||||||||||
| 2688 | =head2 get_available_markets | ||||||||||||||||||||||||||||||||||||||||||
| 2689 | |||||||||||||||||||||||||||||||||||||||||||
| 2690 | equivalent to GET /v1/markets | ||||||||||||||||||||||||||||||||||||||||||
| 2691 | |||||||||||||||||||||||||||||||||||||||||||
| 2692 | $spotify->get_available_markets(); | ||||||||||||||||||||||||||||||||||||||||||
| 2693 | |||||||||||||||||||||||||||||||||||||||||||
| 2694 | This method retrieves the list of markets where Spotify is available. | ||||||||||||||||||||||||||||||||||||||||||
| 2695 | |||||||||||||||||||||||||||||||||||||||||||
| 2696 | =head2 get_show | ||||||||||||||||||||||||||||||||||||||||||
| 2697 | |||||||||||||||||||||||||||||||||||||||||||
| 2698 | equivalent to GET /v1/shows/{id} | ||||||||||||||||||||||||||||||||||||||||||
| 2699 | |||||||||||||||||||||||||||||||||||||||||||
| 2700 | $spotify->get_show('38bS44xjbVVZ3No3ByF1dJ', 'US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2701 | |||||||||||||||||||||||||||||||||||||||||||
| 2702 | This method retrieves Spotify catalog information for a single show identified by its unique Spotify ID. | ||||||||||||||||||||||||||||||||||||||||||
| 2703 | |||||||||||||||||||||||||||||||||||||||||||
| 2704 | =head2 get_several_shows | ||||||||||||||||||||||||||||||||||||||||||
| 2705 | |||||||||||||||||||||||||||||||||||||||||||
| 2706 | equivalent to GET /v1/shows | ||||||||||||||||||||||||||||||||||||||||||
| 2707 | |||||||||||||||||||||||||||||||||||||||||||
| 2708 | $spotify->get_several_shows(['5CfCWKI5pZ28U0uOzXkDHe', '5as3aKmN2k11yfDDDSrvaZ'], 'US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2709 | |||||||||||||||||||||||||||||||||||||||||||
| 2710 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2711 | |||||||||||||||||||||||||||||||||||||||||||
| 2712 | $spotify->get_several_shows('5CfCWKI5pZ28U0uOzXkDHe,5as3aKmN2k11yfDDDSrvaZ', 'US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2713 | |||||||||||||||||||||||||||||||||||||||||||
| 2714 | This method retrieves Spotify catalog information for several shows based on their Spotify IDs. | ||||||||||||||||||||||||||||||||||||||||||
| 2715 | |||||||||||||||||||||||||||||||||||||||||||
| 2716 | =head2 get_show_episodes | ||||||||||||||||||||||||||||||||||||||||||
| 2717 | |||||||||||||||||||||||||||||||||||||||||||
| 2718 | equivalent to GET /v1/shows/{id}/episodes | ||||||||||||||||||||||||||||||||||||||||||
| 2719 | |||||||||||||||||||||||||||||||||||||||||||
| 2720 | $spotify->get_show_episodes('38bS44xjbVVZ3No3ByF1dJ', market => 'US', limit => 10, offset => 5); | ||||||||||||||||||||||||||||||||||||||||||
| 2721 | |||||||||||||||||||||||||||||||||||||||||||
| 2722 | This method retrieves Spotify catalog information about a show's episodes. Optional parameters can be used to limit the number of episodes returned. | ||||||||||||||||||||||||||||||||||||||||||
| 2723 | |||||||||||||||||||||||||||||||||||||||||||
| 2724 | =head2 get_audiobook_chapters | ||||||||||||||||||||||||||||||||||||||||||
| 2725 | |||||||||||||||||||||||||||||||||||||||||||
| 2726 | equivalent to GET /v1/audiobooks/{id}/chapters | ||||||||||||||||||||||||||||||||||||||||||
| 2727 | |||||||||||||||||||||||||||||||||||||||||||
| 2728 | $spotify->get_audiobook_chapters('3ZXb8FKZGU0EHALYX6uCzU', market => 'US', limit => 50, offset => 0); | ||||||||||||||||||||||||||||||||||||||||||
| 2729 | |||||||||||||||||||||||||||||||||||||||||||
| 2730 | This method retrieves the chapters of an audiobook. | ||||||||||||||||||||||||||||||||||||||||||
| 2731 | |||||||||||||||||||||||||||||||||||||||||||
| 2732 | =head2 get_several_audiobooks | ||||||||||||||||||||||||||||||||||||||||||
| 2733 | |||||||||||||||||||||||||||||||||||||||||||
| 2734 | equivalent to GET /v1/audiobooks | ||||||||||||||||||||||||||||||||||||||||||
| 2735 | |||||||||||||||||||||||||||||||||||||||||||
| 2736 | $spotify->get_several_audiobooks(['18yVqkdbdRvS24c0Ilj2ci', '1HGw3J3NxZO1TP1BTtVhpZ'], 'US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2737 | |||||||||||||||||||||||||||||||||||||||||||
| 2738 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2739 | |||||||||||||||||||||||||||||||||||||||||||
| 2740 | $spotify->get_several_audiobooks('18yVqkdbdRvS24c0Ilj2ci,1HGw3J3NxZO1TP1BTtVhpZ', 'US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2741 | |||||||||||||||||||||||||||||||||||||||||||
| 2742 | This method retrieves multiple audiobooks based on their Spotify IDs. | ||||||||||||||||||||||||||||||||||||||||||
| 2743 | |||||||||||||||||||||||||||||||||||||||||||
| 2744 | =head2 send_delete_request | ||||||||||||||||||||||||||||||||||||||||||
| 2745 | |||||||||||||||||||||||||||||||||||||||||||
| 2746 | Internal method used to send DELETE requests to the Spotify API. | ||||||||||||||||||||||||||||||||||||||||||
| 2747 | |||||||||||||||||||||||||||||||||||||||||||
| 2748 | =head2 send_put_request | ||||||||||||||||||||||||||||||||||||||||||
| 2749 | |||||||||||||||||||||||||||||||||||||||||||
| 2750 | Internal method used to send PUT requests to the Spotify API. | ||||||||||||||||||||||||||||||||||||||||||
| 2751 | |||||||||||||||||||||||||||||||||||||||||||
| 2752 | =head2 check_users_saved_audiobooks | ||||||||||||||||||||||||||||||||||||||||||
| 2753 | |||||||||||||||||||||||||||||||||||||||||||
| 2754 | equivalent to GET /v1/me/audiobooks/contains | ||||||||||||||||||||||||||||||||||||||||||
| 2755 | |||||||||||||||||||||||||||||||||||||||||||
| 2756 | $spotify->check_users_saved_audiobooks(['18yVqkdbdRvS24c0Ilj2ci', '1HGw3J3NxZO1TP1BTtVhpZ']); | ||||||||||||||||||||||||||||||||||||||||||
| 2757 | |||||||||||||||||||||||||||||||||||||||||||
| 2758 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2759 | |||||||||||||||||||||||||||||||||||||||||||
| 2760 | $spotify->check_users_saved_audiobooks('18yVqkdbdRvS24c0Ilj2ci,1HGw3J3NxZO1TP1BTtVhpZ'); | ||||||||||||||||||||||||||||||||||||||||||
| 2761 | |||||||||||||||||||||||||||||||||||||||||||
| 2762 | =head2 get_users_saved_shows | ||||||||||||||||||||||||||||||||||||||||||
| 2763 | |||||||||||||||||||||||||||||||||||||||||||
| 2764 | equivalent to GET /v1/me/shows | ||||||||||||||||||||||||||||||||||||||||||
| 2765 | |||||||||||||||||||||||||||||||||||||||||||
| 2766 | $spotify->get_users_saved_shows(limit => 20, offset => 0); | ||||||||||||||||||||||||||||||||||||||||||
| 2767 | |||||||||||||||||||||||||||||||||||||||||||
| 2768 | This method retrieves a list of shows saved in the current Spotify user's library. Optional parameters can be used to limit the number of shows returned. | ||||||||||||||||||||||||||||||||||||||||||
| 2769 | |||||||||||||||||||||||||||||||||||||||||||
| 2770 | =head2 save_shows_for_current_user | ||||||||||||||||||||||||||||||||||||||||||
| 2771 | |||||||||||||||||||||||||||||||||||||||||||
| 2772 | equivalent to PUT /v1/me/shows | ||||||||||||||||||||||||||||||||||||||||||
| 2773 | |||||||||||||||||||||||||||||||||||||||||||
| 2774 | $spotify->save_shows_for_current_user(['5CfCWKI5pZ28U0uOzXkDHe', '5as3aKmN2k11yfDDDSrvaZ']); | ||||||||||||||||||||||||||||||||||||||||||
| 2775 | |||||||||||||||||||||||||||||||||||||||||||
| 2776 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2777 | |||||||||||||||||||||||||||||||||||||||||||
| 2778 | $spotify->save_shows_for_current_user('5CfCWKI5pZ28U0uOzXkDHe,5as3aKmN2k11yfDDDSrvaZ'); | ||||||||||||||||||||||||||||||||||||||||||
| 2779 | |||||||||||||||||||||||||||||||||||||||||||
| 2780 | This method saves one or more shows to the current user's library. | ||||||||||||||||||||||||||||||||||||||||||
| 2781 | |||||||||||||||||||||||||||||||||||||||||||
| 2782 | =head2 get_categories | ||||||||||||||||||||||||||||||||||||||||||
| 2783 | |||||||||||||||||||||||||||||||||||||||||||
| 2784 | equivalent to GET /v1/browse/categories | ||||||||||||||||||||||||||||||||||||||||||
| 2785 | |||||||||||||||||||||||||||||||||||||||||||
| 2786 | $spotify->get_categories( | ||||||||||||||||||||||||||||||||||||||||||
| 2787 | country => 'US', | ||||||||||||||||||||||||||||||||||||||||||
| 2788 | locale => 'en_US', | ||||||||||||||||||||||||||||||||||||||||||
| 2789 | limit => 20, | ||||||||||||||||||||||||||||||||||||||||||
| 2790 | offset => 0 | ||||||||||||||||||||||||||||||||||||||||||
| 2791 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2792 | |||||||||||||||||||||||||||||||||||||||||||
| 2793 | =head2 get_category | ||||||||||||||||||||||||||||||||||||||||||
| 2794 | |||||||||||||||||||||||||||||||||||||||||||
| 2795 | equivalent to GET /v1/browse/categories/{category_id} | ||||||||||||||||||||||||||||||||||||||||||
| 2796 | |||||||||||||||||||||||||||||||||||||||||||
| 2797 | $spotify->get_category('dinner', locale => 'en_US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2798 | |||||||||||||||||||||||||||||||||||||||||||
| 2799 | =head2 get_chapter | ||||||||||||||||||||||||||||||||||||||||||
| 2800 | |||||||||||||||||||||||||||||||||||||||||||
| 2801 | equivalent to GET /v1/chapters/{id} | ||||||||||||||||||||||||||||||||||||||||||
| 2802 | |||||||||||||||||||||||||||||||||||||||||||
| 2803 | $spotify->get_chapter('0D5wENdkdwbqlrHoaJ9g29', market => 'US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2804 | |||||||||||||||||||||||||||||||||||||||||||
| 2805 | =head2 get_several_chapters | ||||||||||||||||||||||||||||||||||||||||||
| 2806 | |||||||||||||||||||||||||||||||||||||||||||
| 2807 | equivalent to GET /v1/chapters | ||||||||||||||||||||||||||||||||||||||||||
| 2808 | |||||||||||||||||||||||||||||||||||||||||||
| 2809 | $spotify->get_several_chapters(['0IsXVP0JmcB2adSE338GkK', '3ZXb8FKZGU0EHALYX6uCzU', '0D5wENdkdwbqlrHoaJ9g29'], market => 'US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2810 | |||||||||||||||||||||||||||||||||||||||||||
| 2811 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2812 | |||||||||||||||||||||||||||||||||||||||||||
| 2813 | $spotify->get_several_chapters('0IsXVP0JmcB2adSE338GkK,3ZXb8FKZGU0EHALYX6uCzU,0D5wENdkdwbqlrHoaJ9g29', market => 'US'); | ||||||||||||||||||||||||||||||||||||||||||
| 2814 | |||||||||||||||||||||||||||||||||||||||||||
| 2815 | =head2 save_audiobooks_for_current_user | ||||||||||||||||||||||||||||||||||||||||||
| 2816 | |||||||||||||||||||||||||||||||||||||||||||
| 2817 | equivalent to PUT /v1/me/audiobooks | ||||||||||||||||||||||||||||||||||||||||||
| 2818 | |||||||||||||||||||||||||||||||||||||||||||
| 2819 | $spotify->save_audiobooks_for_current_user(['18yVqkdbdRvS24c0Ilj2ci', '1HGw3J3NxZO1TP1BTtVhpZ']); | ||||||||||||||||||||||||||||||||||||||||||
| 2820 | |||||||||||||||||||||||||||||||||||||||||||
| 2821 | or | ||||||||||||||||||||||||||||||||||||||||||
| 2822 | |||||||||||||||||||||||||||||||||||||||||||
| 2823 | $spotify->save_audiobooks_for_current_user('18yVqkdbdRvS24c0Ilj2ci,1HGw3J3NxZO1TP1BTtVhpZ'); | ||||||||||||||||||||||||||||||||||||||||||
| 2824 | |||||||||||||||||||||||||||||||||||||||||||
| 2825 | This method saves one or more audiobooks to the current user's library. | ||||||||||||||||||||||||||||||||||||||||||
| 2826 | |||||||||||||||||||||||||||||||||||||||||||
| 2827 | =head2 oauth_client_id | ||||||||||||||||||||||||||||||||||||||||||
| 2828 | |||||||||||||||||||||||||||||||||||||||||||
| 2829 | needed for requests that require OAuth, see Spotify API documentation for more information | ||||||||||||||||||||||||||||||||||||||||||
| 2830 | |||||||||||||||||||||||||||||||||||||||||||
| 2831 | $spotify->oauth_client_id('2xfjijkcjidjkfdi'); | ||||||||||||||||||||||||||||||||||||||||||
| 2832 | |||||||||||||||||||||||||||||||||||||||||||
| 2833 | Can also be set via environment variable, SPOTIFY_CLIENT_ID | ||||||||||||||||||||||||||||||||||||||||||
| 2834 | |||||||||||||||||||||||||||||||||||||||||||
| 2835 | =head2 oauth_client_secret | ||||||||||||||||||||||||||||||||||||||||||
| 2836 | |||||||||||||||||||||||||||||||||||||||||||
| 2837 | needed for requests that require OAuth, see Spotify API documentation for more information | ||||||||||||||||||||||||||||||||||||||||||
| 2838 | |||||||||||||||||||||||||||||||||||||||||||
| 2839 | $spotify->oauth_client_secret('2xfjijkcjidjkfdi'); | ||||||||||||||||||||||||||||||||||||||||||
| 2840 | |||||||||||||||||||||||||||||||||||||||||||
| 2841 | Can also be set via environment variable, SPOTIFY_CLIENT_SECRET | ||||||||||||||||||||||||||||||||||||||||||
| 2842 | |||||||||||||||||||||||||||||||||||||||||||
| 2843 | =head2 authorize_url | ||||||||||||||||||||||||||||||||||||||||||
| 2844 | |||||||||||||||||||||||||||||||||||||||||||
| 2845 | builds the URL to send a user to for the OAuth authorization-code flow. | ||||||||||||||||||||||||||||||||||||||||||
| 2846 | Uses C<oauth_client_id> and C<oauth_redirect_uri>; C<scope> and C<state> | ||||||||||||||||||||||||||||||||||||||||||
| 2847 | are optional | ||||||||||||||||||||||||||||||||||||||||||
| 2848 | |||||||||||||||||||||||||||||||||||||||||||
| 2849 | my $url = $spotify->authorize_url({ | ||||||||||||||||||||||||||||||||||||||||||
| 2850 | scope => 'user-read-private playlist-modify-private', | ||||||||||||||||||||||||||||||||||||||||||
| 2851 | state => $random_string, | ||||||||||||||||||||||||||||||||||||||||||
| 2852 | }); | ||||||||||||||||||||||||||||||||||||||||||
| 2853 | |||||||||||||||||||||||||||||||||||||||||||
| 2854 | Open the URL in a browser; after login Spotify redirects to | ||||||||||||||||||||||||||||||||||||||||||
| 2855 | C<oauth_redirect_uri> with a C<code> query parameter. | ||||||||||||||||||||||||||||||||||||||||||
| 2856 | |||||||||||||||||||||||||||||||||||||||||||
| 2857 | =head2 get_access_token | ||||||||||||||||||||||||||||||||||||||||||
| 2858 | |||||||||||||||||||||||||||||||||||||||||||
| 2859 | exchanges an authorization code (from the C<authorize_url> redirect) for | ||||||||||||||||||||||||||||||||||||||||||
| 2860 | a user access token. On success stores C<current_access_token>, | ||||||||||||||||||||||||||||||||||||||||||
| 2861 | C<refresh_token>, and C<token_expires_at>, and returns true | ||||||||||||||||||||||||||||||||||||||||||
| 2862 | |||||||||||||||||||||||||||||||||||||||||||
| 2863 | $spotify->get_access_token($code); | ||||||||||||||||||||||||||||||||||||||||||
| 2864 | |||||||||||||||||||||||||||||||||||||||||||
| 2865 | =head2 refresh_access_token | ||||||||||||||||||||||||||||||||||||||||||
| 2866 | |||||||||||||||||||||||||||||||||||||||||||
| 2867 | fetches a new access token using the stored C<refresh_token> (set by | ||||||||||||||||||||||||||||||||||||||||||
| 2868 | C<get_access_token>). Dies if no refresh token is stored; returns true | ||||||||||||||||||||||||||||||||||||||||||
| 2869 | on success | ||||||||||||||||||||||||||||||||||||||||||
| 2870 | |||||||||||||||||||||||||||||||||||||||||||
| 2871 | $spotify->refresh_access_token(); | ||||||||||||||||||||||||||||||||||||||||||
| 2872 | |||||||||||||||||||||||||||||||||||||||||||
| 2873 | =head2 refresh_token | ||||||||||||||||||||||||||||||||||||||||||
| 2874 | |||||||||||||||||||||||||||||||||||||||||||
| 2875 | the OAuth refresh token, set automatically by C<get_access_token>. Can | ||||||||||||||||||||||||||||||||||||||||||
| 2876 | be set manually to restore a persisted session | ||||||||||||||||||||||||||||||||||||||||||
| 2877 | |||||||||||||||||||||||||||||||||||||||||||
| 2878 | $spotify->refresh_token($saved_refresh_token); | ||||||||||||||||||||||||||||||||||||||||||
| 2879 | |||||||||||||||||||||||||||||||||||||||||||
| 2880 | =head2 response_status | ||||||||||||||||||||||||||||||||||||||||||
| 2881 | |||||||||||||||||||||||||||||||||||||||||||
| 2882 | returns the response code for the last request made | ||||||||||||||||||||||||||||||||||||||||||
| 2883 | |||||||||||||||||||||||||||||||||||||||||||
| 2884 | my $status = $spotify->response_status(); | ||||||||||||||||||||||||||||||||||||||||||
| 2885 | |||||||||||||||||||||||||||||||||||||||||||
| 2886 | =head2 response_content_type | ||||||||||||||||||||||||||||||||||||||||||
| 2887 | |||||||||||||||||||||||||||||||||||||||||||
| 2888 | returns the response type for the last request made, helpful to verify JSON | ||||||||||||||||||||||||||||||||||||||||||
| 2889 | |||||||||||||||||||||||||||||||||||||||||||
| 2890 | my $content_type = $spotify->response_content_type(); | ||||||||||||||||||||||||||||||||||||||||||
| 2891 | |||||||||||||||||||||||||||||||||||||||||||
| 2892 | =head2 custom_request_handler | ||||||||||||||||||||||||||||||||||||||||||
| 2893 | |||||||||||||||||||||||||||||||||||||||||||
| 2894 | pass a callback subroutine to this method that will be run at the end of the | ||||||||||||||||||||||||||||||||||||||||||
| 2895 | request prior to die_on_response_error, if enabled | ||||||||||||||||||||||||||||||||||||||||||
| 2896 | |||||||||||||||||||||||||||||||||||||||||||
| 2897 | # $m is the WWW::Mechanize object | ||||||||||||||||||||||||||||||||||||||||||
| 2898 | $spotify->custom_request_handler( | ||||||||||||||||||||||||||||||||||||||||||
| 2899 | sub { my $m = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 2900 | if ($m->status() == 401) { | ||||||||||||||||||||||||||||||||||||||||||
| 2901 | return 1; | ||||||||||||||||||||||||||||||||||||||||||
| 2902 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2903 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2904 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 2905 | |||||||||||||||||||||||||||||||||||||||||||
| 2906 | =head2 custom_request_handler_result | ||||||||||||||||||||||||||||||||||||||||||
| 2907 | |||||||||||||||||||||||||||||||||||||||||||
| 2908 | returns the result of the most recent execution of the custom_request_handler callback | ||||||||||||||||||||||||||||||||||||||||||
| 2909 | this allows you to determine the success/failure criteria of your callback | ||||||||||||||||||||||||||||||||||||||||||
| 2910 | |||||||||||||||||||||||||||||||||||||||||||
| 2911 | my $callback_result = $spotify->custom_request_handler_result(); | ||||||||||||||||||||||||||||||||||||||||||
| 2912 | |||||||||||||||||||||||||||||||||||||||||||
| 2913 | =head2 die_on_response_error | ||||||||||||||||||||||||||||||||||||||||||
| 2914 | |||||||||||||||||||||||||||||||||||||||||||
| 2915 | Boolean - default 0 | ||||||||||||||||||||||||||||||||||||||||||
| 2916 | |||||||||||||||||||||||||||||||||||||||||||
| 2917 | added to provide minimal automated checking of responses | ||||||||||||||||||||||||||||||||||||||||||
| 2918 | |||||||||||||||||||||||||||||||||||||||||||
| 2919 | $spotify->die_on_response_error(1); | ||||||||||||||||||||||||||||||||||||||||||
| 2920 | |||||||||||||||||||||||||||||||||||||||||||
| 2921 | eval { | ||||||||||||||||||||||||||||||||||||||||||
| 2922 | # run assuming you do NOT have proper authentication setup | ||||||||||||||||||||||||||||||||||||||||||
| 2923 | $result = $spotify->album('0sNOF9WDwhWunNAHPD3Baj'); | ||||||||||||||||||||||||||||||||||||||||||
| 2924 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 2925 | |||||||||||||||||||||||||||||||||||||||||||
| 2926 | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||
| 2927 | warn $spotify->last_error(); | ||||||||||||||||||||||||||||||||||||||||||
| 2928 | } | ||||||||||||||||||||||||||||||||||||||||||
| 2929 | |||||||||||||||||||||||||||||||||||||||||||
| 2930 | =head2 last_error | ||||||||||||||||||||||||||||||||||||||||||
| 2931 | |||||||||||||||||||||||||||||||||||||||||||
| 2932 | returns last_error (if applicable) from the most recent request. | ||||||||||||||||||||||||||||||||||||||||||
| 2933 | reset to empty string on each request | ||||||||||||||||||||||||||||||||||||||||||
| 2934 | |||||||||||||||||||||||||||||||||||||||||||
| 2935 | print $spotify->last_error() , "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 2936 | |||||||||||||||||||||||||||||||||||||||||||
| 2937 | =head1 THANKS | ||||||||||||||||||||||||||||||||||||||||||
| 2938 | |||||||||||||||||||||||||||||||||||||||||||
| 2939 | Paul Lamere at The Echo Nest / Spotify | ||||||||||||||||||||||||||||||||||||||||||
| 2940 | |||||||||||||||||||||||||||||||||||||||||||
| 2941 | All the great Perl community members that keep Perl fun | ||||||||||||||||||||||||||||||||||||||||||
| 2942 | |||||||||||||||||||||||||||||||||||||||||||
| 2943 | Olaf Alders for all his help and support in maintaining this module | ||||||||||||||||||||||||||||||||||||||||||
| 2944 | |||||||||||||||||||||||||||||||||||||||||||
| 2945 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 2946 | |||||||||||||||||||||||||||||||||||||||||||
| 2947 | Aaron Johnson <aaronjjohnson@gmail.com> | ||||||||||||||||||||||||||||||||||||||||||
| 2948 | |||||||||||||||||||||||||||||||||||||||||||
| 2949 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 2950 | |||||||||||||||||||||||||||||||||||||||||||
| 2951 | This software is copyright (c) 2024 by Aaron Johnson. | ||||||||||||||||||||||||||||||||||||||||||
| 2952 | |||||||||||||||||||||||||||||||||||||||||||
| 2953 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 2954 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 2955 | |||||||||||||||||||||||||||||||||||||||||||
| 2956 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 2957 | |||||||||||||||||||||||||||||||||||||||||||
| 2958 | __END__ | ||||||||||||||||||||||||||||||||||||||||||