<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>FOX21.at v.2.0 &#187; YouTube</title>
	<atom:link href="http://fox21.at/tag/youtube/feed" rel="self" type="application/rss+xml" />
	<link>http://fox21.at</link>
	<description>Just another Perl hacker.</description>
	<lastBuildDate>Fri, 27 Aug 2010 11:05:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>YouTube Download 1.0.0</title>
		<link>http://fox21.at/youtube-direct-download-100.html</link>
		<comments>http://fox21.at/youtube-direct-download-100.html#comments</comments>
		<pubDate>Sun, 15 Feb 2009 12:17:00 +0000</pubDate>
		<dc:creator>TheFox</dc:creator>
				<category><![CDATA[Perl]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[Download]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flv]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[YouTube]]></category>

		<guid isPermaLink="false">http://cms.fox21.at/nocache/?p=766</guid>
		<description><![CDATA[Es gibt kein Problem, das man nicht mit Perl loesen koennte. Ja, ich weiss: es existieren schon unzaehlige Scripte und Programme im Netz, die genau das Gleiche machen wie meines hier. Aber ich dachte mir, ich koennte selber einmal ein Script schreiben, dass die Videos direkt von youtube.com herunterladet. So kann man vielleicht die Funktionsweise [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a target="_blank" href="http://api.tweetmeme.com/share?url=http%3A%2F%2Ffox21.at%2Fyoutube-direct-download-100.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Ffox21.at%2Fyoutube-direct-download-100.html&amp;source=TheFox21&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Es gibt kein Problem, das man nicht mit Perl loesen koennte. Ja, ich weiss: es existieren schon unzaehlige Scripte und Programme im Netz, die genau das Gleiche machen wie meines hier. Aber ich dachte mir, ich koennte selber einmal ein Script schreiben, dass die Videos direkt von <a target="_blank" href="http://www.youtube.com/" target="_blank">youtube.com</a> herunterladet. So kann man vielleicht die Funktionsweise besser verstehen. Ausserdem ist meines <a target="_blank" href="http://de.wikipedia.org/wiki/Open_source" target="_blank">Open Source</a>.</p>
<p><span id="more-766"></span></p>
<p>Es ist eigentlich ganz einfach. Auf jeder YouTube Seite, z.B. <a target="_blank" href="http://www.youtube.com/watch?v=g4uxIo4t7xM" target="_blank">http://www.youtube.com/watch?v=g4uxIo4t7xM</a>, gibt es im HTML Quellcode ein paar JavaScript Variablen, die Flash fuer sich verwendet. Die gesuchte Variable heisst <strong>swfArgs</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> swfArgs <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;q&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;ghostbusters&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;fexp&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;900076&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;vq&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;sourceid&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;ys&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;video_id&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;g4uxIo4t7xM&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;l&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">297</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;sk&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;-RplWXYJhe-YnAN5S824RPkvqdQKDg-rC&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;fmt_map&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;6/720000/7/0/0,34/0/9/0/115&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;usef&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;t&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;vjVQa1PpcFPDn9RlUJw_zdoFEddjpuNrJr0crbQDefw=&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;hl&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;en&quot;</span><span style="color: #339933;">,</span>
<span style="color: #3366CC;">&quot;plid&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;AARi8t_zDjFbWjDVAAAAoAAICAA&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;cr&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;US&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Darin kommt auch das Argument <em>t</em> vor. In dem Fall waere der Hash <strong>vjVQa1PpcFPDn9RlUJw_zdoFEddjpuNrJr0crbQDefw=</strong>. Dieser Hash aendert sich jedoch immer, wenn man die Seite neu ladet. Mit jedem Hash kann man das original Video nur <strong>einmal</strong> herunterladen. Von folgender URL kann man also dann das gewuenschte Video herunterladen.</p>
<pre>http://www.youtube.com/get_video?video_id={$id}&amp;t={$t}=&amp;el=detailpage&amp;ps=</pre>
<p><strong>{$id}</strong> muss durch die Video ID, die auch schon als <em>v</em> im original Link (http://www.youtube.com/watch?v=<strong>g4uxIo4t7xM</strong>) vorkommt, ersetzt werden. Und <strong>{$t}</strong> durch den Hash, den wir oben im JavaScript gefunden haben.</p>
<p>Das Script macht genau diese Schritte automatisch.</p>
<h2><strong>Benoetigte Perl-Module</strong></h2>
<ul>
<li>LWP::Simple</li>
<li>LWP::UserAgent</li>
<li>HTTP::Request</li>
<li>HTTP::Request::Common</li>
<li>HTTP::Response</li>
<li>File::Basename</li>
</ul>
<h2><strong>Installation</strong></h2>
<ol>
<li>Herunterladen von <a target="_blank" href="http://software.fox21.at/youtube/releases/youtube-1.0.0.zip">youtube-1.0.0.zip</a></li>
<li>Entpacken mit <em>unzip youtube-1.0.0.zip</em></li>
<li>Damit man die Scripte ausfuehren kann, Rechte mit chmod auf 755 stellen: <em>chmod 755 ./youtube.pl ./install.pl</em></li>
<li>Ausfuehren von <em>./install.pl</em> um zu sehen, ob alle benoetigten Perl Module installiert sind.</li>
</ol>
<h2><strong>Verwendung unter Linux</strong></h2>
<pre>./youtube.pl "URL"</pre>
<p>oder</p>
<pre>./youtube.pl "URL" "URL" "URL"</pre>
<h2><strong>Verwendung unter Windows</strong></h2>
<pre>perl youtube.pl "URL"</pre>
<p>oder</p>
<pre>perl youtube.pl "URL" "URL" "URL"</pre>
<p>Der oder die uebergebenen URLs sollten auf jeden Fall unter Hochkomma gestellt werden.  Nachdem man dann eines oder mehrere Videos erfolgreich heruntergeladen hat, wird man feststellen, dass sie die Endung <strong>.flv</strong> haben. Entweder schaut man sich die Videos direkt mit dem <a target="_blank" href="http://www.adobe.com/de/products/flashplayer/" target="_blank">Flashplayer</a> an, oder man nimmt das Programm <a target="_blank" href="http://ffmpeg.org/" target="_blank">ffmpeg</a> zur Hand und wandelt es in <strong>.mpg</strong> um.</p>
<h2><strong>.flv Konvertierung unter Linux mit <a target="_blank" href="http://ffmpeg.org/" target="_blank">ffmpeg</a></strong></h2>
<pre>ffmpeg -i movie.flv movie.mpg</pre>
<h2><strong>Download</strong></h2>
<ul>
<li><a target="_blank" href="http://software.fox21.at/youtube/releases/youtube-1.0.0.zip">youtube-1.0.0.zip</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://fox21.at/youtube-direct-download-100.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
