diff --git a/lib/Net/LastFMAPI.pm b/lib/Net/LastFMAPI.pm index 25dc5f4..e1347f8 100644 --- a/lib/Net/LastFMAPI.pm +++ b/lib/Net/LastFMAPI.pm @@ -47,138 +47,138 @@ sub loadfile { } #{{{ our $methods = { - 'album.addTags' => { auth => 1, post => 1, signed => 1 }, - 'album.getBuylinks' => { }, - 'album.getInfo' => { }, - 'album.getShouts' => { }, - 'album.getTags' => { auth => 1, signed => 1 }, - 'album.getTopTags' => { }, - 'album.removeTag' => { auth => 1, post => 1, signed => 1 }, - 'album.search' => { }, - 'album.share' => { auth => 1, post => 1, signed => 1 }, - 'artist.addTags' => { auth => 1, post => 1, signed => 1 }, - 'artist.getCorrection' => { }, - 'artist.getEvents' => { }, - 'artist.getImages' => { }, - 'artist.getInfo' => { }, - 'artist.getPastEvents' => { }, - 'artist.getPodcast' => { }, - 'artist.getShouts' => { }, - 'artist.getSimilar' => { }, - 'artist.getTags' => { auth => 1, signed => 1 }, - 'artist.getTopAlbums' => { }, - 'artist.getTopFans' => { }, - 'artist.getTopTags' => { }, - 'artist.getTopTracks' => { }, - 'artist.removeTag' => { auth => 1, post => 1, signed => 1 }, - 'artist.search' => { }, - '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' => { }, - 'chart.getHypedTracks' => { }, - 'chart.getLovedTracks' => { }, - 'chart.getTopArtists' => { }, - 'chart.getTopTags' => { }, - 'chart.getTopTracks' => { }, - 'event.attend' => { auth => 1, post => 1, signed => 1 }, - 'event.getAttendees' => { }, - 'event.getInfo' => { }, - 'event.getShouts' => { }, - 'event.share' => { auth => 1, post => 1, signed => 1 }, - 'event.shout' => { auth => 1, post => 1, signed => 1 }, - 'geo.getEvents' => { }, - 'geo.getMetroArtistChart' => { }, - 'geo.getMetroHypeArtistChart' => { }, - 'geo.getMetroHypeTrackChart' => { }, - 'geo.getMetroTrackChart' => { }, - 'geo.getMetroUniqueArtistChart' => { }, - 'geo.getMetroUniqueTrackChart' => { }, - 'geo.getMetroWeeklyChartlist' => { }, - 'geo.getMetros' => { }, - 'geo.getTopArtists' => { }, - 'geo.getTopTracks' => { }, - 'group.getHype' => { }, - 'group.getMembers' => { }, - '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' => { }, - 'library.getArtists' => { }, - 'library.getTracks' => { }, - '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' => { }, - 'tag.getTopArtists' => { }, - 'tag.getTopTags' => { }, - 'tag.getTopTracks' => { }, - 'tag.getWeeklyArtistChart' => { }, - 'tag.getWeeklyChartList' => { }, - 'tag.search' => { }, - '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' => { }, - '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' => { }, - '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' => { }, - 'user.getBannedTracks' => { }, - 'user.getEvents' => { }, - 'user.getFriends' => { }, - 'user.getInfo' => { auth => 1 }, - 'user.getLovedTracks' => { }, - 'user.getNeighbours' => { }, - 'user.getNewReleases' => { }, - 'user.getPastEvents' => { }, - 'user.getPersonalTags' => { }, - 'user.getPlaylists' => { }, - 'user.getRecentStations' => { auth => 1, signed => 1 }, - 'user.getRecentTracks' => { }, - 'user.getRecommendedArtists' => { auth => 1, signed => 1 }, - 'user.getRecommendedEvents' => { auth => 1, signed => 1 }, - 'user.getShouts' => { }, - 'user.getTopAlbums' => { }, - 'user.getTopArtists' => { }, - 'user.getTopTags' => { }, - 'user.getTopTracks' => { }, - 'user.getWeeklyAlbumChart' => { }, - 'user.getWeeklyArtistChart' => { }, - 'user.getWeeklyChartList' => { }, - 'user.getWeeklyTrackChart' => { }, - 'user.shout' => { auth => 1, post => 1, signed => 1 }, - 'venue.getEvents' => { }, - 'venue.getPastEvents' => { }, - 'venue.search' => { }, + 'album.addtags' => {auth => 1, post => 1, signed => 1}, + 'album.getbuylinks' => {}, + 'album.getinfo' => {}, + 'album.getshouts' => {}, + 'album.gettags' => {auth => 1, signed => 1}, + 'album.gettoptags' => {}, + 'album.removetag' => {auth => 1, post => 1, signed => 1}, + 'album.search' => {}, + 'album.share' => {auth => 1, post => 1, signed => 1}, + 'artist.addtags' => {auth => 1, post => 1, signed => 1}, + 'artist.getcorrection' => {}, + 'artist.getevents' => {}, + 'artist.getimages' => {}, + 'artist.getinfo' => {}, + 'artist.getpastevents' => {}, + 'artist.getpodcast' => {}, + 'artist.getshouts' => {}, + 'artist.getsimilar' => {}, + 'artist.gettags' => {auth => 1, signed => 1}, + 'artist.gettopalbums' => {}, + 'artist.gettopfans' => {}, + 'artist.gettoptags' => {}, + 'artist.gettoptracks' => {}, + 'artist.removetag' => {auth => 1, post => 1, signed => 1}, + 'artist.search' => {}, + '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' => {}, + 'chart.gethypedtracks' => {}, + 'chart.getlovedtracks' => {}, + 'chart.gettopartists' => {}, + 'chart.gettoptags' => {}, + 'chart.gettoptracks' => {}, + 'event.attend' => {auth => 1, post => 1, signed => 1}, + 'event.getattendees' => {}, + 'event.getinfo' => {}, + 'event.getshouts' => {}, + 'event.share' => {auth => 1, post => 1, signed => 1}, + 'event.shout' => {auth => 1, post => 1, signed => 1}, + 'geo.getevents' => {}, + 'geo.getmetroartistchart' => {}, + 'geo.getmetrohypeartistchart' => {}, + 'geo.getmetrohypetrackchart' => {}, + 'geo.getmetrotrackchart' => {}, + 'geo.getmetrouniqueartistchart' => {}, + 'geo.getmetrouniquetrackchart' => {}, + 'geo.getmetroweeklychartlist' => {}, + 'geo.getmetros' => {}, + 'geo.gettopartists' => {}, + 'geo.gettoptracks' => {}, + 'group.gethype' => {}, + 'group.getmembers' => {}, + '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' => {}, + 'library.getartists' => {}, + 'library.gettracks' => {}, + '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' => {}, + 'tag.gettopartists' => {}, + 'tag.gettoptags' => {}, + 'tag.gettoptracks' => {}, + 'tag.getweeklyartistchart' => {}, + 'tag.getweeklychartlist' => {}, + 'tag.search' => {}, + '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' => {}, + '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' => {}, + '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' => {}, + 'user.getbannedtracks' => {}, + 'user.getevents' => {}, + 'user.getfriends' => {}, + 'user.getinfo' => {auth => 1}, + 'user.getlovedtracks' => {}, + 'user.getneighbours' => {}, + 'user.getnewreleases' => {}, + 'user.getpastevents' => {}, + 'user.getpersonaltags' => {}, + 'user.getplaylists' => {}, + 'user.getrecentstations' => {auth => 1, signed => 1}, + 'user.getrecenttracks' => {}, + 'user.getrecommendedartists' => {auth => 1, signed => 1}, + 'user.getrecommendedevents' => {auth => 1, signed => 1}, + 'user.getshouts' => {}, + 'user.gettopalbums' => {}, + 'user.gettopartists' => {}, + 'user.gettoptags' => {}, + 'user.gettoptracks' => {}, + 'user.getweeklyalbumchart' => {}, + 'user.getweeklyartistchart' => {}, + 'user.getweeklychartlist' => {}, + 'user.getweeklytrackchart' => {}, + 'user.shout' => {auth => 1, post => 1, signed => 1}, + 'venue.getevents' => {}, + 'venue.getpastevents' => {}, + 'venue.search' => {}, }; #}}} sub lastfm { @@ -219,7 +219,7 @@ sub lastfm { $params{format} ||= "json" if $json; delete $params{format} if $params{format} && $params{format} eq "xml"; - unless (exists $methods->{$method}) { + unless (exists $methods->{lc $method}) { carp "method $method is not known to Net::LastFMAPI" } @@ -228,7 +228,7 @@ sub lastfm { sign(\%params); my $res; - if ($methods->{$method}->{post}) { + if ($methods->{lc $method}->{post}) { $res = $ua->post($url, Content => \%params); } else { @@ -257,7 +257,7 @@ sub lastfm { sub sessionise { my $params = shift; - my $m = $methods->{$params->{method}}; + my $m = $methods->{lc $params->{method}}; unless (delete $params->{auth} || $m && $m->{auth}) { return } @@ -308,7 +308,7 @@ sub talk_authorisation { sub sign { my $params = shift; - return unless $methods->{$params->{method}}->{signed}; + return unless $methods->{lc $params->{method}}->{signed}; my $jumble = join "", map { $_ => $params->{$_} } sort keys %$params; my $hash = md5_hex($jumble.$secret); $params->{api_sig} = $hash; diff --git a/sync-api-docs.pl b/sync-api-docs.pl index 0574661..4a4bdee 100644 --- a/sync-api-docs.pl +++ b/sync-api-docs.pl @@ -5,6 +5,7 @@ use File::Slurp; use lib "$ENV{HOME}/pquery-pm/lib"; use pQuery; +use Time::HiRes "usleep"; my $file = "lib/Net/LastFMAPI.pm"; -f $file or die "where's the $file at?"; @@ -27,7 +28,7 @@ signed => $sig, auth => $auth, }; - sleep 1; + usleep 10000; }); @@ -37,8 +38,8 @@ say shift @old until $old[0] =~ /^};/; for my $m (@methods) { - my $method = delete $m->{method}; - if ($method eq "user.getInfo") { + my $method = lc delete $m->{method}; + if ($method eq "user.getinfo") { $m->{auth} = 1; } push @new, sprintf(" '%s' => {%s},\n",