glutton_lastfm 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,9 +1,15 @@
1
1
  = glutton_lastfm
2
2
 
3
- Ruby last.fm API wrapper written using HTTParty. A last.fm API key is required.
3
+ Simple Ruby wrapper for the last.fm API (version 2.0) written using HTTParty.
4
4
 
5
- See: http://last.fm/api & http://httparty.rubyforge.org
5
+ == Installation
6
6
 
7
+ sudo gem install glutton_fm
8
+
9
+ This gem is hosted at: http://rubygems.org/gems/glutton_lastfm
10
+
11
+ <b>Note:</b> A last.fm API key is also required. See: http://last.fm/api
12
+
7
13
  == Implemented Methods
8
14
 
9
15
  <tt>[method invocation]</tt> => [api docs url]:
@@ -49,6 +55,8 @@ See: http://last.fm/api & http://httparty.rubyforge.org
49
55
 
50
56
  pp album_info
51
57
 
58
+ More examples can be found in the <tt>examples</tt> folder of the source repository.
59
+
52
60
  == Query Responses
53
61
 
54
62
  Queries to glutton_lastfm methods return hierarchical hash / array strucutres. As shown above, it is best to familarize yourself with the returned data using the <tt>pp</tt> (pretty print) inspector.
@@ -56,7 +64,7 @@ Queries to glutton_lastfm methods return hierarchical hash / array strucutres. A
56
64
  Here's a look at the returned data in a pseudo-structure. In reality all hash keys are strings.
57
65
 
58
66
  * artist_info & artist_info_by_mbid
