Created
June 17, 2012 19:34
-
-
Save kellyrob99/2945511 to your computer and use it in GitHub Desktop.
Reads RSS feeds from Adobe kuler site and extracts the hexadecimal representation of each five element theme, writing those values to a file.
This file contains 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 characters
/** | |
* Reads RSS feeds from kuler and extracts the hexadecimal representation of each five element theme, writing those | |
* values to a file. | |
*/ | |
def feeds = [ | |
new URL("http://kuler-api.adobe.com/feeds/rss/get.cfm?itemsPerPage=100&listType=rating"), | |
new URL("http://kuler-api.adobe.com/feeds/rss/get.cfm?itemsPerPage=100&listType=popular") | |
] | |
def mappedThemes = [:] | |
def slurp = {rssXML, themes -> | |
def xml = new XmlSlurper().parseText(rssXML) | |
xml.channel.item.each { theme -> | |
println theme.title | |
def desc = theme.description.toString().split('\n') | |
def hex = desc[-1] | |
hex = hex.replaceAll('\t', '') | |
hex = hex.replaceAll(' ', '') | |
themes.put(theme.title.toString().replaceAll('Theme Title:', '').trim().replaceAll(' ', '_').replaceAll('\'', | |
'_').toLowerCase(), hex.split(',')) | |
} | |
} | |
feeds.each { URL url -> | |
slurp(url.text, mappedThemes) | |
} | |
println mappedThemes.keySet().size() | |
def themeMapFile = new File("kulerThemeMap-${new Date().format('yyMMddHHmmss')}.groovy") | |
themeMapFile << "themeMap = ${mappedThemes.inspect()}" | |
themeMapFile.absolutePath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment