Permalink
Browse files

add a link to the methods documentation in the error

  • Loading branch information...
1 parent 59e6102 commit 2d29bd6a46e8c87abe4dae15058ef1311b63b1b2 @st3vil committed Nov 24, 2011
Showing with 143 additions and 137 deletions.
  1. +137 −134 lib/Net/LastFMAPI.pm
  2. +6 −3 sync-api-docs.pl
View
@@ -60,138 +60,138 @@ sub loadfile {
}
#{{{
our $methods = {
- 'album.addtags' => {auth => 1, post => 1, signed => 1},
- 'album.getbuylinks' => {},
- 'album.getinfo' => {},
- 'album.getshouts' => {page => 1},
- 'album.gettags' => {auth => 1, signed => 1},
- 'album.gettoptags' => {},
- 'album.removetag' => {auth => 1, post => 1, signed => 1},
- 'album.search' => {page => 1},
- 'album.share' => {auth => 1, post => 1, signed => 1},
- 'artist.addtags' => {auth => 1, post => 1, signed => 1},
- 'artist.getcorrection' => {},
- 'artist.getevents' => {page => 1},
- 'artist.getimages' => {page => 1},
- 'artist.getinfo' => {},
- 'artist.getpastevents' => {page => 1},
- 'artist.getpodcast' => {},
- 'artist.getshouts' => {page => 1},
- 'artist.getsimilar' => {},
- 'artist.gettags' => {auth => 1, signed => 1},
- 'artist.gettopalbums' => {page => 1},
- 'artist.gettopfans' => {},
- 'artist.gettoptags' => {},
- 'artist.gettoptracks' => {page => 1},
- 'artist.removetag' => {auth => 1, post => 1, signed => 1},
- 'artist.search' => {page => 1},
- 'artist.share' => {auth => 1, post => 1, signed => 1},
- 'artist.shout' => {auth => 1, post => 1, signed => 1},
- 'auth.getmobilesession' => {signed => 1},
- 'auth.getsession' => {signed => 1},
- 'auth.gettoken' => {signed => 1},
- 'chart.gethypedartists' => {page => 1},
- 'chart.gethypedtracks' => {page => 1},
- 'chart.getlovedtracks' => {page => 1},
- 'chart.gettopartists' => {page => 1},
- 'chart.gettoptags' => {page => 1},
- 'chart.gettoptracks' => {page => 1},
- 'event.attend' => {auth => 1, post => 1, signed => 1},
- 'event.getattendees' => {page => 1},
- 'event.getinfo' => {},
- 'event.getshouts' => {page => 1},
- 'event.share' => {auth => 1, post => 1, signed => 1},
- 'event.shout' => {auth => 1, post => 1, signed => 1},
- 'geo.getevents' => {page => 1},
- 'geo.getmetroartistchart' => {},
- 'geo.getmetrohypeartistchart' => {},
- 'geo.getmetrohypetrackchart' => {},
- 'geo.getmetrotrackchart' => {},
- 'geo.getmetrouniqueartistchart' => {},
- 'geo.getmetrouniquetrackchart' => {},
- 'geo.getmetroweeklychartlist' => {},
- 'geo.getmetros' => {},
- 'geo.gettopartists' => {page => 1},
- 'geo.gettoptracks' => {page => 1},
- 'group.gethype' => {},
- 'group.getmembers' => {page => 1},
- 'group.getweeklyalbumchart' => {},
- 'group.getweeklyartistchart' => {},
- 'group.getweeklychartlist' => {},
- 'group.getweeklytrackchart' => {},
- 'library.addalbum' => {auth => 1, post => 1, signed => 1},
- 'library.addartist' => {auth => 1, post => 1, signed => 1},
- 'library.addtrack' => {auth => 1, post => 1, signed => 1},
- 'library.getalbums' => {page => 1},
- 'library.getartists' => {page => 1},
- 'library.gettracks' => {page => 1},
- 'library.removealbum' => {auth => 1, post => 1, signed => 1},
- 'library.removeartist' => {auth => 1, post => 1, signed => 1},
- 'library.removescrobble' => {auth => 1, post => 1, signed => 1},
- 'library.removetrack' => {auth => 1, post => 1, signed => 1},
- 'playlist.addtrack' => {auth => 1, post => 1, signed => 1},
- 'playlist.create' => {auth => 1, post => 1, signed => 1},
- 'radio.getplaylist' => {auth => 1, signed => 1},
- 'radio.search' => {},
- 'radio.tune' => {auth => 1, post => 1, signed => 1},
- 'tag.getinfo' => {},
- 'tag.getsimilar' => {},
- 'tag.gettopalbums' => {page => 1},
- 'tag.gettopartists' => {page => 1},
- 'tag.gettoptags' => {},
- 'tag.gettoptracks' => {page => 1},
- 'tag.getweeklyartistchart' => {},
- 'tag.getweeklychartlist' => {},
- 'tag.search' => {page => 1},
- 'tasteometer.compare' => {},
- 'tasteometer.comparegroup' => {},
- 'track.addtags' => {auth => 1, post => 1, signed => 1},
- 'track.ban' => {auth => 1, post => 1, signed => 1},
- 'track.getbuylinks' => {},
- 'track.getcorrection' => {},
- 'track.getfingerprintmetadata' => {},
- 'track.getinfo' => {},
- 'track.getshouts' => {page => 1},
- 'track.getsimilar' => {},
- 'track.gettags' => {auth => 1, signed => 1},
- 'track.gettopfans' => {},
- 'track.gettoptags' => {},
- 'track.love' => {auth => 1, post => 1, signed => 1},
- 'track.removetag' => {auth => 1, post => 1, signed => 1},
- 'track.scrobble' => {auth => 1, post => 1, signed => 1},
- 'track.search' => {page => 1},
- 'track.share' => {auth => 1, post => 1, signed => 1},
- 'track.unban' => {auth => 1, post => 1, signed => 1},
- 'track.unlove' => {auth => 1, post => 1, signed => 1},
- 'track.updatenowplaying' => {auth => 1, post => 1, signed => 1},
- 'user.getartisttracks' => {page => 1},
- 'user.getbannedtracks' => {page => 1},
- 'user.getevents' => {page => 1},
- 'user.getfriends' => {page => 1},
- 'user.getinfo' => {auth => 1},
- 'user.getlovedtracks' => {page => 1},
- 'user.getneighbours' => {},
- 'user.getnewreleases' => {},
- 'user.getpastevents' => {page => 1},
- 'user.getpersonaltags' => {page => 1},
- 'user.getplaylists' => {},
- 'user.getrecentstations' => {auth => 1, signed => 1, page => 1},
- 'user.getrecenttracks' => {page => 1},
- 'user.getrecommendedartists' => {auth => 1, signed => 1, page => 1},
- 'user.getrecommendedevents' => {auth => 1, signed => 1, page => 1},
- 'user.getshouts' => {page => 1},
- 'user.gettopalbums' => {page => 1},
- 'user.gettopartists' => {page => 1},
- 'user.gettoptags' => {},
- 'user.gettoptracks' => {page => 1},
- 'user.getweeklyalbumchart' => {},
- 'user.getweeklyartistchart' => {},
- 'user.getweeklychartlist' => {},
- 'user.getweeklytrackchart' => {},
- 'user.shout' => {auth => 1, post => 1, signed => 1},
- 'venue.getevents' => {},
- 'venue.getpastevents' => {page => 1},
- 'venue.search' => {page => 1},
+ 'album.addtags' => {auth => 1, post => 1, signed => 1, id => 302},
+ 'album.getbuylinks' => {id => 429},
+ 'album.getinfo' => {id => 290},
+ 'album.getshouts' => {page => 1, id => 450},
+ 'album.gettags' => {auth => 1, signed => 1, id => 317},
+ 'album.gettoptags' => {id => 438},
+ 'album.removetag' => {auth => 1, post => 1, signed => 1, id => 314},
+ 'album.search' => {page => 1, id => 357},
+ 'album.share' => {auth => 1, post => 1, signed => 1, id => 436},
+ 'artist.addtags' => {auth => 1, post => 1, signed => 1, id => 303},
+ 'artist.getcorrection' => {id => 446},
+ 'artist.getevents' => {page => 1, id => 117},
+ 'artist.getimages' => {page => 1, id => 407},
+ 'artist.getinfo' => {id => 267},
+ 'artist.getpastevents' => {page => 1, id => 428},
+ 'artist.getpodcast' => {id => 118},
+ 'artist.getshouts' => {page => 1, id => 397},
+ 'artist.getsimilar' => {id => 119},
+ 'artist.gettags' => {auth => 1, signed => 1, id => 318},
+ 'artist.gettopalbums' => {page => 1, id => 287},
+ 'artist.gettopfans' => {id => 310},
+ 'artist.gettoptags' => {id => 288},
+ 'artist.gettoptracks' => {page => 1, id => 277},
+ 'artist.removetag' => {auth => 1, post => 1, signed => 1, id => 315},
+ 'artist.search' => {page => 1, id => 272},
+ 'artist.share' => {auth => 1, post => 1, signed => 1, id => 306},
+ 'artist.shout' => {auth => 1, post => 1, signed => 1, id => 408},
+ 'auth.getmobilesession' => {signed => 1, id => 266},
+ 'auth.getsession' => {signed => 1, id => 125},
+ 'auth.gettoken' => {signed => 1, id => 265},
+ 'chart.gethypedartists' => {page => 1, id => 493},
+ 'chart.gethypedtracks' => {page => 1, id => 494},
+ 'chart.getlovedtracks' => {page => 1, id => 495},
+ 'chart.gettopartists' => {page => 1, id => 496},
+ 'chart.gettoptags' => {page => 1, id => 497},
+ 'chart.gettoptracks' => {page => 1, id => 498},
+ 'event.attend' => {auth => 1, post => 1, signed => 1, id => 307},
+ 'event.getattendees' => {page => 1, id => 391},
+ 'event.getinfo' => {id => 292},
+ 'event.getshouts' => {page => 1, id => 399},
+ 'event.share' => {auth => 1, post => 1, signed => 1, id => 350},
+ 'event.shout' => {auth => 1, post => 1, signed => 1, id => 409},
+ 'geo.getevents' => {page => 1, id => 270},
+ 'geo.getmetroartistchart' => {id => 421},
+ 'geo.getmetrohypeartistchart' => {id => 420},
+ 'geo.getmetrohypetrackchart' => {id => 422},
+ 'geo.getmetrotrackchart' => {id => 423},
+ 'geo.getmetrouniqueartistchart' => {id => 424},
+ 'geo.getmetrouniquetrackchart' => {id => 425},
+ 'geo.getmetroweeklychartlist' => {id => 426},
+ 'geo.getmetros' => {id => 435},
+ 'geo.gettopartists' => {page => 1, id => 297},
+ 'geo.gettoptracks' => {page => 1, id => 298},
+ 'group.gethype' => {id => 259},
+ 'group.getmembers' => {page => 1, id => 379},
+ 'group.getweeklyalbumchart' => {id => 293},
+ 'group.getweeklyartistchart' => {id => 294},
+ 'group.getweeklychartlist' => {id => 295},
+ 'group.getweeklytrackchart' => {id => 296},
+ 'library.addalbum' => {auth => 1, post => 1, signed => 1, id => 370},
+ 'library.addartist' => {auth => 1, post => 1, signed => 1, id => 371},
+ 'library.addtrack' => {auth => 1, post => 1, signed => 1, id => 372},
+ 'library.getalbums' => {page => 1, id => 321},
+ 'library.getartists' => {page => 1, id => 322},
+ 'library.gettracks' => {page => 1, id => 323},
+ 'library.removealbum' => {auth => 1, post => 1, signed => 1, id => 523},
+ 'library.removeartist' => {auth => 1, post => 1, signed => 1, id => 524},
+ 'library.removescrobble' => {auth => 1, post => 1, signed => 1, id => 525},
+ 'library.removetrack' => {auth => 1, post => 1, signed => 1, id => 526},
+ 'playlist.addtrack' => {auth => 1, post => 1, signed => 1, id => 337},
+ 'playlist.create' => {auth => 1, post => 1, signed => 1, id => 365},
+ 'radio.getplaylist' => {auth => 1, signed => 1, id => 256},
+ 'radio.search' => {id => 418},
+ 'radio.tune' => {auth => 1, post => 1, signed => 1, id => 160},
+ 'tag.getinfo' => {id => 452},
+ 'tag.getsimilar' => {id => 311},
+ 'tag.gettopalbums' => {page => 1, id => 283},
+ 'tag.gettopartists' => {page => 1, id => 284},
+ 'tag.gettoptags' => {id => 276},
+ 'tag.gettoptracks' => {page => 1, id => 285},
+ 'tag.getweeklyartistchart' => {id => 358},
+ 'tag.getweeklychartlist' => {id => 359},
+ 'tag.search' => {page => 1, id => 273},
+ 'tasteometer.compare' => {id => 258},
+ 'tasteometer.comparegroup' => {id => 500},
+ 'track.addtags' => {auth => 1, post => 1, signed => 1, id => 304},
+ 'track.ban' => {auth => 1, post => 1, signed => 1, id => 261},
+ 'track.getbuylinks' => {id => 431},
+ 'track.getcorrection' => {id => 447},
+ 'track.getfingerprintmetadata' => {id => 441},
+ 'track.getinfo' => {id => 356},
+ 'track.getshouts' => {page => 1, id => 453},
+ 'track.getsimilar' => {id => 319},
+ 'track.gettags' => {auth => 1, signed => 1, id => 320},
+ 'track.gettopfans' => {id => 312},
+ 'track.gettoptags' => {id => 289},
+ 'track.love' => {auth => 1, post => 1, signed => 1, id => 260},
+ 'track.removetag' => {auth => 1, post => 1, signed => 1, id => 316},
+ 'track.scrobble' => {auth => 1, post => 1, signed => 1, id => 443},
+ 'track.search' => {page => 1, id => 286},
+ 'track.share' => {auth => 1, post => 1, signed => 1, id => 305},
+ 'track.unban' => {auth => 1, post => 1, signed => 1, id => 449},
+ 'track.unlove' => {auth => 1, post => 1, signed => 1, id => 440},
+ 'track.updatenowplaying' => {auth => 1, post => 1, signed => 1, id => 454},
+ 'user.getartisttracks' => {page => 1, id => 432},
+ 'user.getbannedtracks' => {page => 1, id => 448},
+ 'user.getevents' => {page => 1, id => 291},
+ 'user.getfriends' => {page => 1, id => 263},
+ 'user.getinfo' => {auth => 1, id => 344},
+ 'user.getlovedtracks' => {page => 1, id => 329},
+ 'user.getneighbours' => {id => 264},
+ 'user.getnewreleases' => {id => 444},
+ 'user.getpastevents' => {page => 1, id => 343},
+ 'user.getpersonaltags' => {page => 1, id => 455},
+ 'user.getplaylists' => {id => 313},
+ 'user.getrecentstations' => {auth => 1, signed => 1, page => 1, id => 414},
+ 'user.getrecenttracks' => {page => 1, id => 278},
+ 'user.getrecommendedartists' => {auth => 1, signed => 1, page => 1, id => 388},
+ 'user.getrecommendedevents' => {auth => 1, signed => 1, page => 1, id => 375},
+ 'user.getshouts' => {page => 1, id => 401},
+ 'user.gettopalbums' => {page => 1, id => 299},
+ 'user.gettopartists' => {page => 1, id => 300},
+ 'user.gettoptags' => {id => 123},
+ 'user.gettoptracks' => {page => 1, id => 301},
+ 'user.getweeklyalbumchart' => {id => 279},
+ 'user.getweeklyartistchart' => {id => 281},
+ 'user.getweeklychartlist' => {id => 280},
+ 'user.getweeklytrackchart' => {id => 282},
+ 'user.shout' => {auth => 1, post => 1, signed => 1, id => 411},
+ 'venue.getevents' => {id => 394},
+ 'venue.getpastevents' => {page => 1, id => 395},
+ 'venue.search' => {page => 1, id => 396},
};
#}}}
our %last_params;
@@ -265,13 +265,16 @@ sub lastfm {
EARORR:
$DB::single = 0;
$DB::single = 1;
- my $consider;
+ my $consider = "";
if ($content =~ /Invalid session key - Please re-authenticate/) {
$consider = "setting NET_LASTFMAPI_REAUTH=1 to re-authenticate";
}
+ $consider .= ($consider ? "\n or " : "")."reading the docs: "
+ ."http://www.last.fm/api/show/?service=$methods->{$method}->{id}"
+ if $methods->{$method};
croak "Something went wrong:\n$content\n".
($consider?"\nConsider $consider":"");
- }
+ }
if ($params{format} eq "json") {
$content = decode_json($content);
View
@@ -16,9 +16,11 @@
->each(sub{
$_ = pQuery($_)->html;
say "studying: $_";
- m{<a href="(/api/show/\?service=\d+)">(.+)</a>} || die "not <a>: $_";
+ m{<a href="/api/show/\?service=(\d+)">(.+)</a>} || die "not <a>: $_";
+ my $id = $1;
my $method = $2;
- $_ = pQuery("http://www.last.fm$1")->find("div#wsdescriptor")->html;
+ $_ = pQuery("http://www.last.fm/api/show/?service=$1")
+ ->find("div#wsdescriptor")->html;
my $auth = m{This service requires authentication};
my $sig = m{<span class="param">api_sig</span>};
my $post = m{must be accessed with an HTTP POST request};
@@ -29,6 +31,7 @@
signed => $sig,
auth => $auth,
page => $page,
+ id => $id,
};
usleep 10000;
});
@@ -47,7 +50,7 @@
push @new, sprintf(" '%s' => {%s},\n",
$method,
join (", ", map { "$_ => $m->{$_}" }
- grep { $m->{$_} } qw{auth post signed page}
+ grep { $m->{$_} } qw{auth post signed page id}
),
);
}

0 comments on commit 2d29bd6

Please sign in to comment.