34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/songbirdsh/scrobbler.rb', line 34
def setup
puts " Because of the way lastfm authentication works, setting up lastfm involves two steps:\n Firstly, you need to register that you are developing an application. This will give you an api key and an associated 'secret'\n Secondly, you need to gives your application access your lastfm account. This will give a authenticated session.\n\n Step 1. Logging in to your lastfm account and register an application\n This will launch a browser. You need to log in and fill out the API registration form\n EOF\n answer = ask 'Are you ready ? '\n return unless answer.downcase.start_with? 'y'\n \"http://www.last.fm/api/account\".to_launcher\n preferences = {}\n preferences['api_key'] = ask 'What is your API key ? '\n preferences['secret'] = ask 'What is your secret ? '\n puts <<-EOF\n Now you've got you application details, you need to create an authentication session between your application and your lastfm account\n Step 2. Authorising your application to access your lastfm account\n This will launch another browser. You just need to give your application permission to access your account\n EOF\n preferences['user'] = ask 'What is your lastfm user name ? '\n @scrobbler = SimpleScrobbler.new preferences['api_key'], preferences['secret'], preferences['user']\n preferences['session_key'] = @scrobbler.fetch_session_key do |url|\n url.to_launcher\n ask 'Hit enter when you\\'ve allowed your application access to your account'\n end\n @preferences['lastfm'] = preferences\nend\n"
|