Module: RMAL
- Defined in:
- lib/rMAL.rb,
lib/rMAL/version.rb
Defined Under Namespace
Modules: Settings
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
-
.login ⇒ Object
Verify Credentials.
-
.search(type = "anime", query) ⇒ Object
Search anime/manga.
Class Method Details
.login ⇒ Object
Verify Credentials
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rMAL.rb', line 45 def self.login RMAL::Settings.load($path) # Curl into MAL with the request IO.popen("curl -u #{$w_username}:#{$w_password} http://myanimelist.net/api/account/verify_credentials.xml -A #{$w_apikey}") { |f| $login_response = f.read } # Parse out the user id login_id = Ox.parse($login_response).user.id.text # Parse out the username login_username = Ox.parse($login_response).user.username.text # Display both bits of info puts "Login ID: " + login_id, "Login Username: " + login_username # Return both bits of info return login_id, login_username end |
.search(type = "anime", query) ⇒ Object
Search anime/manga
59 60 61 62 63 64 65 66 |
# File 'lib/rMAL.rb', line 59 def self.search(type = "anime", query) RMAL::Settings.load($path) # Replace spaces with '+'s query = query.gsub(/\s/, "+") # Curl into MAL with the request IO.popen("curl -u #{$w_username}:#{$w_password} http://myanimelist.net/api/#{type}/search.xml?q=#{query} -A #{$w_apikey}") { |f| $search_response = f.read } p $search_response # temporary end |