pitchfork best new music filestube mashup


/ Published in: ColdFusion
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <cfset apiKey="yourApiKeyHere">
  2. <!--- Grab the feed --->
  3. <cfset pitchforkFeed = XmlParse("http://feeds.feedburner.com/PitchforkBestNewAlbums?format=xml")>
  4. <!--- Pull the titles --->
  5. <cfset titles = XmlSearch(pitchforkFeed, "/rss/channel/item/title/")>
  6. <!--- The titles need to be scrubbed so they actually work as arguments to the FilesTube API --->
  7. <cfset numItems = ArrayLen(titles)>
  8. <cfloop index="i" from="1" to=#numItems#>
  9. <cfset artistAlbum = #titles[i].xmlText#>
  10. <cfset noSpaceName = REREplace(artistAlbum, "&[##\d]+;", "", "ALL")>
  11. <cfset noSpaceName = REREplace(noSpaceName, "(\s)+", " ", "ALL")>
  12. <cfset noSpaceName = REREplace(noSpaceName, " ?- ?", " ", "ALL")>
  13. <cfset noSpaceName = URLEncodedFormat(noSpaceName, "utf-8")>
  14. <cfset filesTubeURL[i] = "http://api.filestube.com/?key=#apiKey#&phrase=#noSpaceName#">
  15. </cfloop>
  16. <!--- This is where we grab shit from the FT API --->
  17. <cfset urlLength = ArrayLen(filesTubeURL)>
  18. <cfloop index="j" from="1" to=#urlLength#>
  19. <cfhttp method="Get" url="#filesTubeURL[j]#">
  20. <!--- I should save these as a file so that processing isn't ridiculous --->
  21. <cfset filesTubeFeed = XmlParse("#cfhttp.FileContent#")>
  22. <cfset links = XmlSearch(filesTubeFeed, "/answer/results/hits/")>
  23. <cfset linkLength = ArrayLen(links)>
  24. <cfoutput>
  25. <!--- Start outputing the urls --->
  26. <p>#titles[j].xmlText#</p>
  27. <ul>
  28. <cfloop index="k" from ="1" to="#linkLength#">
  29. <li>
  30. <p>
  31. #links[k].name.xmlText#&mdash;
  32. #links[k].size.xmlText# <br />
  33. <a href=#links[k].address.xmlText#>#links[k].address.xmlText#</a>
  34. </p>
  35. </li>
  36. </cfloop>
  37. </ul>
  38. </cfoutput>
  39. </cfloop>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.