Skip to content

Instantly share code, notes, and snippets.

@itszero
Created June 27, 2012 07:23
Show Gist options
  • Save itszero/3002213 to your computer and use it in GitHub Desktop.
Save itszero/3002213 to your computer and use it in GitHub Desktop.
iTunes TW Feed List
#!/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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment