Coder Social home page Coder Social logo

ruby-lastfm's People

Contributors

benuuu avatar bfontaine avatar causal-agent avatar ckdake avatar dbolson avatar erickreutz avatar freemanoid avatar hrefhref avatar jjgh avatar jmahoney avatar johanoskarsson avatar lfzawacki avatar mask8 avatar masterkain avatar mattfawcett avatar mikepack avatar mllocs avatar morion4000 avatar paulmillr avatar petrinecp avatar pipedreambomb avatar polomasta avatar rahilsondhi avatar rootpd avatar ryland avatar sebweaver avatar toy avatar volontarian avatar youpy avatar zkdrift avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-lastfm's Issues

REXML::ParseException

When calling get_recent_tracks for my last.fm data, some nasty data from Last.fm causes the gem to blow up with:

REXML::ParseException: #<RuntimeError: Illegal character "\uFFFE" in raw string "�䬀愀瀀 匀氀愀瀀">

This probably should get eaten by the gem because as it is, the only way I could effectively catch this is to loop through get_recent_tracks once per song which is a Bad Thing.

track#get_tags requires authentication

Lastfm::MethodCategory::Track#get_tags uses method_with_authentication, but the getTags end point on Last.fm doesn't require authentication, which is causing some confusion. I'll try and submit a pull request to adjust this.

Nice gem by the way, very elegant.

getSession - Invalid method signature supplied

I have a problem when I try to set the session attribute.

@lastfm.session = @lastfm.auth.get_session(token: @token)['api_key']

I don't know exactly what to put inside [ ]. I've tried api_key, but I get the following error

 Invalid method signature supplied 

How can I solve this?

Thanks

getGeo.events and artist.getEvents not working, but maybe because LastFM API changed or broken?

Examples

lastfm = Lastfm.new(ENV['LAST_FM_KEY'],ENV['LAST_FM_SECRET'])

lastfm.geo.get_events(location: "New York")
>Lastfm::ApiError: Invalid Method - No method with that name in this package

lastfm.artist.get_events(artist: "Morrissey")
>Lastfm::ApiError: Invalid Method - No method with that name in this package

Relevant links as to API status

https://plus.google.com/+TimothyMalseed/posts/Sn6qcQuPDrX

Their status doesn't reflect deletion or changes in these methods.
http://status.last.fm/

Anyone else having these problems? Or know what the issue is? I reached out to LastFM but haven't heard back yet.

Mandatory and optional parameters

The problem comes when the required params are dependent, such as:

