<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《Downloading YouTube Videos with a Groovy one-liner, kind of》的评论</title>
	<atom:link href="http://damienh.org/2007/07/29/downloading-youtube-videos-with-a-groovy-one-liner-kind-of/feed/" rel="self" type="application/rss+xml" />
	<link>http://damienh.org/2007/07/29/downloading-youtube-videos-with-a-groovy-one-liner-kind-of/</link>
	<description>Braindump from Damien; Python, Objective-C, Javascript, geeking;</description>
	<lastBuildDate>Sun, 16 Oct 2011 08:37:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>作者：houyr</title>
		<link>http://damienh.org/2007/07/29/downloading-youtube-videos-with-a-groovy-one-liner-kind-of/comment-page-1/#comment-23</link>
		<dc:creator>houyr</dc:creator>
		<pubDate>Mon, 30 Jul 2007 08:29:58 +0000</pubDate>
		<guid isPermaLink="false">http://houyr.72pines.com/2007/07/29/downloading-youtube-videos-with-a-groovy-one-liner-kind-of/#comment-23</guid>
		<description>Cool! Yeah substring is actually the simpler approach to the do the same thing:P</description>
		<content:encoded><![CDATA[<p>Cool! Yeah substring is actually the simpler approach to the do the same thing:P</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：Jove</title>
		<link>http://damienh.org/2007/07/29/downloading-youtube-videos-with-a-groovy-one-liner-kind-of/comment-page-1/#comment-22</link>
		<dc:creator>Jove</dc:creator>
		<pubDate>Mon, 30 Jul 2007 04:43:56 +0000</pubDate>
		<guid isPermaLink="false">http://houyr.72pines.com/2007/07/29/downloading-youtube-videos-with-a-groovy-one-liner-kind-of/#comment-22</guid>
		<description>Awesome!

Anyway, I&#039;d prefer using substring to make the code more readable :D

[code]
HttpURLConnection.followRedirects=false
def vid=args[0].substring(&#039;http://www.youtube.com/watch?v=&#039;.length())
def uri = new URL(&quot;http://www.youtube.com/v/$vid&quot;).openConnection().getHeaderField(&#039;Location&#039;)
def t=uri.substring(uri.lastIndexOf(&#039;=&#039;)+1)
HttpURLConnection.followRedirects=true
def output=new File(&quot;${vid}.flv&quot;)
if(output.exists()) output.delete()
println &quot;Saving ${output.canonicalPath}&quot;
output.withOutputStream{os -&gt; new URL(&quot;http://www.youtube.com/get_video?video_id=$vid&amp;t=$t&quot;).eachByte{os.write(it)}}
[/code]</description>
		<content:encoded><![CDATA[<p>Awesome!</p>
<p>Anyway, I&#8217;d prefer using substring to make the code more readable <img src='http://damienh.org/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>[code]<br />
HttpURLConnection.followRedirects=false<br />
def vid=args[0].substring('http://www.youtube.com/watch?v='.length())<br />
def uri = new URL("http://www.youtube.com/v/$vid").openConnection().getHeaderField('Location')<br />
def t=uri.substring(uri.lastIndexOf('=')+1)<br />
HttpURLConnection.followRedirects=true<br />
def output=new File("${vid}.flv")<br />
if(output.exists()) output.delete()<br />
println "Saving ${output.canonicalPath}"<br />
output.withOutputStream{os -&gt; new URL("http://www.youtube.com/get_video?video_id=$vid&amp;t=$t").eachByte{os.write(it)}}<br />
[/code]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

