Permalink
Browse files

Fixes for changes to the wikidata API - keys are now qnnnn

  • Loading branch information...
1 parent c3e32b6 commit 742997d0f8027b69d575251d3fccae63d9a98643 @njh committed Dec 22, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/wikidata_api.rb
View
@@ -14,14 +14,15 @@ def self.get_sitelink(id, site='enwiki')
:languages => 'en'
})
+ key = id.downcase
if data['entities'].nil?
- raise MediaWiki::Exception.new('Empty response')
- elsif data['entities'][id].nil?
- raise MediaWiki::NotFound.new('Wikidata identifier does not exist')
- elsif data['entities'][id]['sitelinks'][site].nil?
- raise MediaWiki::NotFound.new('Sitelink does not exist for Wikidata identifier')
+ raise MediaWikiApi::Exception.new('Empty response')
+ elsif data['entities'][key].nil?
+ raise MediaWikiApi::NotFound.new('Wikidata identifier does not exist')
+ elsif data['entities'][key]['sitelinks'][site].nil?
+ raise MediaWikiApi::NotFound.new('Sitelink does not exist for Wikidata identifier')
else
- return data['entities'][id]['sitelinks'][site]
+ return data['entities'][key]['sitelinks'][site]
end
end

0 comments on commit 742997d

Please sign in to comment.