Module: Imasquerade
- Defined in:
- lib/imasquerade/version.rb,
lib/imasquerade/extractor.rb
Constant Summary collapse
- VERSION =
"0.3.0"
Class Method Summary collapse
Class Method Details
.parse_itunes_uri(uri) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/imasquerade/extractor.rb', line 4 def self.parse_itunes_uri(uri) # Extract the iTunes id from the URI id = uri.match(@itunes_id_regex)[:id] # Get raw JSON search response = HTTParty.get('https://itunes.apple.com/lookup', {query: {id: id}}) # Parse the JSON to a Hash hash = MultiJson.load(response.body, symbolize_keys: true) # Extract the first feed URL hash[:results].first[:feedUrl] if hash.has_key?(:results) && hash[:resultCount] > 0 end |