Return to Snippet

Revision: 31274
at June 11, 2011 07:06 by landock


Updated Code
<cfset apiKey="yourApiKeyHere">
<!--- Grab the feed --->
<cfset pitchforkFeed = XmlParse("http://feeds.feedburner.com/PitchforkBestNewAlbums?format=xml")>
<!--- Pull the titles --->
<cfset titles = XmlSearch(pitchforkFeed, "/rss/channel/item/title/")>
<!--- The titles need to be scrubbed so they actually work as arguments to the FilesTube API --->
<cfset numItems = ArrayLen(titles)>
<cfloop index="i" from="1" to=#numItems#>
	<cfset artistAlbum = #titles[i].xmlText#>
	<cfset noSpaceName = REREplace(artistAlbum, "&[##\d]+;", "", "ALL")>
	<cfset noSpaceName = REREplace(noSpaceName, "(\s)+", " ", "ALL")>
	<cfset noSpaceName = REREplace(noSpaceName, " ?- ?", " ", "ALL")>
	<cfset noSpaceName = URLEncodedFormat(noSpaceName, "utf-8")>	
	<cfset filesTubeURL[i] = "http://api.filestube.com/?key=#apiKey#&phrase=#noSpaceName#">
</cfloop>
<!--- This is where we grab shit from the FT API --->
<cfset urlLength = ArrayLen(filesTubeURL)>
<cfloop index="j" from="1" to=#urlLength#>
	<cfhttp method="Get" url="#filesTubeURL[j]#">
	<!--- I should save these as a file so that processing isn't ridiculous --->
	<cfset filesTubeFeed = XmlParse("#cfhttp.FileContent#")>	
	<cfset links = XmlSearch(filesTubeFeed, "/answer/results/hits/")>
	<cfset linkLength = ArrayLen(links)> 
        <cfoutput>
	    <!--- Start outputing the urls --->
	    <p>#titles[j].xmlText#</p>	
	    <ul>
	        <cfloop index="k" from ="1" to="#linkLength#">
		    <li>
                        <p>
		            #links[k].name.xmlText#&mdash;
		            #links[k].size.xmlText# <br />
		            <a href=#links[k].address.xmlText#>#links[k].address.xmlText#</a>
		        </p>
		   </li>
	        </cfloop>
	    </ul>
        </cfoutput>
</cfloop>

Revision: 31273
at September 2, 2010 05:23 by landock


Updated Code
<cfset apiKey="yourApiKeyHere">
<!--- Grab the feed --->
<cfset pitchforkFeed = XmlParse("http://feeds.feedburner.com/PitchforkBestNewAlbums?format=xml")>
<!--- Pull the titles --->
<cfset titles = XmlSearch(pitchforkFeed, "/rss/channel/item/title/")>
<!--- The titles need to be scrubbed so they actually work as arguments to the FilesTube API --->
<cfset numItems = ArrayLen(titles)>
<cfloop index="i" from="1" to=#numItems#>
	<cfset artistAlbum = #titles[i].xmlText#>
	<cfset noSpaceName = REREplace(artistAlbum, "&[##\d]+;", "", "ALL")>
	<cfset noSpaceName = REREplace(noSpaceName, "(\s)+", " ", "ALL")>
	<cfset noSpaceName = REREplace(noSpaceName, " ?- ?", " ", "ALL")>
	<cfset noSpaceName = URLEncodedFormat(noSpaceName, "utf-8")>	
	<cfset filesTubeURL[i] = "http://api.filestube.com/?key=#apiKey#&phrase=#noSpaceName#">
</cfloop>
<!--- This is where we grab shit from the FT API --->
<cfset urlLength = ArrayLen(filesTubeURL)>
<cfloop index="j" from="1" to=#urlLength#>
	<cfhttp method="Get" url="#filesTubeURL[j]#">
	<!--- I should save these as a file so that processing isn't ridiculous --->
	<cfset filesTubeFeed = XmlParse("#cfhttp.FileContent#")>	
	<cfset links = XmlSearch(filesTubeFeed, "/answer/results/hits/")>
	<cfset linkLength = ArrayLen(links)>
	<cfoutput>
	<!--- Start outputing the urls --->
	<p>#titles[j].xmlText#</p>	
	<ul>
	<cfloop index="k" from ="1" to="#linkLength#">
		<li><p>
			#links[k].name.xmlText#&mdash;
			#links[k].size.xmlText# <br />
			<a href=#links[k].address.xmlText#>#links[k].address.xmlText#</a>
			</p>
		</li>
	</cfloop>
	</ul>
	</cfoutput>
</cfloop>

Revision: 31272
at September 2, 2010 05:15 by landock


