jonaustin-rockstar 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +8 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +62 -0
- data/History.txt +6 -0
- data/MIT-LICENSE +19 -0
- data/Manifest +72 -0
- data/README.md +173 -0
- data/Rakefile +32 -0
- data/VERSION +1 -0
- data/examples/.gitignore +1 -0
- data/examples/album.rb +16 -0
- data/examples/artist.rb +25 -0
- data/examples/geo.rb +60 -0
- data/examples/lastfm.yml_example +3 -0
- data/examples/scrobble.rb +45 -0
- data/examples/tag.rb +20 -0
- data/examples/track.rb +14 -0
- data/examples/user.rb +18 -0
- data/lib/rockstar.rb +46 -0
- data/lib/rockstar/album.rb +104 -0
- data/lib/rockstar/artist.rb +183 -0
- data/lib/rockstar/auth.rb +38 -0
- data/lib/rockstar/base.rb +48 -0
- data/lib/rockstar/chart.rb +31 -0
- data/lib/rockstar/event.rb +73 -0
- data/lib/rockstar/geo.rb +47 -0
- data/lib/rockstar/library.rb +13 -0
- data/lib/rockstar/metro.rb +26 -0
- data/lib/rockstar/rest.rb +66 -0
- data/lib/rockstar/session.rb +19 -0
- data/lib/rockstar/tag.rb +100 -0
- data/lib/rockstar/track.rb +265 -0
- data/lib/rockstar/user.rb +205 -0
- data/lib/rockstar/venue.rb +59 -0
- data/lib/rockstar/version.rb +3 -0
- data/rockstar.gemspec +176 -0
- data/test/fixtures/xml/album/getinfo_album_Radio_Retalation_artist_Thievery_Corporation.xml +21 -0
- data/test/fixtures/xml/album/getinfo_album_Some_Hearts_artist_Carrie_Underwood.xml +63 -0
- data/test/fixtures/xml/artist/getevents_artist_Metallica.xml +1064 -0
- data/test/fixtures/xml/artist/getimages_artist_Metallica_page_2.xml +1074 -0
- data/test/fixtures/xml/artist/getinfo_artist_Metallica.xml +115 -0
- data/test/fixtures/xml/artist/getinfo_mbid_65f4f0c5-ef9e-490c-aee3-909e7ae6b2ab.xml +115 -0
- data/test/fixtures/xml/artist/getsimilar_artist_Metallica.xml +1203 -0
- data/test/fixtures/xml/artist/gettopalbums_artist_Metallica.xml +704 -0
- data/test/fixtures/xml/artist/gettopfans_artist_Metallica.xml +504 -0
- data/test/fixtures/xml/artist/gettoptags_artist_Metallica.xml +403 -0
- data/test/fixtures/xml/artist/gettoptracks_artist_Metallica.xml +800 -0
- data/test/fixtures/xml/geo/getevents_location_london.xml +531 -0
- data/test/fixtures/xml/geo/getmetros_country_germany.xml +44 -0
- data/test/fixtures/xml/geo/gettopartists_country_spain_limit_50_page_.xml +561 -0
- data/test/fixtures/xml/geo/gettoptracks_country_spain_limit_50_page_.xml +1004 -0
- data/test/fixtures/xml/library/getalbums_user_jnunemaker.xml +704 -0
- data/test/fixtures/xml/library/getartists_user_jnunemaker.xml +554 -0
- data/test/fixtures/xml/tag/gettopalbums_tag_rock.xml +654 -0
- data/test/fixtures/xml/tag/gettopartists_tag_rock.xml +504 -0
- data/test/fixtures/xml/tag/gettoptags.xml +1253 -0
- data/test/fixtures/xml/tag/gettoptracks_tag_rock.xml +704 -0
- data/test/fixtures/xml/track/getinfo_artist_Carrie_Underwood_track_Before_He_Cheats.xml +55 -0
- data/test/fixtures/xml/track/getinfo_artist_Karrie_Underwood_track_Before_He_Cheats.xml +55 -0
- data/test/fixtures/xml/track/getsimilar_artist_Carrie_Underwood_limit_10_track_Before_He_Cheats.xml +185 -0
- data/test/fixtures/xml/track/gettopfans_artist_Carrie_Underwood_track_Before_He_Cheats.xml +504 -0
- data/test/fixtures/xml/track/gettoptags_artist_Carrie_Underwood_track_Before_He_Cheats.xml +403 -0
- data/test/fixtures/xml/track/gettoptags_artist_Carrie_Underwood_track_Wasted.xml +405 -0
- data/test/fixtures/xml/track/love_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +2 -0
- data/test/fixtures/xml/track/updatenowplaying_artist_Carrie_Underwood_sk_tag_track_Before_He_Cheats.xml +10 -0
- data/test/fixtures/xml/user/getevents_sk_token_user_bodot.xml +513 -0
- data/test/fixtures/xml/user/getfriends_user_jnunemaker.xml +173 -0
- data/test/fixtures/xml/user/getinfo_user_jnunemaker.xml +22 -0
- data/test/fixtures/xml/user/getinfo_user_oaknd1.xml +22 -0
- data/test/fixtures/xml/user/getinfo_user_wharle.xml +22 -0
- data/test/fixtures/xml/user/getlovedtracks_user_jnunemaker.xml +775 -0
- data/test/fixtures/xml/user/getneighbours_user_jnunemaker.xml +503 -0
- data/test/fixtures/xml/user/getrecenttracks_user_jnunemaker.xml +133 -0
- data/test/fixtures/xml/user/getrecommendedartists_sk_token_user_jnunemaker.xml +553 -0
- data/test/fixtures/xml/user/gettopalbums_user_jnunemaker.xml +704 -0
- data/test/fixtures/xml/user/gettopartists_period_3month_user_jnunemaker.xml +710 -0
- data/test/fixtures/xml/user/gettopartists_period_overall_user_jnunemaker.xml +554 -0
- data/test/fixtures/xml/user/gettoptags_user_jnunemaker.xml +63 -0
- data/test/fixtures/xml/user/gettoptracks_user_jnunemaker.xml +750 -0
- data/test/fixtures/xml/user/getweeklyalbumchart_from_1138536002_to_1139140802_user_jnunemaker.xml +143 -0
- data/test/fixtures/xml/user/getweeklyalbumchart_from__to__user_jnunemaker.xml +31 -0
- data/test/fixtures/xml/user/getweeklyartistchart_from_1138536002_to_1139140802_user_jnunemaker.xml +201 -0
- data/test/fixtures/xml/user/getweeklyartistchart_from__to__user_jnunemaker.xml +21 -0
- data/test/fixtures/xml/user/getweeklychartlist_user_jnunemaker.xml +232 -0
- data/test/fixtures/xml/user/getweeklytrackchart_from_1138536002_to_1139140802_user_jnunemaker.xml +883 -0
- data/test/fixtures/xml/user/getweeklytrackchart_from__to__user_jnunemaker.xml +423 -0
- data/test/fixtures/xml/venue/getevents_venue_8807850.xml +280 -0
- data/test/fixtures/xml/venue/search_country__limit__page__venue_country_DE_venue_cotton.xml +72 -0
- data/test/mocks/rest.rb +50 -0
- data/test/test_helper.rb +18 -0
- data/test/unit/test_album.rb +76 -0
- data/test/unit/test_artist.rb +123 -0
- data/test/unit/test_chart.rb +35 -0
- data/test/unit/test_geo.rb +51 -0
- data/test/unit/test_library.rb +65 -0
- data/test/unit/test_rockstar.rb +15 -0
- data/test/unit/test_tag.rb +57 -0
- data/test/unit/test_track.rb +93 -0
- data/test/unit/test_user.rb +309 -0
- data/test/unit/test_venue.rb +20 -0
- metadata +243 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d592c200873023f91fc16692fe0340f027e11d55
|
4
|
+
data.tar.gz: 90af841dae93e46038fc61378a0562ebd7af5907
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1dfc64aa10a817d68fafe8f58666e2c6b8819fb0705199be93f2829a1b54109885de4aeeff2bc018074b3016d604fb4de63b581ee8d3ec1518443a30784107f9
|
7
|
+
data.tar.gz: 8e79c9dba95451a1a0217dae1171d1b7483091234aebcb98cc5d92d87431c7647a774ee1a8677018ee75e653a770e2b1d2fa009801d2773e7797ed33961da8e6
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.0.8)
|
5
|
+
addressable (2.3.5)
|
6
|
+
builder (3.2.2)
|
7
|
+
descendants_tracker (0.0.3)
|
8
|
+
faraday (0.8.9)
|
9
|
+
multipart-post (~> 1.2.0)
|
10
|
+
git (1.2.6)
|
11
|
+
github_api (0.11.1)
|
12
|
+
addressable (~> 2.3)
|
13
|
+
descendants_tracker (~> 0.0.1)
|
14
|
+
faraday (~> 0.8, < 0.10)
|
15
|
+
hashie (>= 1.2)
|
16
|
+
multi_json (>= 1.7.5, < 2.0)
|
17
|
+
nokogiri (~> 1.6.0)
|
18
|
+
oauth2
|
19
|
+
hashie (2.0.5)
|
20
|
+
highline (1.6.20)
|
21
|
+
hpricot (0.8.4)
|
22
|
+
httpauth (0.2.0)
|
23
|
+
i18n (0.5.0)
|
24
|
+
jeweler (2.0.0)
|
25
|
+
builder
|
26
|
+
bundler (>= 1.0)
|
27
|
+
git (>= 1.2.5)
|
28
|
+
github_api
|
29
|
+
highline (>= 1.6.15)
|
30
|
+
nokogiri (>= 1.5.10)
|
31
|
+
rake
|
32
|
+
rdoc
|
33
|
+
json (1.8.1)
|
34
|
+
jwt (0.1.10)
|
35
|
+
multi_json (>= 1.5)
|
36
|
+
mini_portile (0.5.2)
|
37
|
+
multi_json (1.8.4)
|
38
|
+
multi_xml (0.5.5)
|
39
|
+
multipart-post (1.2.0)
|
40
|
+
nokogiri (1.6.1)
|
41
|
+
mini_portile (~> 0.5.0)
|
42
|
+
oauth2 (0.9.2)
|
43
|
+
faraday (~> 0.8)
|
44
|
+
httpauth (~> 0.2)
|
45
|
+
jwt (~> 0.1.4)
|
46
|
+
multi_json (~> 1.0)
|
47
|
+
multi_xml (~> 0.5)
|
48
|
+
rack (~> 1.2)
|
49
|
+
rack (1.5.2)
|
50
|
+
rake (0.8.7)
|
51
|
+
rdoc (4.1.1)
|
52
|
+
json (~> 1.4)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
activesupport (>= 1.4.2)
|
59
|
+
hpricot (>= 0.4.86)
|
60
|
+
i18n
|
61
|
+
jeweler
|
62
|
+
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,173 @@
|
|
1
|
+
# Rockstar [![Build Status](https://secure.travis-ci.org/putpat/rockstar.png?branch=master)](https://next.travis-ci.org/putpat/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
|
+
Alternatively you can provide a hash with the api key and secret:
|
23
|
+
|
24
|
+
Rockstar.lastfm = {:api_key => "API", :api_secret => "SECRET"}
|
25
|
+
|
26
|
+
## Users
|
27
|
+
|
28
|
+
user = Rockstar::User.new('jnunemaker')
|
29
|
+
|
30
|
+
puts "#{user.username}'s Recent Tracks"
|
31
|
+
puts "=" * (user.username.length + 16)
|
32
|
+
user.recent_tracks.each { |t| puts t.name }
|
33
|
+
|
34
|
+
puts
|
35
|
+
puts
|
36
|
+
|
37
|
+
puts "#{user.username}'s Top Tracks"
|
38
|
+
puts "=" * (user.username.length + 13)
|
39
|
+
user.top_tracks.each { |t| puts "(#{t.playcount}) #{t.name}" }
|
40
|
+
|
41
|
+
## Albums
|
42
|
+
|
43
|
+
album = Rockstar::Album.new('Carrie Underwood', 'Some Hearts', :include_info => true)
|
44
|
+
|
45
|
+
puts "Album: #{album.name}"
|
46
|
+
puts "Artist: #{album.artist}"
|
47
|
+
puts "URL: #{album.url}"
|
48
|
+
puts "Release Date: #{album.release_date.strftime('%m/%d/%Y')}"
|
49
|
+
|
50
|
+
## Artists
|
51
|
+
|
52
|
+
If you want to load all informations about an artist or any other
|
53
|
+
object, you have to add `:include_info => true` .
|
54
|
+
|
55
|
+
artist = Rockstar::Artist.new('Carrie Underwood', :include_info => true)
|
56
|
+
|
57
|
+
puts artist.url
|
58
|
+
|
59
|
+
puts 'Top Tracks'
|
60
|
+
puts "=" * 10
|
61
|
+
artist.top_tracks.each { |t| puts "(#{t.name}" }
|
62
|
+
|
63
|
+
puts
|
64
|
+
|
65
|
+
puts 'Similar Artists'
|
66
|
+
puts "=" * 15
|
67
|
+
artist.similar.each { |a| puts "(#{a.match}%) #{a.name}" }
|
68
|
+
|
69
|
+
## Tags
|
70
|
+
|
71
|
+
tag = Rockstar::Tag.new('country')
|
72
|
+
|
73
|
+
puts 'Top Albums'
|
74
|
+
tag.top_albums.each { |a| puts "(#{a.count}) #{a.name} by #{a.artist}" }
|
75
|
+
|
76
|
+
puts
|
77
|
+
|
78
|
+
puts 'Top Tracks'
|
79
|
+
tag.top_tracks.each { |t| puts "(#{t.count}) #{t.name} by #{t.artist}" }
|
80
|
+
|
81
|
+
## Geo
|
82
|
+
|
83
|
+
geo = Rockstar::Geo.new
|
84
|
+
|
85
|
+
# Get events for a lat/long
|
86
|
+
geo.events(:lat => 50.0, :long => 12.3).each{|e| p "#{e.title} at #{e.venue.name}"}
|
87
|
+
|
88
|
+
# Get events for a location
|
89
|
+
geo.events(:location => 'london').each{|e| p "#{e.title} at #{e.venue.name}"}
|
90
|
+
|
91
|
+
# To get a list of possible locations use
|
92
|
+
geo.metros("germany").each{|m| p m.name}
|
93
|
+
|
94
|
+
# Retrieve list of top tracks by country
|
95
|
+
geo.toptracks('united kingdom', 10).each{|t| p "#{t.name} by #{t.artist}"}
|
96
|
+
|
97
|
+
# Retrieve list of top artists by country
|
98
|
+
geo.topartists('united kingdom', 10).each{|a| p "artist #{a.name} with #{a.listenercount} listeners"}
|
99
|
+
|
100
|
+
|
101
|
+
## Library
|
102
|
+
|
103
|
+
# Get artists and albums for user
|
104
|
+
library = Rockstar::Library.new
|
105
|
+
|
106
|
+
puts 'Artists'
|
107
|
+
library.artists(false, :user => 'jnunemaker').each { |a| puts a.name }
|
108
|
+
|
109
|
+
puts 'Albums'
|
110
|
+
library.albums(false, :user => 'jnunemaker').each { |a| puts a.name }
|
111
|
+
|
112
|
+
# Get it with Rockstar::User
|
113
|
+
user = Rockstar::User.new('jnunemaker')
|
114
|
+
|
115
|
+
puts 'Artists'
|
116
|
+
user.artists.each { |a| puts a.name }
|
117
|
+
|
118
|
+
puts 'Albums'
|
119
|
+
user.albums.each { |a| puts a.name }
|
120
|
+
|
121
|
+
## Get rights to access the user data for scrobbing, now playing, events etc...
|
122
|
+
|
123
|
+
a = Rockstar::Auth.new
|
124
|
+
token = a.token
|
125
|
+
|
126
|
+
puts
|
127
|
+
puts "Please open http://www.last.fm/api/auth/?api_key=#{Rockstar.lastfm_api_key}&token=#{token}"
|
128
|
+
puts
|
129
|
+
puts "Press enter when done."
|
130
|
+
|
131
|
+
gets
|
132
|
+
|
133
|
+
session = a.session(token)
|
134
|
+
|
135
|
+
You can store the session.key somewhere and use it from now on to identify the user. More
|
136
|
+
details can be found in Rockstar::Auth or examples/scrobble.rb
|
137
|
+
|
138
|
+
## Tracks
|
139
|
+
|
140
|
+
track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats')
|
141
|
+
puts 'Fans'
|
142
|
+
puts "=" * 4
|
143
|
+
track.fans.each { |u| puts "(#{u.weight}) #{u.username}" }
|
144
|
+
|
145
|
+
track.love(session.key)
|
146
|
+
|
147
|
+
## Scrobbling
|
148
|
+
|
149
|
+
track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats')
|
150
|
+
track.scrobble(Time.now, session.key)
|
151
|
+
|
152
|
+
## Now Playing Submission
|
153
|
+
|
154
|
+
track = Rockstar::Track.new('Carrie Underwood', 'Before He Cheats')
|
155
|
+
track.updateNowPlaying(Time.now, session.key)
|
156
|
+
|
157
|
+
## Note on Patches/Pull Requests
|
158
|
+
|
159
|
+
* Fork the project.
|
160
|
+
* Make your feature addition or bug fix.
|
161
|
+
* Add tests for it. This is important so I don't break it in a
|
162
|
+
future version unintentionally.
|
163
|
+
* Commit, do not mess with rakefile, version, or history.
|
164
|
+
(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)
|
165
|
+
* Send me a pull request. Bonus points for topic branches.
|
166
|
+
|
167
|
+
## Copyright
|
168
|
+
|
169
|
+
Copyright (c) 2007-2011 John Nunemaker, Bodo "Bitboxer" Tasche, Nick "zapnap" Plante. See LICENSE for details.
|
170
|
+
|
171
|
+
## Acknowledgements
|
172
|
+
|
173
|
+
Thanks to [putpat.tv](http://www.putpat.tv) for sponsering the work on the rockstar gem.
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Rakefile
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require File.expand_path('../lib/rockstar/version', __FILE__)
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "jonaustin-rockstar"
|
10
|
+
gem.summary = %Q{wrapper for audioscrobbler (last.fm) web services}
|
11
|
+
gem.description = %Q{This gem is an updated version of jnunemakers scrobbler gem. Rockstar uses v2.0 of the last.fm api.}
|
12
|
+
gem.email = "jon.i.austin@gmail.com"
|
13
|
+
gem.homepage = "http://github.com/jonaustin/rockstar"
|
14
|
+
gem.authors = ["Jon Austin", "Bodo Tasche"]
|
15
|
+
gem.add_dependency("hpricot", ">=0.4.86")
|
16
|
+
gem.add_dependency("activesupport", ">=1.4.2")
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/test_*.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
#task :test => :check_dependencies
|
31
|
+
|
32
|
+
task :default => :test
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.7.1
|
data/examples/.gitignore
ADDED
@@ -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}"
|
data/examples/artist.rb
ADDED
@@ -0,0 +1,25 @@
|
|
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', :include_info => true)
|
8
|
+
|
9
|
+
puts artist.url
|
10
|
+
|
11
|
+
puts 'Top Tracks'
|
12
|
+
puts "=" * 10
|
13
|
+
artist.top_tracks.each { |t| puts "#{t.name}" }
|
14
|
+
|
15
|
+
puts
|
16
|
+
|
17
|
+
puts 'Events'
|
18
|
+
puts '=' * 10
|
19
|
+
artist.events.each { |e| puts "#{e.venue.city} at #{e.venue.name} on #{e.start_date.strftime("%D")}" }
|
20
|
+
|
21
|
+
puts
|
22
|
+
|
23
|
+
puts 'Similar Artists'
|
24
|
+
puts "=" * 15
|
25
|
+
artist.similar.each { |a| puts "(#{a.match}%) #{a.name}" }
|