album.getInfo:

  • artist (Required (unless mbid) : The artist name
  • album (Required (unless mbid) : The album name
  • mbid (Optional) : The musicbrainz id for the album
  • ...

Here you can provide whether mbid or both artist and album.

The gem only implements the artist and album case, not if you provide only the mbid.

The way regular_method is implemented doesn't allow an easy way to solve these cases (or at least I don't see it :( )

def regular_method(id, mandatory, optional = [], &block)
  __define_method(:request, id, mandatory, optional, &block)
end

Any idea of how we could handle the mbid case? It's not only a problem of this method (album.getInfo) but also in many other...

Cannot install lastfm gem

When trying to install lastfm gem i get this error message.

ERROR: Error installing lastfm:
lastfm requires lastfm (>= 0)

OSX Lion
ruby 1.9.3p125

ArgumentError: File does not exist: .

Hello,
I upgraded to 1.8.0 and I'm getting this exception on now_playing:

xml-simple (1.1.1) lib/xmlsimple.rb:990:in `find_xml_file'
xml-simple (1.1.1) lib/xmlsimple.rb:168:in `xml_in'
xml-simple (1.1.1) lib/xmlsimple.rb:203:in `xml_in'
lastfm (1.8.0) lib/lastfm/response.rb:9:in `initialize'
lastfm (1.8.0) lib/lastfm.rb:94:in `new'
lastfm (1.8.0) lib/lastfm.rb:94:in `request'
lastfm (1.8.0) lib/lastfm/method_category/base.rb:54:in `request'
lastfm (1.8.0) lib/lastfm/method_category/base.rb:39:in `write_request'
lastfm (1.8.0) lib/lastfm/method_category/base.rb:29:in `block in __define_method'
client.track.update_now_playing(artist, title, album, position)
# or
client.track.update_now_playing(artist: artist, track: title, album: album, trackNumber: position)

Is the Last.fm service being funky?

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec
via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

There is even a License Finder to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec.
Including a license in your gemspec is a good practice, in any case.

How did I find you?

I'm using a script to collect stats on gems, originally looking for download data, but decided to collect licenses too,
and make issues for missing ones as a public service :)
https://gist.github.com/bf4/5952053#file-license_issue-rb-L13 So far it's going pretty well

Question regarding using the gem for authenticating a web app.

I have the gem accepting a token and getting a session key for a given user. I'm storing this session key for later use in my User table. My question is, how do I sign my requests like, lastfm.track.scrobble and lastfm.track.update_now_playing, with this saved session key so I do not have get the user to give me a new token and retrieve a new session key every time.

cc: @youpy

Thanks!

*#search raises REXML::UndefinedNamespaceException

last.fm returns invalid XML, missing namespace declaration.

<?xml version="1.0" encoding="UTF-8" ?>
  <lfm status="ok">
    <results for="Believe">
      <opensearch:Query role="request" searchTerms="Believe" startPage="1"></opensearch:Query>
...

valid XML is:

<?xml version="1.0" encoding="UTF-8" ?>
  <lfm status="ok">
    <results for="Believe" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
      <opensearch:Query role="request" searchTerms="Believe" startPage="1"></opensearch:Query>
...

XML inconsistency

I noticed that the Last.fm API's endpoints in the Tag group don't return the same XML as written in their documentation.As an example of the problem, here are screenshots of the data, that is actually returned by their API and data written in official documentation.
2017-12-20 00 08 58
2017-12-20 00 09 11

Rakefile depends on old version of rspec

I'd like to contribute, but the Rakefile seems to depend on rspec 1.3. As I have 2.1.0 installed I can't install the library. I've attempted a few different fixes, but my rake foo isn't good enough. Any chance you could upgrade the Rakefile to support 2.1.0?

user.get_loved_tracks does not always return an array

It is possible to get three different return types from user.get_loved_tracks:

  • When a user has more than one loved track it returns an array.
  • When a user has only one loved track it returns a hash.
  • When a user has not got any loved tracks it returns nil.

This leads to ugly code. For example if one wants to use each on the result from user.get_loved_tracks one has to check before whether it is nil or a hash. This is similar to #46.

Rexml parsing escaping problem

Problem with artist.
I thinks this placeformed=>"Montreal & Ottawa, Canada" don't escaped

lastfm.artist.get_info(artist: "Obey The Brave")
/Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/parsers/treeparser.rb:95:in `rescue in parse': #<RuntimeError: Illegal character '&' in raw string "Montreal & Ottawa, Canada"> (REXML::ParseException)
/Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/text.rb:155:in `block in check'
/Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/text.rb:153:in `scan'
/Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/text.rb:153:in `check'
/Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/text.rb:120:in `initialize'
/Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/parsers/treeparser.rb:46:in `new'
/Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/parsers/treeparser.rb:46:in `parse'
/Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/document.rb:283:in `build'
/Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/document.rb:43:in `initialize'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/xml-simple-1.1.2/lib/xmlsimple.rb:965:in `new'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/xml-simple-1.1.2/lib/xmlsimple.rb:965:in `parse'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/xml-simple-1.1.2/lib/xmlsimple.rb:164:in `xml_in'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/xml-simple-1.1.2/lib/xmlsimple.rb:203:in `xml_in'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm/response.rb:11:in `rescue in initialize'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm/response.rb:9:in `initialize'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm.rb:114:in `new'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm.rb:114:in `request'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm/method_category/base.rb:84:in `request'
/Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm/method_category/base.rb:46:in `block in __define_method'
lastfm.rb:11:in `<main>'
...
Illegal character '&' in raw string "Montreal & Ottawa, Canada"
Line: 112
Position: 6708
Last 80 unconsumed characters:
</placeformed>
    from /Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/parsers/treeparser.rb:20:in `parse'
    from /Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/document.rb:283:in `build'
    from /Users/onemanstartup/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/rexml/document.rb:43:in `initialize'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/xml-simple-1.1.2/lib/xmlsimple.rb:965:in `new'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/xml-simple-1.1.2/lib/xmlsimple.rb:965:in `parse'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/xml-simple-1.1.2/lib/xmlsimple.rb:164:in `xml_in'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/xml-simple-1.1.2/lib/xmlsimple.rb:203:in `xml_in'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm/response.rb:11:in `rescue in initialize'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm/response.rb:9:in `initialize'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm.rb:114:in `new'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm.rb:114:in `request'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm/method_category/base.rb:84:in `request'
    from /Users/onemanstartup/.rvm/gems/ruby-2.0.0-p195/gems/lastfm-1.19.0/lib/lastfm/method_category/base.rb:46:in `block in __define_method'
    from lastfm.rb:11:in `<main>'

There's no way to know last.fm username after calling auth.getSession

It returns session key only, api has no methods that would return user's name by its session key.
To get name it is needed to modify existing method auth.getSession to return not only session key, but entire session info. But this likely would cause problems to existing gem users.

Version upgrade

Hi Youpy,

Thank you for having pulled my recent upgrade! When do you plan to release it on rubygems? Indeed, the gem I'm developing now requires yours and I'd like to release it soon with the right dependency. No pressure, of course. ;-)

Thanks in advance.

Bye

NoMethodError: undefined method `lstrip!' for {}:Hash on album.getinfo

Please have a look at this:

Lastfm.new(yourkey, yoursecret).album.get_info('Vemoth', 'The Upcoming End')

NoMethodError: undefined method `lstrip!' for {}:Hash
  from /Users/kain/.rvm/gems/ruby-1.9.3-p125/bundler/gems/ruby-lastfm-33f2415100e3/lib/lastfm/method_category/album.rb:6:in `block in <class:Album>'
  from /Users/kain/.rvm/gems/ruby-1.9.3-p125/bundler/gems/ruby-lastfm-33f2415100e3/lib/lastfm/method_category/base.rb:29:in `call'
  from /Users/kain/.rvm/gems/ruby-1.9.3-p125/bundler/gems/ruby-lastfm-33f2415100e3/lib/lastfm/method_category/base.rb:29:in `block in __define_method'
  from (irb):2
  from /Users/kain/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
  from /Users/kain/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
  from /Users/kain/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.3/lib/rails/commands.rb:41:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'

This happens because the releasedate is {}:

lastfm.request('album.getInfo', { artist: 'Vemoth', album: 'The Upcoming End'})

 => #<Lastfm::Response:0x007fd5d1862460 @xml={"status"=>"ok", "album"=>{"name"=>"The Upcoming End", "artist"=>"Vemoth", "id"=>"75620491", "mbid"=>{}, "url"=>"http://www.last.fm/music/Vemoth/The+Upcoming+End", "releasedate"=>{}, "image"=>[{"size"=>"small", "content"=>"http://userserve-ak.last.fm/serve/34s/35151317.jpg"}, {"size"=>"medium", "content"=>"http://userserve-ak.last.fm/serve/64s/35151317.jpg"}, {"size"=>"large", "content"=>"http://userserve-ak.last.fm/serve/174s/35151317.jpg"}, {"size"=>"extralarge", "content"=>"http://userserve-ak.last.fm/serve/300x300/35151317.jpg"}, {"size"=>"mega", "content"=>"http://userserve-ak.last.fm/serve/_/35151317/The+Upcoming+End.jpg"}], "listeners"=>"242", "playcount"=>"4003", "tracks"=>{}, "toptags"=>{}}}> 

.

This is an issue to recover rubygems.org account

Optional user parameter in user#get_info

First of thanks for a awesome gem!

According to the official Last.fm API docs the user.getInfo method doesn't require a user parameter being passed along the call. If it's omitted it will default to the authenticated user. Therefor it would be great if the method would mimic this behaviour aswell.

The optional parameter artist of track.search makes no difference

According to #30 you should be able to use the optional artist parameter of track.search. However, when I try it it makes no difference. For example

p lastfm.track.search(artist: 'Spacemen 3', track: 'Revolution')['results']['trackmatches']['track'].length

gives the same result as

p lastfm.track.search(track: 'Revolution')['results']['trackmatches']['track'].length

track.getCorrection returns exceptions or nil

69946f0

Lastfm.new(Settings.services.lastfm.api_key, Settings.services.lastfm.secret).track.get_correction('White Stripes', 'One More Cup of Coffee', 'wainekerr')

This uses the same data as in the spec, however it returns nil for me.

If instead we use a mispelt artist or track title, it raises:

Lastfm::ApiError: Supplied artist does not exist
  from /Users/kain/.rvm/gems/ruby-1.9.3-p125/bundler/gems/ruby-lastfm-2242de096b1e/lib/lastfm.rb:96:in `request'
  from /Users/kain/.rvm/gems/ruby-1.9.3-p125/bundler/gems/ruby-lastfm-2242de096b1e/lib/lastfm/method_category/base.rb:54:in `request'
  from /Users/kain/.rvm/gems/ruby-1.9.3-p125/bundler/gems/ruby-lastfm-2242de096b1e/lib/lastfm/method_category/base.rb:29:in `block in __define_method'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.