Updated Code
<cfset apiKey="yourApiKeyHere">
<!--- Grab the feed --->
<cfset pitchforkFeed = XmlParse("http://feeds.feedburner.com/PitchforkBestNewAlbums?format=xml")>
<!--- Pull the titles --->
<cfset titles = XmlSearch(pitchforkFeed, "/rss/channel/item/title/")>
<!--- The titles need to be scrubbed so they actually work as arguments to the FilesTube API --->
<cfset numItems = ArrayLen(titles)>
<cfloop index="i" from="1" to=#numItems#>
	<cfset artistAlbum = #titles[i].xmlText#>
	<cfset noSpaceName = REREplace(artistAlbum, "&[##\d]+;", "", "ALL")>
	<cfset noSpaceName = REREplace(noSpaceName, "(\s)+", " ", "ALL")>
	<cfset noSpaceName = REREplace(noSpaceName, " ?- ?", " ", "ALL")>
	<cfdump var="#noSpaceName#">
	<cfset noSpaceName = URLEncodedFormat(noSpaceName, "utf-8")>	
	<cfset filesTubeURL[i] = "http://api.filestube.com/?key=#apiKey#&phrase=#noSpaceName#">
</cfloop>
<!--- This is where we grab shit from the FT API --->
<cfset urlLength = ArrayLen(filesTubeURL)>
<cfloop index="j" from="1" to=#urlLength#>
	<cfhttp method="Get" url="#filesTubeURL[j]#">
	<!--- I should save these as a file so that processing isn't ridiculous --->
	<cfset filesTubeFeed = XmlParse("#cfhttp.FileContent#")>	
	<cfset links = XmlSearch(filesTubeFeed, "/answer/results/hits/")>
	<cfset linkLength = ArrayLen(links)>
	<cfoutput>
	<!--- Start outputing the urls --->
	<p>#titles[j].xmlText#</p>	
	<ul>
	<cfloop index="k" from ="1" to="#linkLength#">
		<li><p>
			#links[k].name.xmlText#&mdash;
			#links[k].size.xmlText# <br />
			<a href=#links[k].address.xmlText#>#links[k].address.xmlText#</a>
			</p>
		</li>
	</cfloop>
	</ul>
	</cfoutput>
</cfloop>

Revision: 31271
at September 2, 2010 05:04 by landock


Initial Code
<cfset apiKey="yourApiKeyHere">
<!--- Grab the feed --->
<cfset pitchforkFeed = XmlParse("http://feeds.feedburner.com/PitchforkBestNewAlbums?format=xml")>
<!--- Pull the titles --->
<cfset titles = XmlSearch(pitchforkFeed, "/rss/channel/item/title/")>
<!--- The titles need to be scrubbed so they actually work as arguments to the FilesTube API --->
<cfset numItems = ArrayLen(titles)>
<cfloop index="i" from="1" to=#numItems#>
	<cfset artistAlbum = #titles[i].xmlText#>
	<!--- <cfset noSpaceName = Trim(artistAlbum)> --->
	<cfset noSpaceName = REREplace(artistAlbum, "&[##\d]+;", "", "ALL")>
	<cfset noSpaceName = REREplace(noSpaceName, "(\s)+", " ", "ALL")>
	<cfset noSpaceName = REREplace(noSpaceName, " ?- ?", " ", "ALL")>
	<cfdump var="#noSpaceName#">
	<cfset noSpaceName = URLEncodedFormat(noSpaceName, "utf-8")>	
	<cfset filesTubeURL[i] = "http://api.filestube.com/?key=#apiKey#&phrase=#noSpaceName#">
</cfloop>
<!--- This is where we grab shit from the FT API --->
<cfset urlLength = ArrayLen(filesTubeURL)>
<cfloop index="j" from="1" to=#urlLength#>
	<cfhttp method="Get" url="#filesTubeURL[j]#">
	<!--- I should save these as a file so that processing isn't ridiculous --->
	<cfset filesTubeFeed = XmlParse("#cfhttp.FileContent#")>	
	<cfset links = XmlSearch(filesTubeFeed, "/answer/results/hits/")>
	<cfset linkLength = ArrayLen(links)>
	<cfoutput>
	<!--- Start outputing the urls --->
	<p>#titles[j].xmlText#</p>	
	<ul>
	<cfloop index="k" from ="1" to="#linkLength#">
		<li><p>
			#links[k].name.xmlText#&mdash;
			#links[k].size.xmlText# <br />
			<a href=#links[k].address.xmlText#>#links[k].address.xmlText#</a>
			</p>
		</li>
	</cfloop>
	</ul>
	</cfoutput>
</cfloop>

Initial URL

                                

Initial Description

                                

Initial Title
pitchfork best new music filestube mashup

Initial Tags
api

Initial Language
ColdFusion