Skip to content

Commit

Permalink
symlink/savefile
Browse files Browse the repository at this point in the history
  • Loading branch information
st3vil committed Feb 7, 2012
1 parent 00baba2 commit 878bc89
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/Net/LastFMAPI.pm
Expand Up @@ -24,22 +24,22 @@ our $username; # not important
our $xml = 0; our $xml = 0;
our $cache = 0; our $cache = 0;
our $cache_dir = my_home()."/.net-lastfmapi-cache/"; our $cache_dir = my_home()."/.net-lastfmapi-cache/";
our $sk_symlink = my_home()."/.net-lastfmapi-sessionkey"; our $sk_savefile = my_home()."/.net-lastfmapi-sessionkey";


sub load_save_sessionkey { # see get_session_key() sub load_save_sessionkey { # see get_session_key()
my $key = shift; my $key = shift;
if ($key) { if ($key) {
write_file($sk_symlink, $key); write_file($sk_savefile, $key);
} }
else { else {
$key = eval{ read_file($sk_symlink) }; $key = eval{ read_file($sk_savefile) };
} }
$session_key = $key; $session_key = $key;
} }


sub lastfm_config { sub lastfm_config {
my %configs = @_; my %configs = @_;
for my $k (qw{api_key secret session_key ua xml cache cache_dir sk_symlink}) { for my $k (qw{api_key secret session_key ua xml cache cache_dir sk_savefile}) {
my $v = delete $configs{$k}; my $v = delete $configs{$k};
if (defined $v) { if (defined $v) {
no strict 'refs'; no strict 'refs';
Expand Down Expand Up @@ -432,8 +432,8 @@ sub sign {


if ($ENV{NET_LASTFMAPI_REAUTH}) { if ($ENV{NET_LASTFMAPI_REAUTH}) {
say "Re-authenticatinging..."; say "Re-authenticatinging...";
if (readlink($sk_symlink)) { if (-e $sk_savefile) {
unlink($sk_symlink); unlink($sk_savefile);
} }
undef $session_key; undef $session_key;
get_session_key(); get_session_key();
Expand Down Expand Up @@ -505,11 +505,11 @@ empty arrays, single elements turned into a hash instead of an array of one hash
The session key will be sought when an authorised request is needed. See L<CONFIG>. The session key will be sought when an authorised request is needed. See L<CONFIG>.
If it is not configured or saves in a symlink then on-screen instructions should If it is not configured or saved then on-screen instructions should be followed to
be followed to authorise in a web browser with whoever is logged in to L<last.fm>. authorise in a web browser with whoever is logged in to L<last.fm>.
See L<http://www.last.fm/api/desktopauth>. See L<http://www.last.fm/api/desktopauth>.
It is saved in the symlink B<File::HomeDir::my_home()/.net-lastfmapi-sessionkey> It is saved in the file B<File::HomeDir::my_home()/.net-lastfmapi-sessionkey>
by default. This is probably fine. by default. This is probably fine.
Consider altering the subroutines B<talk_authentication>, B<load_save_sessionkey>, Consider altering the subroutines B<talk_authentication>, B<load_save_sessionkey>,
Expand Down Expand Up @@ -576,7 +576,7 @@ keeping going into the next page, and the next...
ua => $ua, ua => $ua,
# default File::HomeDir::my_home()/.net-lastfmapi-sessionkey # default File::HomeDir::my_home()/.net-lastfmapi-sessionkey
sk_symlink => $path, sk_savefile => $path,
); );
B<cache> and B<cache_dir> are likely most popular, see L<CACHING>. B<cache> and B<cache_dir> are likely most popular, see L<CACHING>.
Expand Down

0 comments on commit 878bc89

Please sign in to comment.