59
- artist info{
67
+ artist_info{
60
68
  name
61
69
  mbid
62
70
  url
@@ -130,6 +138,30 @@ Here's a look at the returned data in a pseudo-structure. In reality all hash ke
130
138
  image[]
131
139
  }
132
140
 
141
+ <b>Note:</b> Since these objects are generated from the last.fm XML responses their structure is idiosyncratic; be cautious of inconsistencies and superfluous nesting.
142
+
143
+ == Exceptions
144
+
145
+ The following custom exceptions may be thrown by the library:
146
+
147
+ <tt>Unauthorized</tt>:: Access to the API was refused. Check your API key.
148
+ <tt>NotFound</tt>:: Last.fm returned a 404 (Page Not Found) HTTP code for your request.
149
+ <tt>QueryStatusFail</tt>:: Received a well-formed response but the status attribute shows that your request failed.
150
+ <tt>QueryArgumentFail</tt>:: There was a problem with the parameters supplied to the API method.
151
+ <tt>UnknownFail</tt>:: An unanticipated error occurred. If this happens consistently, post a GitHub project issue.
152
+
153
+ <b>Note:</b> If you receive a <tt>REXML::ParseException</tt> that looks like the following, then the last.fm API may be offline:
154
+
155
+ /usr/lib/ruby/1.8/rexml/parsers/baseparser.rb:330:in `pull': Missing end tag for 'HR' (got "BODY") (REXML::ParseException)
156
+
157
+ == Thanks
158
+
159
+ Respect to the creators and maintainers of HTTParty, FakeWeb and Jeweler.
160
+
161
+ * http://github.com/jnunemaker/httparty
162
+ * http://github.com/chrisk/fakeweb
163
+ * http://github.com/technicalpickles/jeweler
164
+
133
165
  == License
134
166
 
135
- This is free and unencumbered software released into the public domain. See LICENSE for details.
167
+ This is free and unencumbered software released into the public domain. See LICENSE for details.
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/stungeye/glutton_lastfm"
12
12
  gem.authors = ["Wally Glutton"]
13
13
  gem.add_dependency("httparty", ">= 0.5.0")
14
+ gem.add_development_dependency("fakeweb", ">= 1.2.8")
14
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
16
  end
16
17
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -0,0 +1,28 @@
1
+ # Example: Calling all availble glutton_lastfm methods.
2
+
3
+ require 'rubygems'
4
+ require 'glutton_lastfm'
5
+ require 'pp'
6
+
7
+ last = GluttonLastfm.new '<your last.fm API key>'
8
+
9
+ artist = 'Leonard Cohen'
10
+
11
+ artist_search = last.artist_search artist
12
+ artist_info = last.artist_info artist
13
+ artist_info_by_mbid = last.artist_info_by_mbid '65314b12-0e08-43fa-ba33-baaa7b874c15'
14
+ artist_top_albums = last.artist_top_albums artist
15
+ artist_top_tracks = last.artist_top_tracks artist
16
+ artist_top_tags = last.artist_top_tags artist
17
+ artist_events = last.artist_events artist
18
+
19
+ album = 'Songs of Leonard Cohen'
20
+
21
+ album_search = last.album_search album
22
+ album_info = last.album_info artist, album
23
+ album_info_by_mbid = last.album_info_by_mbid '256312e7-0377-47e0-b2e6-df2c6e0cd2e8'
24
+
25
+ # Inspect any of the returned structures using pp (pretty print):
26
+
27
+ pp artist_info
28
+
@@ -0,0 +1,15 @@
1
+ # Example: Looping Through Arist Tag Names and Image Urls
2
+
3
+ require 'rubygems'
4
+ require 'glutton_lastfm'
5
+
6
+ last = GluttonLastfm.new '<your last.fm API key>'
7
+
8
+ artist = 'Buck 65'
9
+ artist_info = last.artist_info artist
10
+
11
+ puts "#{artist} Tags: "
12
+ artist_info['tags']['tag'].each { |tag| puts tag['name'] }
13
+ puts
14
+ puts "#{artist} Image URLs: "
15
+ artist_info['image'].each { |img| puts img }
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{glutton_lastfm}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wally Glutton"]
12
- s.date = %q{2010-05-09}
12
+ s.date = %q{2010-05-10}
13
13
  s.description = %q{Simple last.fm API wrapper written using HTTParty in Ruby.}
14
14
  s.email = %q{stungeye@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -23,8 +23,12 @@ Gem::Specification.new do |s|
23
23
  "README.rdoc",
24
24
  "Rakefile",
25
25
  "VERSION",
26
+ "examples/all_methods.rb",
27
+ "examples/artist_tags_and_images.rb",
26
28
  "glutton_lastfm.gemspec",
27
29
  "lib/glutton_lastfm.rb",
30
+ "test/fixtures/artist_info_prince.xml",
31
+ "test/fixtures/invalid_api_key.xml",
28
32
  "test/helper.rb",
29
33
  "test/test_glutton_lastfm.rb"
30
34
  ]
@@ -35,7 +39,9 @@ Gem::Specification.new do |s|
35
39
  s.summary = %q{Ruby last.fm API wrapper.}
36
40
  s.test_files = [
37
41
  "test/helper.rb",
38
- "test/test_glutton_lastfm.rb"
42
+ "test/test_glutton_lastfm.rb",
43
+ "examples/artist_tags_and_images.rb",
44
+ "examples/all_methods.rb"
39
45
  ]
40
46
 
41
47
  if s.respond_to? :specification_version then
@@ -44,11 +50,14 @@ Gem::Specification.new do |s|
44
50
 
45
51
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
46
52
  s.add_runtime_dependency(%q<httparty>, [">= 0.5.0"])
53
+ s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
47
54
  else
48
55
  s.add_dependency(%q<httparty>, [">= 0.5.0"])
56
+ s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
49
57
  end
50
58
  else
51
59
  s.add_dependency(%q<httparty>, [">= 0.5.0"])
60
+ s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
52
61
  end
53
62
  end
54
63
 
@@ -4,6 +4,7 @@
4
4
  #
5
5
  # Author : Wally Glutton - http://stungeye.com
6
6
  # Required : Last.fm API Key - http://www.last.fm/api
7
+ # Source Repo : http://github.com/stungeye/glutton_lastfm
7
8
  # Gem Dependence : HTTParty - Installed by gem along with glutton_lastfm.
8
9
  # Ruby Version : Written and tested using Ruby 1.8.7.
9
10
  # License : This is free and unencumbered software released into the public domain. See LICENSE for details.
@@ -0,0 +1,149 @@
1
+ <lfm status="ok">
2
+ <artist>
3
+ <name>Prince</name>
4
+ <mbid>070d193a-845c-479f-980e-bef15710653e</mbid>
5
+ <url>http://www.last.fm/music/Prince</url>
6
+ <image size="small">http://userserve-ak.last.fm/serve/34/46190147.png</image>
7
+ <image size="medium">http://userserve-ak.last.fm/serve/64/46190147.png</image>
8
+ <image size="large">http://userserve-ak.last.fm/serve/126/46190147.png</image>
9
+ <image size="extralarge">http://userserve-ak.last.fm/serve/252/46190147.png</image>
10
+ <image size="mega">http://userserve-ak.last.fm/serve/_/46190147/Prince.png</image>
11
+ <streamable>1</streamable>
12
+ <stats>
13
+ <listeners>886644</listeners>
14
+ <playcount>15259751</playcount>
15
+ </stats>
16
+
17
+ <similar>
18
+ <artist>
19
+ <name>Prince &amp; The Revolution</name>
20
+ <url>http://www.last.fm/music/Prince%2B%2526%2BThe%2BRevolution</url>
21
+ <image size="small">http://userserve-ak.last.fm/serve/34/603760.jpg</image>
22
+ <image size="medium">http://userserve-ak.last.fm/serve/64/603760.jpg</image>
23
+ <image size="large">http://userserve-ak.last.fm/serve/126/603760.jpg</image>
24
+ <image size="extralarge">http://userserve-ak.last.fm/serve/252/603760.jpg</image>
25
+ <image size="mega">http://userserve-ak.last.fm/serve/_/603760/Prince++The+Revolution.jpg</image>
26
+ </artist>
27
+ <artist>
28
+ <name>Prince and the New Power Generation</name>
29
+ <url>http://www.last.fm/music/Prince+and+the+New+Power+Generation</url>
30
+ <image size="small">http://userserve-ak.last.fm/serve/34/138712.jpg</image>
31
+ <image size="medium">http://userserve-ak.last.fm/serve/64/138712.jpg</image>
32
+ <image size="large">http://userserve-ak.last.fm/serve/126/138712.jpg</image>
33
+ <image size="extralarge">http://userserve-ak.last.fm/serve/252/138712.jpg</image>
34
+ <image size="mega">http://userserve-ak.last.fm/serve/500/138712/Prince+and+the+New+Power+Generation.jpg</image>
35
+ </artist>
36
+ <artist>
37
+ <name>The Time</name>
38
+ <url>http://www.last.fm/music/The+Time</url>
39
+ <image size="small">http://userserve-ak.last.fm/serve/34/317105.jpg</image>
40
+ <image size="medium">http://userserve-ak.last.fm/serve/64/317105.jpg</image>
41
+ <image size="large">http://userserve-ak.last.fm/serve/126/317105.jpg</image>
42
+ <image size="extralarge">http://userserve-ak.last.fm/serve/252/317105.jpg</image>
43
+ <image size="mega">http://userserve-ak.last.fm/serve/_/317105/The+Time.jpg</image>
44
+ </artist>
45
+ <artist>
46
+ <name>Sheila E.</name>
47
+ <url>http://www.last.fm/music/Sheila+E.</url>
48
+ <image size="small">http://userserve-ak.last.fm/serve/34/4593183.png</image>
49
+ <image size="medium">http://userserve-ak.last.fm/serve/64/4593183.png</image>
50
+ <image size="large">http://userserve-ak.last.fm/serve/126/4593183.png</image>
51
+ <image size="extralarge">http://userserve-ak.last.fm/serve/252/4593183.png</image>
52
+ <image size="mega">http://userserve-ak.last.fm/serve/_/4593183/Sheila+E+03.png</image>
53
+ </artist>
54
+ <artist>
55
+ <name>Wendy &amp; Lisa</name>
56
+ <url>http://www.last.fm/music/Wendy%2B%2526%2BLisa</url>
57
+ <image size="small">http://userserve-ak.last.fm/serve/34/20848697.jpg</image>
58
+ <image size="medium">http://userserve-ak.last.fm/serve/64/20848697.jpg</image>
59
+ <image size="large">http://userserve-ak.last.fm/serve/126/20848697.jpg</image>
60
+ <image size="extralarge">http://userserve-ak.last.fm/serve/252/20848697.jpg</image>
61
+ <image size="mega">http://userserve-ak.last.fm/serve/_/20848697/Wendy++Lisa+WL+last.jpg</image>
62
+ </artist>
63
+ </similar>
64
+ <tags>
65
+ <tag>
66
+ <name>funk</name>
67
+ <url>http://www.last.fm/tag/funk</url>
68
+ </tag>
69
+ <tag>
70
+ <name>pop</name>
71
+ <url>http://www.last.fm/tag/pop</url>
72
+ </tag>
73
+ <tag>
74
+ <name>80s</name>
75
+ <url>http://www.last.fm/tag/80s</url>
76
+ </tag>
77
+ <tag>
78
+ <name>soul</name>
79
+ <url>http://www.last.fm/tag/soul</url>
80
+ </tag>
81
+ <tag>
82
+ <name>rock</name>
83
+ <url>http://www.last.fm/tag/rock</url>
84
+ </tag>
85
+ </tags>
86
+ <bio>
87
+ <published>Thu, 29 Apr 2010 01:40:59 +0000</published>
88
+ <summary><![CDATA[Prince Rogers Nelson (born June 7, 1958), known from 1993 to 2000 as an unpronounceable symbol (or informally, The Artist Formerly Known as Prince, Tafkap, or simply The Artist), is a popular American musician. He had the most massive hit song of 1984 with &quot;When Doves Cry&quot; and is best known for his album and movie &quot;Purple Rain&quot;. As for the &quot;mega-superstars&quot; only Michael Jackson &amp; Madonna are similar to Prince in terms of star power.]]></summary>
89
+ <content><![CDATA[Prince Rogers Nelson (born June 7, 1958), known from 1993 to 2000 as an unpronounceable symbol (or informally, The Artist Formerly Known as Prince, Tafkap, or simply The Artist), is a popular American musician. He had the most massive hit song of 1984 with &quot;When Doves Cry&quot; and is best known for his album and movie &quot;Purple Rain&quot;.
90
+
91
+ As for the &quot;mega-superstars&quot; only Michael Jackson &amp; Madonna are similar to Prince in terms of star power. None could match the formidable breadth of his talents, which included not just singing and dancing but also composing, producing, and playing instruments (not to mention directing videos and movies). In fact, Prince played nearly all the instruments on his first five albums, and has produced himself since signing with Warner Bros. at age 21 (Rolling Stone).
92
+
93
+ His music has spanned myriad styles; from his early material, rooted in funk and soul, he has constantly expanded his musical palette throughout his career, absorbing many other genres including new wave, pop, rock, blues, jazz and hip hop. Born in Minneapolis, he has based his entire career in Minnesota. He now resides in Los Angeles.
94
+
95
+ The distinctive characteristics of the early-to-mid 1980s work that raised him to super-stardom - which includes industrial sounding drum machine arrangements, the use of synthesizer riffs to serve the role of horn riffs traditionally used in earlier R&amp;B, funk and soul music - became known as &quot;the Minneapolis sound&quot;. He has a reputation as a workaholic, having released over a thousand songs both under his own name and through other artists, and is known for having composed and recorded many more songs that remain unreleased. Regarded as a perfectionist, Prince has a reputation as being somewhat difficult to work with and for being highly protective of his music. He writes, composes and produces most of his music single-handedly. He also plays most of the instruments on his albums.
96
+
97
+ Few artists have created a body of work as rich and varied as Prince. His genius is critically agreed. During the 1980's he emerged as one of the singular talents of the ><a href="http://www.last.fm/tag/rock%20and%20roll" class="bbcode_tag" rel="tag">rock and roll</a> era, capable of seamlessly tying together <a href="http://www.last.fm/tag/pop" class="bbcode_tag" rel="tag">pop</a>, <a href="http://www.last.fm/tag/funk" class="bbcode_tag" rel="tag">funk</a> and <a href="http://www.last.fm/tag/rock" class="bbcode_tag" rel="tag">rock</a>. Not only did he release a series of ground-breaking albums, he toured frequently, produced albums and wrote songs for many other artists, and recorded hundreds of songs that still lie unreleased in his vaults. With each album he has released, Prince has shown remarkable stylistic growth and musical diversity, constantly experimenting with different sounds, textures, and genres. Occasionally, his music can be maddeningly inconsistent because of this eclecticism, but his experiments frequently succeed; no other contemporary artist can blend so many diverse styles into a cohesive whole.
98
+
99
+ Prince's first two albums were solid, if unremarkable, late-'<a href="http://www.last.fm/tag/70s" class="bbcode_tag" rel="tag">70s</a> <a href="http://www.last.fm/tag/funk-pop" class="bbcode_tag" rel="tag">funk-pop</a>. With 1980's <a title="Prince - Dirty Mind" href="http://www.last.fm/music/Prince/Dirty+Mind" class="bbcode_album">Dirty Mind</a>, he recorded his first masterpiece, a one-man tour-de-force of sex and music; it was hard funk, catchy <a href="http://www.last.fm/music/+noredirect/Beatles" class="bbcode_artist">Beatles</a>-esque melodies, sweet <a href="http://www.last.fm/tag/soul" class="bbcode_tag" rel="tag">soul</a> ballads, and rocking guitar pop, all at once. The follow-up, <a title="Prince - Controversy" href="http://www.last.fm/music/Prince/Controversy" class="bbcode_album">Controversy</a>, was more of the same, but <a title="Prince - 1999" href="http://www.last.fm/music/Prince/1999" class="bbcode_album">1999</a> was brilliant and helped break Prince into the mainstream pop charts. The video for the single &quot;Little Red Corvette&quot; was one of the first music videos by an African American to be played on MTV alongside Michael Jackson's &quot;Billie Jean&quot;. The album was a monster hit, selling over three million copies, but it was nothing compared to his 1984 masterpiece &quot;Purple Rain&quot;, which at it's glory was selling over 1 million copies per week in the USA alone and spun off several #1's and top ten hits, not to mention the #1 blockbuster hit movie of the same name. The Purple Rain album made another milestone: it had spent an astonishing 24 weeks at number one.
100
+
101
+ Purple Rain made Prince a mega-superstar and it delivered seamlessly. By 1996, it easily surpassed the esteemed RIAA Diamond Certification (10 million domestic units) by selling over 13.5 million in America. The classic continues to sell very well and it's estimated to pass the 17 million mark by 2010.
102
+
103
+ Partially recorded with his touring band the Revolution, the record featured the most pop-oriented music he has ever made. Instead of continuing in this accessible direction, he veered off into the bizarre psychedelia of <a title="Prince - Around the World in a Day" href="http://www.last.fm/music/Prince/Around+the+World+in+a+Day" class="bbcode_album">Around the World in a Day</a> (1985), which zoomed to #1 and nevertheless sold over three million copies. It contains the critically acclaimed pop hits &quot;Raspberry Beret&quot; and &quot;Pop Life&quot;, which were noted for their strong, sophisticated story-telling lyrics.
104
+
105
+ In 1986, he released the Parade, which in its own way was as ambitious and intricate as any <a href="http://www.last.fm/tag/art%20rock" class="bbcode_tag" rel="tag">art rock</a> of the '<a href="http://www.last.fm/tag/60s" class="bbcode_tag" rel="tag">60s</a>; however, no art rock was ever grounded with a super hit as brilliant as the spare funk of &quot;Kiss.&quot; Several entities such as Rolling Stone, Billboard and New Musical Express ranked the song near the top of their list of The Top 50 Greatest Singles of All Time. It rocketed to #1 (pushing out another huge chart topper he wrote for The Bangles, &quot;Manic Monday&quot;) and stayed perched there for several weeks. The hit album sold several million copies and was the soundtrack to his second movie, the universally panned &quot;Under The Cherry Moon&quot;.
106
+
107
+ By 1987, Prince's ambitions were growing by leaps and bounds, resulting in the sprawling masterpiece <a title="Prince - Sign O' The Times" href="http://www.last.fm/music/Prince/Sign+O%27+The+Times" class="bbcode_album">Sign O' The Times</a>. Prince was set to release the hard funk of The Black Album by the end of the year, yet he withdrew it just before its release, deciding it was too dark and immoral. Instead, he released the confused <a title="Prince - Lovesexy" href="http://www.last.fm/music/Prince/Lovesexy" class="bbcode_album">Lovesexy</a> in 1988, which was a commercial disaster, but remains a fan favo(u)rite. With the soundtrack to 1989's <a title="Prince - Batman" href="http://www.last.fm/music/Prince/Batman" class="bbcode_album">Batman</a> he returned to the top of the charts, even if the album was essentially a recap of everything he had done before. The following year he released <a title="Prince - Graffiti Bridge" href="http://www.last.fm/music/Prince/Graffiti+Bridge" class="bbcode_album">Graffiti Bridge</a>, the soundtrack for the movie sequel to Purple Rain, which turned out to be a considerable commercial disappointment.
108
+
109
+ In 1991, Prince formed <a href="http://www.last.fm/music/The+New+Power+Generation" class="bbcode_artist">The New Power Generation</a>, the most versatile he has ever assembled. With their first album, <a title="Prince - Diamonds and Pearls" href="http://www.last.fm/music/Prince/Diamonds+and+Pearls" class="bbcode_album">Diamonds and Pearls</a>, Prince reasserted his mastery of contemporary <a href="http://www.last.fm/tag/r%2526amp%253Bb" class="bbcode_tag" rel="tag">r&amp;amp;b</a>; it was his biggest hit since 1985, with the song <a title="Prince &ndash; Cream" href="http://www.last.fm/music/Prince/_/Cream" class="bbcode_track">Cream</a> becoming a worldwide smash. The following year, he released his 12th album, which was titled with a cryptic symbol; in 1993, Prince legally changed his name to the symbol. In 1994, after becoming embroiled in contract disagreements with Warner Bros., he independently released the single &quot;<a title="Prince &ndash; The Most Beautiful Girl in the World" href="http://www.last.fm/music/Prince/_/The+Most+Beautiful+Girl+in+the+World" class="bbcode_track">The Most Beautiful Girl in the World</a>,&quot; likely to illustrate what he would be capable of on his own; the song became his biggest hit in years. Later that summer, Warner released the somewhat halfhearted <a title="Prince - Come" href="http://www.last.fm/music/Prince/Come" class="bbcode_album">Come</a> under the name of Prince; the record was a moderate success, going gold.
110
+
111
+ In November 1994, as part of a contractual obligation, Prince agreed to the official release of <a title="Prince - The Black Album" href="http://www.last.fm/music/Prince/The+Black+Album" class="bbcode_album">The Black Album</a>. In early 1995, he immersed himself in another legal battle with Warner, appearing in public with the word &quot;slave&quot; on his cheek, and refusing to deliver his new record, <a title="Prince - The Gold Experience" href="http://www.last.fm/music/Prince/The+Gold+Experience" class="bbcode_album">The Gold Experience</a>, for release.
112
+
113
+ By the end of the summer, a fed-up Warner had negotiated a compromise which guaranteed the album's release, plus one final record for the label. <a title="Prince - The Gold Experience" href="http://www.last.fm/music/Prince/The+Gold+Experience" class="bbcode_album">The Gold Experience</a> was issued in the fall; although it received good reviews and was following a smash single, it failed to catch fire commercially. It remains a fan favo(u)rite, with most considering it his best work.
114
+
115
+ In the summer of 1996, Prince released <a title="Prince - Chaos &amp; Disorder" href="http://www.last.fm/music/Prince/Chaos%2B%2526%2BDisorder" class="bbcode_album">Chaos &amp; Disorder</a>, which freed him to become an independent artist. Setting up his own label, NPG (which was distributed by EMI), he resurfaced later that same year with the three-disc <a title="Prince - Emancipation" href="http://www.last.fm/music/Prince/Emancipation" class="bbcode_album">Emancipation</a>, which was designed as a magnum opus that would spin off singles for several years and be supported with several tours.
116
+
117
+ However, even his devoted following needed considerable time to digest such an enormous compilation of songs. Once it was clear that Emancipation wasn't the commercial blockbuster he hoped it would be, Prince assembled a long-awaited collection of outtakes and unreleased material called <a title="Prince - Crystal Ball" href="http://www.last.fm/music/Prince/Crystal+Ball" class="bbcode_album">Crystal Ball</a> in 1998. With Crystal Ball, Prince discovered that it's much more difficult to get records to an audience than it seems; some fans who pre-ordered their copies through Prince's website (from which a bonus fifth disc was included) didn't receive them until months after the set began appearing in stores. Prince then released a new one-man album, <a title="Prince - New power soul" href="http://www.last.fm/music/Prince/New+power+soul" class="bbcode_album">New power soul</a>, just three months after Crystal Ball; even though it was his most straightforward album since Diamonds and Pearls, it didn't do well on the charts, partly because many listeners didn't realize it had been released. Most fans consider it his worst album.
118
+
119
+ A year later, with &quot;<a title="Prince &ndash; 1999" href="http://www.last.fm/music/Prince/_/1999" class="bbcode_track">1999</a>&quot; predictably an end-of-the-millennium anthem, Prince issued the remix collection 1999 (<span title="Unknown album" class="bbcode_unknown">The New Master</span>). A collection of Warner Bros.-era leftovers, <a title="Prince - Vault: Old Friends 4 Sale" href="http://www.last.fm/music/Prince/Vault%3A+Old+Friends+4+Sale" class="bbcode_album">Vault: Old Friends 4 Sale</a>, followed that summer, and in the fall Prince returned on Arista with the all-star <a title="Prince - Rave Un2 the Joy Fantastic" href="http://www.last.fm/music/Prince/Rave+Un2+the+Joy+Fantastic" class="bbcode_album">Rave Un2 the Joy Fantastic</a>.
120
+
121
+ In the Fall of 2001 he released the controversial <a title="Prince - Rainbow Children" href="http://www.last.fm/music/Prince/Rainbow+Children" class="bbcode_album">Rainbow Children</a>, a <a href="http://www.last.fm/tag/jazz" class="bbcode_tag" rel="tag">jazz</a>-infused circus of sound trumpeting his conversion to the Jehovah's Witnesses that left many long time fans out in the cold. He further isolated himself with 2003's <a title="Prince - N.E.W.S." href="http://www.last.fm/music/Prince/N.E.W.S." class="bbcode_album">N.E.W.S.</a>, a four-song set of instrumental jams that sounded a lot more fun to play than to listen to.
122
+
123
+ Prince re-bounded in 2003 with the chart-topping <a title="Prince - Musicology" href="http://www.last.fm/music/Prince/Musicology" class="bbcode_album">Musicology</a>, a return to form that found the artist back in the top ten. In 2004, Prince was inducted into the Rock and Roll Hall of Fame and performed at the Grammy Awards with Beyonce Knowles.
124
+
125
+ On December 9, 2005, it was reported that Prince had determined an agreement with Universal Records to release his next album, <a title="Prince - 3121" href="http://www.last.fm/music/Prince/3121" class="bbcode_album">3121</a>. This deal is believed to be similar to that which the artist struck with Columbia Records for Musicology. The debut single put forward from the album was the Latin-tinged “<a title="Prince &ndash; Te Amo Corazon" href="http://www.last.fm/music/Prince/_/Te+Amo+Corazon" class="bbcode_track">Te Amo Corazon</a>,” the video for which debuted on VH1 on December 13, and was directed by actress Salma Hayek. The piece was filmed in Marrakesh, and showed Prince accompanied on-screen by Mía Maestro. She was also present at a brief press conference which Prince made in promotion of the new single and video. The video for “<a title="Prince &ndash; Black Sweat" href="http://www.last.fm/music/Prince/_/Black+Sweat" class="bbcode_track">Black Sweat</a>,” the second single from 3121, premiered on February 2, 2006, demonstating a rather more minimalistic approach both in the sound of the song and the style of the video. Prince is also believed to have a concert tour in the works to promote the new album.
126
+
127
+ On February 4, 2006, Prince was the musical guest on Saturday Night Live after a 25 year gap between appearances, where he performed two new songs, the guitar-driven “<a title="Prince &ndash; Fury" href="http://www.last.fm/music/Prince/_/Fury" class="bbcode_track">Fury</a>” and “<a title="Prince &ndash; Beautiful, Loved &amp; Blessed" href="http://www.last.fm/music/Prince/_/Beautiful%252C%2BLoved%2B%2526%2BBlessed" class="bbcode_track">Beautiful, Loved &amp; Blessed</a>,” with up-and-coming R&amp;B singer <a href="http://www.last.fm/music/T%C3%A1mar" class="bbcode_artist">T&aacute;mar</a>. Both are featured on Prince’s own 3121, with “Beautiful, Loved &amp; Blessed” also appearing on Tamar’s album, titled Beautiful Loved &amp; Blessed.
128
+
129
+ On February 15, 2006, Prince performed at the Brit awards alongside <a href="http://www.last.fm/music/Wendy" class="bbcode_artist">Wendy</a>, <a href="http://www.last.fm/music/Lisa" class="bbcode_artist">Lisa</a> and <a href="http://www.last.fm/music/+noredirect/Sheila+E" class="bbcode_artist">Sheila E</a>. He played “Te Amo Corazon” and “Fury” from 3121, “<a title="Prince &ndash; Purple Rain" href="http://www.last.fm/music/Prince/_/Purple+Rain" class="bbcode_track">Purple Rain</a>” and “<a title="Prince &ndash; Let's Go Crazy" href="http://www.last.fm/music/Prince/_/Let%27s+Go+Crazy" class="bbcode_track">Let's Go Crazy</a>” from Purple Rain, in a performance which was generally regarded as the best of the night.
130
+
131
+ Ultimate is the title of Prince’s latest greatest hits compilation album. Originally slated to be released in North America on 14 March 2006, the album was cancelled just days prior to its release. However, copies were already available in some retailers and have been sold.
132
+
133
+ The double disc set is slated to consist of one CD of hits, while the second disc will contain extended versions and mixes that, for the most part were previously unavailable on CD. Artwork for a promo copy [20] revealed that the selection included these tracks: “Let's Go Crazy (Special Dance Mix),” “Little Red Corvette (Dance Remix),” “Let’s Work (Dance Remix),” “Pop Life (Fresh Dance Mix),” “She's Always In My Hair (12&quot; Version),” “Raspberry Beret (12&quot; Version),” “Kiss (Extended Version),” “U Got The Look (Long Look),” “Hot Thing (Extended Remix),” “Thieves In The Temple (Remix),” and “Cream (N.P.G. Mix).”
134
+
135
+ 3121 was leaked to the internet on March 6, 2006. Prince achieved his first career number-one debut on the Billboard 200 (in the issue dated April 8, 2006) with 3121. The set sold 183,000 copies in the United States in its first week, according to Nielsen SoundScan. It also debuted at number one on Billboard’s Top R&amp;B/Hip-Hop Albums tally. 3121 also took over the number one spot on Billboard's European Top 100 Albums chart the following week, giving the legendary artist his highest charting international album of the decade.
136
+
137
+ On May 24, 2006, Prince performed “Lolita” and “Satisfied” from his album 3121 on the last results show of the fifth season of American Idol. He was the only artist to perform without any contestant in the episode. The infamous judge on the show, Simon Cowell, has recently turned his barbed comments toward the artist saying, “It just tells you how selfish he is. He comes on, not a word—‘I’m not gonna sing with anybody else, I’m not gonna say goodbye.’ Thank you for your generosity, Prince.” in regard to Prince’s late arrival and abrupt departure.
138
+
139
+ On June 12, 2006, Prince was hono(u)red with a Webby Lifetime Achievement Award in recognition of his &quot;visionary&quot; use of the Internet that included becoming the first major artist to release an entire album—1997's &quot;Crystal Ball&quot;—exclusively on the Web. &quot;Everything you think is true,&quot; Prince said, coming in under the five-word limit and leaving everyone wondering what he meant as he launched into a solo number. The performance ended abruptly as he suddenly chucked his guitar back over his head with a crash and raced off to a waiting limousine.
140
+
141
+ On June 27, 2006, Prince appeared at the BET awards. He was awarded Best Male R&amp;B artist. In his acceptance speech he told the crowd that he was surprised but honored to receive the award. He also thanked Jehovah, <a href="http://www.last.fm/music/Chaka+Khan" class="bbcode_artist">Chaka Khan</a>, <a href="http://www.last.fm/music/Stevie+Wonder" class="bbcode_artist">Stevie Wonder</a>, <a href="http://www.last.fm/music/India.Arie" class="bbcode_artist">India.Arie</a>, and Yolanda Adams. Later in the evening Prince participated in a tribute to Chaka Khan with the other artists he had named in his speech. The tribute was part of Chaka Khan's lifetime acheievement award given to her that evening. Prince also closed the show, alongside Támar, with his song &quot;3121&quot; from his album of the same name. He was joined onstage by musician <a href="http://www.last.fm/music/will.i.am" class="bbcode_artist">will.i.am</a> from <a href="http://www.last.fm/music/+noredirect/The+Black+Eyed+Peas" class="bbcode_artist">The Black Eyed Peas</a>.
142
+
143
+ On June 28, 2007, the UK national newspaper 'The Mail On Sunday' revealed that it had made a deal to give Prince's new album <a title="Prince - Planet Earth" href="http://www.last.fm/music/Prince/Planet+Earth" class="bbcode_album">Planet Earth</a> away for free with an &quot;imminent&quot; edition of the paper, making it the first place in the world to get the album. The date chosen was July 15, 2007. This move has sparked controversy among music distributors and has also led the UK arm of Prince's distributor, Sony BMG, to withdraw from distributing the album in UK stores. The UK's largest high street music retailer, HMV, decided to stock the paper on release day due to the giveaway.
144
+
145
+ Last year in the summer, he played 21 nights over 2 months in London's o2 Arena including many aftershow parties where he would play for up to 3 hours. He recently released a book called &quot;21 Nights&quot; which featured professional photos of the concerts, photoshoots and poems written by Prince himself.
146
+
147
+ In the spring of 2009 Prince released two albums: <a title="Prince - LotusFlow3r" href="http://www.last.fm/music/Prince/LotusFlow3r" class="bbcode_album">LotusFlow3r</a> and <a title="Prince - MPLSOUND" href="http://www.last.fm/music/Prince/MPLSOUND" class="bbcode_album">MPLSOUND</a>.]]></content>
148
+ </bio>
149
+ </artist></lfm>
@@ -0,0 +1,2 @@
1
+ <lfm status="failed">
2
+ <error code="10">Invalid API key - You must be granted a valid key by last.fm</error></lfm>
data/test/helper.rb CHANGED
@@ -1,9 +1,24 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
+ require 'fakeweb'
3
4
 
4
5
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
6
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
7
  require 'glutton_lastfm'
7
8
 
9
+ FakeWeb.allow_net_connect = false
10
+
8
11
  class Test::Unit::TestCase
9
12
  end
13
+
14
+ def fixture_file(filename)
15
+ return "" if filename == ""
16
+ file_path = File.expand_path(File.dirname(__FILE__) + "/fixtures/" + filename)
17
+ File.read(file_path)
18
+ end
19
+
20
+ def stub_get(url, filename, status=nil)
21
+ options = { :body => fixture_file(filename) }
22
+ options.merge!({ :status => status }) unless status.nil?
23
+ FakeWeb.register_uri(:get, url, options)
24
+ end
@@ -1,7 +1,39 @@
1
1
  require 'helper'
2
2
 
3
+ # I'm currently only testing two methods and one exception.
4
+ # HTTP calls are replaced by fixture file responses using the fakeweb gem.
5
+
3
6
  class TestGluttonLastfm < Test::Unit::TestCase
4
- def test_something_for_real
5
- flunk "Nothing to see here. Wally hasn't added any tests yet."
7
+ LASTFM_API_KEY = '<your last.fm API key>'
8
+
9
+ def setup
10
+ @lastfm = GluttonLastfm.new LASTFM_API_KEY
11
+ end
12
+
13
+ def test_api_key_is_set
14
+ assert_not_equal(LASTFM_API_KEY, '<your last.fm API key>')
15
+ end
16
+
17
+ def test_object_creations
18
+ assert_equal(@lastfm.class, GluttonLastfm)
19
+ end
20
+
21
+ def test_artist_info_by_name
22
+ stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.getinfo&artist=Prince", 'artist_info_prince.xml')
23
+ prince_artist_info = @lastfm.artist_info('Prince')
24
+ assert_equal(prince_artist_info['mbid'],'070d193a-845c-479f-980e-bef15710653e')
25
+ end
26
+
27
+ def test_artist_info_by_mbid
28
+ mbid = '070d193a-845c-479f-980e-bef15710653e'
29
+ stub_get("http://ws.audioscrobbler.com/2.0?api_key=#{LASTFM_API_KEY}&method=artist.getinfo&mbid=#{mbid}", 'artist_info_prince.xml')
30
+ prince_artist_info = @lastfm.artist_info_by_mbid(mbid)
31
+ assert_equal(prince_artist_info['name'],'Prince')
32
+ end
33
+
34
+ def test_unauthorized_exception
35
+ lastfm_bad_key = GluttonLastfm.new 'invalid_key'
36
+ stub_get("http://ws.audioscrobbler.com/2.0?api_key=invalid_key&method=artist.getinfo&artist=Prince", 'invalid_api_key.xml', 403)
37
+ assert_raise(GluttonLastfm::Unauthorized) { lastfm_bad_key.artist_info('Prince') }
6
38
  end
7
39
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Wally Glutton
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-09 00:00:00 -05:00
17
+ date: 2010-05-10 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -31,6 +31,20 @@ dependencies:
31
31
  version: 0.5.0
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: fakeweb
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 2
44
+ - 8
45
+ version: 1.2.8
46
+ type: :development
47
+ version_requirements: *id002
34
48
  description: Simple last.fm API wrapper written using HTTParty in Ruby.
35
49
  email: stungeye@gmail.com
36
50
  executables: []
@@ -47,8 +61,12 @@ files:
47
61
  - README.rdoc
48
62
  - Rakefile
49
63
  - VERSION
64
+ - examples/all_methods.rb
65
+ - examples/artist_tags_and_images.rb
50
66
  - glutton_lastfm.gemspec
51
67
  - lib/glutton_lastfm.rb
68
+ - test/fixtures/artist_info_prince.xml
69
+ - test/fixtures/invalid_api_key.xml
52
70
  - test/helper.rb
53
71
  - test/test_glutton_lastfm.rb
54
72
  has_rdoc: true
@@ -84,3 +102,5 @@ summary: Ruby last.fm API wrapper.
84
102
  test_files:
85
103
  - test/helper.rb
86
104
  - test/test_glutton_lastfm.rb
105
+ - examples/artist_tags_and_images.rb
106
+ - examples/all_methods.rb