Created
June 27, 2012 07:23
Revisions
-
itszero created this gist
Jun 27, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ #!/bin/sh wget -O xml/top_albums.xml http://itunes.apple.com/tw/rss/topalbums/limit=300/explicit=true/xml wget -O xml/new_releases.xml http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/newreleases/sf=143470/limit=300/rss.xml wget -O xml/just_added.xml http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/justadded/sf=143470/limit=300/rss.xml wget -O xml/featured_albums.xml http://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/featuredalbums/sf=143470/limit=300/rss.xml This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ require 'bundler' require 'nokogiri' require 'uri' def parse_itms_feed(feed) d = Nokogiri(feed) d.css('feed entry').map { |entry| { :name => entry.css('name').text, :artist => entry.css('artist').text, :image => entry.css('image').max { |o| o['height'].to_i }.text, :price => entry.css('price').first['amount'].to_i, :id => entry.css('id').first['im:id'], :link => entry.css('link').first['href'] } } end def parse_phobes_feed(feed) d = Nokogiri(feed) d.css('item').map { |entry| { :name => entry.css('itms|album').text, :artist => entry.css('itms|artist').text, :image => entry.css('itms|coverArt').max { |o| o['height'].to_i }.text, :price => entry.css('itms|albumPrice').text.gsub(/NT\$/,'').to_i, :id => File.basename(URI.parse(entry.css('link').text)).gsub(/id/,''), :link => entry.css('link').text } } end