rockstar-custom 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.travis.yml +6 -0
  2. data/Gemfile +11 -0
  3. data/Gemfile.lock +22 -0
  4. data/History.txt +6 -0
  5. data/MIT-LICENSE +19 -0
  6. data/Manifest +72 -0
  7. data/README.md +135 -0
  8. data/Rakefile +34 -0
  9. data/VERSION +1 -0
  10. data/examples/.gitignore +1 -0
  11. data/examples/album.rb +16 -0
  12. data/examples/artist.rb +23 -0
  13. data/examples/geo.rb +9 -0
  14. data/examples/lastfm.yml_example +3 -0
  15. data/examples/scrobble.rb +45 -0
  16. data/examples/tag.rb +20 -0
  17. data/examples/track.rb +14 -0
  18. data/examples/user.rb +18 -0
  19. data/lib/rockstar.rb +50 -0
  20. data/lib/rockstar/album.rb +109 -0
  21. data/lib/rockstar/artist.rb +182 -0
  22. data/lib/rockstar/auth.rb +21 -0
  23. data/lib/rockstar/base.rb +48 -0
  24. data/lib/rockstar/chart.rb +31 -0
  25. data/lib/rockstar/event.rb +73 -0
  26. data/lib/rockstar/geo.rb +22 -0
  27. data/lib/rockstar/metro.rb +26 -0
  28. data/lib/rockstar/playing.rb +50 -0
  29. data/lib/rockstar/rest.rb +66 -0
  30. data/lib/rockstar/scrobble.rb +68 -0
  31. data/lib/rockstar/session.rb +19 -0
  32. data/lib/rockstar/simpleauth.rb +62 -0
  33. data/lib/rockstar/tag.rb +100 -0
  34. data/lib/rockstar/tokenauth.rb +84 -0
  35. data/lib/rockstar/track.rb +260 -0
  36. data/lib/rockstar/user.rb +200 -0
  37. data/lib/rockstar/venue.rb +59 -0
  38. data/lib/rockstar/version.rb +3 -0
  39. data/rockstar.gemspec +174 -0
  40. data/test/fixtures/xml/album/getinfo_album_Radio_Retalation_artist_Thievery_Corporation.xml +21 -0
  41. data/test/fixtures/xml/album/getinfo_album_Some_Hearts_artist_Carrie_Underwood.xml +63 -0
  42. data/test/fixtures/xml/artist/getevents_artist_Metallica.xml +1064 -0
  43. data/test/fixtures/xml/artist/getimages_artist_Metallica_page_2.xml +1074 -0
  44. data/test/fixtures/xml/artist/getinfo_artist_Metallica.xml +115 -0
  45. data/test/fixtures/xml/artist/getsimilar_artist_Metallica.xml +1203 -0
  46. data/test/fixtures/xml/artist/gettopalbums_artist_Metallica.xml +704 -0
  47. data/test/fixtures/xml/artist/gettopfans_artist_Metallica.xml +504 -0
  48. data/test/fixtures/xml/artist/gettoptags_artist_Metallica.xml +403 -0
  49. data/test/fixtures/xml/artist/gettoptracks_artist_Metallica.xml +800 -0
  50. data/test/fixtures/xml/geo/getevents_location_london.xml +531 -0
  51. data/test/fixtures/xml/geo/getmetros_country_germany.xml +44 -0
  52. data/test/fixtures/xml/tag/gettopalbums_tag_rock.xml +654 -0
  53. data/test/fixtures/xml/tag/gettopartists_tag_rock.xml +504 -0
  54. data/test/fixtures/xml/tag/gettoptags.xml +1253 -0
  55. data/test/fixtures/xml/tag/gettoptracks_tag_rock.xml +704 -0
  56. data/test/fixtures/xml/track/getinfo_artist_Carrie_Underwood_track_Before_He_Cheats.xml +55 -0
  57. data/test/fixtures/xml/track/gettopfans_artist_Carrie_Underwood_track_Before_He_Cheats.xml +504 -0
  58. data/test/fixtures/xml/track/gettoptags_artist_Carrie_Underwood_track_Before_He_Cheats.xml +403 -0
  59. data/test/fixtures/xml/track/love_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +2 -0
  60. data/test/fixtures/xml/track/updatenowplaying_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +10 -0
  61. data/test/fixtures/xml/user/getevents_sk_token_user_bodot.xml +513 -0
  62. data/test/fixtures/xml/user/getfriends_user_jnunemaker.xml +173 -0
  63. data/test/fixtures/xml/user/getinfo_user_jnunemaker.xml +22 -0
  64. data/test/fixtures/xml/user/getinfo_user_oaknd1.xml +22 -0
  65. data/test/fixtures/xml/user/getinfo_user_wharle.xml +22 -0
  66. data/test/fixtures/xml/user/getlovedtracks_user_jnunemaker.xml +775 -0
  67. data/test/fixtures/xml/user/getneighbours_user_jnunemaker.xml +503 -0
  68. data/test/fixtures/xml/user/getrecenttracks_user_jnunemaker.xml +133 -0
  69. data/test/fixtures/xml/user/getrecommendedartists_sk_token_user_jnunemaker.xml +553 -0
  70. data/test/fixtures/xml/user/gettopalbums_user_jnunemaker.xml +704 -0
  71. data/test/fixtures/xml/user/gettopartists_period_overall_user_jnunemaker.xml +554 -0
  72. data/test/fixtures/xml/user/gettoptags_user_jnunemaker.xml +63 -0
  73. data/test/fixtures/xml/user/gettoptracks_user_jnunemaker.xml +750 -0
  74. data/test/fixtures/xml/user/getweeklyalbumchart_from_1138536002_to_1139140802_user_jnunemaker.xml +143 -0
  75. data/test/fixtures/xml/user/getweeklyalbumchart_from__to__user_jnunemaker.xml +31 -0
  76. data/test/fixtures/xml/user/getweeklyartistchart_from_1138536002_to_1139140802_user_jnunemaker.xml +201 -0
  77. data/test/fixtures/xml/user/getweeklyartistchart_from__to__user_jnunemaker.xml +21 -0
  78. data/test/fixtures/xml/user/getweeklychartlist_user_jnunemaker.xml +232 -0
  79. data/test/fixtures/xml/user/getweeklytrackchart_from_1138536002_to_1139140802_user_jnunemaker.xml +883 -0
  80. data/test/fixtures/xml/user/getweeklytrackchart_from__to__user_jnunemaker.xml +423 -0
  81. data/test/fixtures/xml/venue/getevents_venue_8807850.xml +280 -0
  82. data/test/fixtures/xml/venue/search_country__limit__page__venue_country_DE_venue_cotton.xml +72 -0
  83. data/test/mocks/rest.rb +67 -0
  84. data/test/test_helper.rb +18 -0
  85. data/test/unit/test_album.rb +76 -0
  86. data/test/unit/test_artist.rb +102 -0
  87. data/test/unit/test_chart.rb +35 -0
  88. data/test/unit/test_geo.rb +25 -0
  89. data/test/unit/test_playing.rb +53 -0
  90. data/test/unit/test_scrobble.rb +69 -0
  91. data/test/unit/test_simpleauth.rb +45 -0
  92. data/test/unit/test_tag.rb +57 -0
  93. data/test/unit/test_tokenauth.rb +45 -0
  94. data/test/unit/test_track.rb +82 -0
  95. data/test/unit/test_user.rb +299 -0
  96. data/test/unit/test_venue.rb +20 -0
  97. metadata +269 -0
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ notifications:
2
+ recipients:
3
+ - bodo@wannawork.de
4
+ rvm:
5
+ - 1.8.7
6
+ - 1.9.2
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # A sample Gemfile
2
+ source "http://rubygems.org"
3
+
4
+ gem "rake"
5
+ gem "hpricot", ">=0.4.86"
6
+ gem "i18n"
7
+ gem "activesupport", ">=1.4.2"
8
+
9
+ group :development do
10
+ gem "jeweler"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.0.8)
5
+ git (1.2.5)
6
+ hpricot (0.8.4)
7
+ i18n (0.5.0)
8
+ jeweler (1.5.2)
9
+ bundler (~> 1.0.0)
10
+ git (>= 1.2.5)
11
+ rake
12
+ rake (0.8.7)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ activesupport (>= 1.4.2)
19
+ hpricot (>= 0.4.86)
20
+ i18n
21
+ jeweler
22
+ rake
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ * v 0.4.0: Add geo class and support for events and locations
2
+ * v 0.3.0: update api to use v2.0 of the last.fm api and renamed gem to "Rockstar Gem"
3
+ * v 0.2.3: changed the way things get escaped in hopes that it would fix some problems some were having
4
+ * v 0.2.2: a bunch of changes from titanous, mostly refactoring
5
+ * v 0.2.0: added support for scrobbling tracks and now playing submission (Titanous)
6
+ * v 0.1.0: initial release
data/MIT-LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2007-2011 John Nunemaker, Bodo Tasche
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,72 @@
1
+ History.txt
2
+ MIT-LICENSE
3
+ Manifest
4
+ README.rdoc
5
+ Rakefile
6
+ examples/album.rb
7
+ examples/artist.rb
8
+ examples/lastfm.yml_example
9
+ examples/scrobble.rb
10
+ examples/tag.rb
11
+ examples/track.rb
12
+ examples/user.rb
13
+ lib/rockstar.rb
14
+ lib/rockstar/album.rb
15
+ lib/rockstar/artist.rb
16
+ lib/rockstar/auth.rb
17
+ lib/rockstar/base.rb
18
+ lib/rockstar/chart.rb
19
+ lib/rockstar/playing.rb
20
+ lib/rockstar/rest.rb
21
+ lib/rockstar/scrobble.rb
22
+ lib/rockstar/session.rb
23
+ lib/rockstar/simpleauth.rb
24
+ lib/rockstar/tag.rb
25
+ lib/rockstar/tokenauth.rb
26
+ lib/rockstar/track.rb
27
+ lib/rockstar/user.rb
28
+ lib/rockstar/version.rb
29
+ test/fixtures/xml/album/getinfo_album_Some_Hearts_artist_Carrie_Underwood.xml
30
+ test/fixtures/xml/artist/getsimilar_artist_Metallica.xml
31
+ test/fixtures/xml/artist/gettopalbums_artist_Metallica.xml
32
+ test/fixtures/xml/artist/gettopfans_artist_Metallica.xml
33
+ test/fixtures/xml/artist/gettoptags_artist_Metallica.xml
34
+ test/fixtures/xml/artist/gettoptracks_artist_Metallica.xml
35
+ test/fixtures/xml/tag/gettopalbums_tag_rock.xml
36
+ test/fixtures/xml/tag/gettopartists_tag_rock.xml
37
+ test/fixtures/xml/tag/gettoptags.xml
38
+ test/fixtures/xml/tag/gettoptracks_tag_rock.xml
39
+ test/fixtures/xml/track/gettopfans_artist_Carrie_Underwood_track_Before_He_Cheats.xml
40
+ test/fixtures/xml/track/gettoptags_artist_Carrie_Underwood_track_Before_He_Cheats.xml
41
+ test/fixtures/xml/track/love_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml
42
+ test/fixtures/xml/user/getfriends_user_jnunemaker.xml
43
+ test/fixtures/xml/user/getinfo_user_jnunemaker.xml
44
+ test/fixtures/xml/user/getinfo_user_oaknd1.xml
45
+ test/fixtures/xml/user/getinfo_user_wharle.xml
46
+ test/fixtures/xml/user/getlovedtracks_user_jnunemaker.xml
47
+ test/fixtures/xml/user/getneighbours_user_jnunemaker.xml
48
+ test/fixtures/xml/user/getrecenttracks_user_jnunemaker.xml
49
+ test/fixtures/xml/user/getrecommendedartists_sk_token_user_jnunemaker.xml
50
+ test/fixtures/xml/user/gettopalbums_user_jnunemaker.xml
51
+ test/fixtures/xml/user/gettopartists_user_jnunemaker.xml
52
+ test/fixtures/xml/user/gettoptags_user_jnunemaker.xml
53
+ test/fixtures/xml/user/gettoptracks_user_jnunemaker.xml
54
+ test/fixtures/xml/user/getweeklyalbumchart_from_1138536002_to_1139140802_user_jnunemaker.xml
55
+ test/fixtures/xml/user/getweeklyalbumchart_from__to__user_jnunemaker.xml
56
+ test/fixtures/xml/user/getweeklyartistchart_from_1138536002_to_1139140802_user_jnunemaker.xml
57
+ test/fixtures/xml/user/getweeklyartistchart_from__to__user_jnunemaker.xml
58
+ test/fixtures/xml/user/getweeklychartlist_user_jnunemaker.xml
59
+ test/fixtures/xml/user/getweeklytrackchart_from_1138536002_to_1139140802_user_jnunemaker.xml
60
+ test/fixtures/xml/user/getweeklytrackchart_from__to__user_jnunemaker.xml
61
+ test/mocks/rest.rb
62
+ test/test_helper.rb
63
+ test/unit/test_album.rb
64
+ test/unit/test_artist.rb
65
+ test/unit/test_chart.rb
66
+ test/unit/test_playing.rb
67
+ test/unit/test_scrobble.rb
68
+ test/unit/test_simpleauth.rb
69
+ test/unit/test_tag.rb
70
+ test/unit/test_tokenauth.rb
71
+ test/unit/test_track.rb
72
+ test/unit/test_user.rb
data/README.md ADDED
@@ -0,0 +1,135 @@
1
+ # Rockstar
2
+
3
+ Rockstar is a wrapper for the last.fm audioscrobbler web services (http://www.last.fm/api/). This gem is based on the scrobbler
4
+ gem by John Nunemaker and was updated to use the 2.0 version of the last.fm api
5
+
6
+ Below is just a sampling of how easy this lib is to use.
7
+
8
+ Please initialize your api key and secret before using the api:
9
+
10
+ Rockstar.lastfm = YAML.load_file('lastfm.yml')
11
+
12
+ Here is an example lastfm.yml:
13
+
14
+ api_key: "API"
15
+ api_secret: "SECRET"
16
+
17
+ If you want to use the api in an rails app, you could add an initializer in config/initializers/lastm.rb and load a config/lastfm.yml file.
18
+
19
+ rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
20
+ Rockstar.lastfm = YAML.load_file(rails_root + '/config/lastfm.yml')
21
+
22
+ ## Users
23
+
24
+ user = Rockstar::User.new('jnunemaker')
25
+
26
+ puts "#{user.username}'s Recent Tracks"
27
+ puts "=" * (user.username.length + 16)
28
+ user.recent_tracks.each { |t| puts t.name }
29
+
30
+ puts
31
+ puts
32
+
33
+ puts "#{user.username}'s Top Tracks"
34
+ puts "=" * (user.username.length + 13)
35
+ user.top_tracks.each { |t| puts "(#{t.playcount}) #{t.name}" }
36
+
37
+ ## Albums
38
+
39
+ album = Rockstar::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
40
+
41
+ puts "Album: #{album.name}"
42
+ puts "Artist: #{album.artist}"
43
+ puts "URL: #{album.url}"
44
+ puts "Release Date: #{album.release_date.strftime('%m/%d/%Y')}"
45
+
46
+ ## Artists
47
+
48
+ artist = Rockstar::Artist.new('Carrie Underwood')
49
+
50
+ puts 'Top Tracks'
51
+ puts "=" * 10
52
+ artist.top_tracks.each { |t| puts "(#{t.name}" }
53
+
54
+ puts
55
+
56
+ puts 'Similar Artists'
57
+ puts "=" * 15
58
+ artist.similar.each { |a| puts "(#{a.match}%) #{a.name}" }
59
+
60
+ ## Tags
61
+
62
+ tag = Rockstar::Tag.new('country')
63
+
64
+ puts 'Top Albums'
65
+ tag.top_albums.each { |a| puts "(#{a.count}) #{a.name} by #{a.artist}" }
66
+
67
+ puts
68
+
69
+ puts 'Top Tracks'
70
+ tag.top_tracks.each { |t| puts "(#{t.count}) #{t.name} by #{t.artist}" }
71
+
72
+ ## Tracks
73
+
74
+ track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats')
75
+ puts 'Fans'
76
+ puts "=" * 4
77
+ track.fans.each { |u| puts "(#{u.weight}) #{u.username}" }
78
+
79
+ # Love a song, session_key is returned by Rockstar::Auth. See Rockstar::TokenAuth or
80
+ # examples/scrobble.rb for a complete example
81
+ track.love(session_key)
82
+
83
+ ## Geo
84
+
85
+ geo = Rockstar::Geo.new
86
+
87
+ # Get events for a lat/long
88
+ geo.events(:lat => 50.0, :long => 12.3).each{|e| p "#{e.title} at #{e.venue.name}"}
89
+
90
+ # Get events for a location
91
+ geo.events(:location => 'london').each{|e| p "#{e.title} at #{e.venue.name}"}
92
+
93
+ # To get a list of possible locations use
94
+ geo.metros("germany").each{|m| p m.name}
95
+
96
+
97
+ ## Get rights to access the user data for scrobbing, now playing, events etc...
98
+
99
+ a = Rockstar::Auth.new
100
+ token = a.token
101
+
102
+ puts
103
+ puts "Please open http://www.last.fm/api/auth/?api_key=#{Rockstar.lastfm_api_key}&token=#{token}"
104
+ puts
105
+ puts "Press enter when done."
106
+
107
+ gets
108
+
109
+ session = a.session(token)
110
+
111
+ You can store the session.key somewhere and use it from now on to identify the user.
112
+
113
+ ## Scrobbling
114
+
115
+ track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats')
116
+ track.scrobble(Time.now, session.key)
117
+
118
+ ## Now Playing Submission
119
+
120
+ track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats')
121
+ track.updateNowPlaying(Time.now, session.key)
122
+
123
+ ## Note on Patches/Pull Requests
124
+
125
+ * Fork the project.
126
+ * Make your feature addition or bug fix.
127
+ * Add tests for it. This is important so I don't break it in a
128
+ future version unintentionally.
129
+ * Commit, do not mess with rakefile, version, or history.
130
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
131
+ * Send me a pull request. Bonus points for topic branches.
132
+
133
+ ## Copyright
134
+
135
+ Copyright (c) 2007-2011 John Nunemaker, Bodo "Bitboxer" Tasche, Nick "zapnap" Plante. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ # Rakefile
2
+ require 'rubygems'
3
+ require 'rake/dsl_definition'
4
+
5
+ require 'rake'
6
+ require File.expand_path('../lib/rockstar/version', __FILE__)
7
+
8
+ begin
9
+ require 'jeweler'
10
+ Jeweler::Tasks.new do |gem|
11
+ gem.name = "rockstar-custom"
12
+ gem.summary = %Q{wrapper for audioscrobbler (last.fm) web services. with listener count on artist}
13
+ gem.description = %Q{This gem is an updated version of the rockstar gem for the last.fm api. This adds "listener count" to artist.}
14
+ gem.email = "scottf7@me.com"
15
+ gem.homepage = "http://github.com/scottmfisher/rockstar"
16
+ gem.authors = ["Bodo Tasche", "scottmfisher"]
17
+ gem.add_dependency("hpricot", ">=0.4.86")
18
+ gem.add_dependency("activesupport", ">=1.4.2")
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
23
+ end
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/test_*.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ #task :test => :check_dependencies
33
+
34
+ task :default => :test
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.6.1
@@ -0,0 +1 @@
1
+ lastfm.yml
data/examples/album.rb ADDED
@@ -0,0 +1,16 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'rockstar'))
2
+
3
+ # Please enter your API-Keys into lastfm.yml first.
4
+ # You can find them here : http://www.lastfm.de/api/account
5
+ Rockstar.lastfm = YAML.load_file(File.join(File.dirname(__FILE__), 'lastfm.yml'))
6
+
7
+ album = Rockstar::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
8
+
9
+ puts "Album: #{album.name}"
10
+ puts "Artist: #{album.artist}"
11
+ puts "URL: #{album.url}"
12
+ puts "Release Date: #{album.release_date.strftime('%m/%d/%Y')}"
13
+ puts "Large cover: #{album.image_large}"
14
+ puts
15
+ puts
16
+ puts "Summary: #{album.summary}"
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'rockstar'))
2
+
3
+ # Please enter your API-Keys into lastfm.yml first.
4
+ # You can find them here : http://www.lastfm.de/api/account
5
+ Rockstar.lastfm = YAML.load_file(File.join(File.dirname(__FILE__), 'lastfm.yml'))
6
+
7
+ artist = Rockstar::Artist.new('Metallica')
8
+
9
+ puts 'Top Tracks'
10
+ puts "=" * 10
11
+ artist.top_tracks.each { |t| puts "#{t.name}" }
12
+
13
+ puts
14
+
15
+ puts 'Events'
16
+ puts '=' * 10
17
+ artist.events.each { |e| puts "#{e.venue.city} at #{e.venue.name} on #{e.start_date.strftime("%D")}" }
18
+
19
+ puts
20
+
21
+ puts 'Similar Artists'
22
+ puts "=" * 15
23
+ artist.similar.each { |a| puts "(#{a.match}%) #{a.name}" }
data/examples/geo.rb ADDED
@@ -0,0 +1,9 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'rockstar'))
2
+
3
+ # Please enter your API-Keys into lastfm.yml first.
4
+ # You can find them here : http://www.lastfm.de/api/account
5
+ Rockstar.lastfm = YAML.load_file(File.join(File.dirname(__FILE__), 'lastfm.yml'))
6
+
7
+ geo = Rockstar::Geo.new
8
+
9
+ geo.events(:location => 'london').each{|e| p "#{e.title} at #{e.venue.name}"}
@@ -0,0 +1,3 @@
1
+ # Please enter your API-Keys. You can find them here : http://www.lastfm.de/api/account
2
+ api_key: "API"
3
+ api_secret: "KEY"
@@ -0,0 +1,45 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'rockstar'))
2
+
3
+ # Please enter your API-Keys into lastfm.yml first.
4
+ # You can find them here : http://www.lastfm.de/api/account
5
+ Rockstar.lastfm = YAML.load_file(File.join(File.dirname(__FILE__), 'lastfm.yml'))
6
+
7
+ # This is the desktop app aproach to token auth. See Rockstar::TokenAuth for
8
+ # details on how to get a token for a web app.
9
+
10
+ a = Rockstar::Auth.new
11
+ token = a.token
12
+
13
+ puts
14
+ puts "Please open http://www.last.fm/api/auth/?api_key=#{Rockstar.lastfm_api_key}&token=#{token}"
15
+ puts
16
+ puts "Press enter when done."
17
+
18
+ gets
19
+
20
+ session = a.session(token)
21
+
22
+ Rockstar::Track.scrobble(
23
+ :session_key => session.key,
24
+ :track => "Viva La Vida",
25
+ :artist => "Coldplay",
26
+ :album => "Viva La Vida",
27
+ :time => Time.new,
28
+ :length => 244,
29
+ :track_number => 7
30
+ )
31
+
32
+ # Love the Song :
33
+ l_status = Rockstar::Track.new('Coldplay', 'Viva La Vida').love(session.key)
34
+
35
+ puts "Love track status : #{l_status}"
36
+
37
+ Rockstar::Track.updateNowPlaying(
38
+ :session_key => session.key,
39
+ :track => "Viva La Vida",
40
+ :artist => "Coldplay",
41
+ :album => "Viva La Vida",
42
+ :time => Time.new,
43
+ :length => 244,
44
+ :track_number => 7
45
+ )
data/examples/tag.rb ADDED
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'rockstar'))
2
+
3
+ # Please enter your API-Keys into lastfm.yml first.
4
+ # You can find them here : http://www.lastfm.de/api/account
5
+ Rockstar.lastfm = YAML.load_file(File.join(File.dirname(__FILE__), 'lastfm.yml'))
6
+
7
+ tag = Rockstar::Tag.new('country')
8
+
9
+ puts 'Top Tags '
10
+ Rockstar::Tag.top_tags.each { |a| puts "(#{a.count}) #{a.name}" }
11
+
12
+ puts
13
+
14
+ puts 'Top Albums'
15
+ tag.top_albums.each { |a| puts "(#{a.count}) #{a.name} by #{a.artist}" }
16
+
17
+ puts
18
+
19
+ puts 'Top Tracks'
20
+ tag.top_tracks.each { |t| puts "(#{t.count}) #{t.name} by #{t.artist}" }