You are on page 1of 2

##

YouTube Fix
generate_204
Owner
:
Faysal Banna
Liscence
:
GPL
Date
:
29/04/2013
E-Mail
:
degreane@gmail.com
##
Description:
================================================================================
================================================
Purpose of this project is to catchup with the changes done by youtube guys
to reflect the new changes and get videos cacheable once again.
it grabs the request sent from squid mainly the one contains http://(.*)\.youtub
e.com/generate_204\?(.*)?&id=([0-9a-zA-Z\-\_]+)(.*)?
then take the referer header should look something like
referer :
'http://www.youtube.com/watch?v=([0-9a-zA-Z\-\_]+)'
I take the reqular expression in the referer and touch a file in /data/YouTube/h
acked/ID and put inside it the referer
in the Store_URL_Rewrite i look for the ID file and read the referer and reply w
ith referer&itag&range
thus no matter what id's youtube use that shall always refer to the same video b
eing watched
================================================================================
================================================
Language Used : NodeJS
Version
: 0.10.5
################################################################################
################################################
ChangeLog:
29/04/2013
- Creation of script uses module request to pipe in and
out requests to and from client to server creating a bridge
System Performed quite well no errors and even a
dded custom header to the reply works flawless
################################################################################
################################################
Steps:
1- Create listening server port 8888
2- in request part
a- select the generate_204? url
b- get the referer request.headers.referer
get the v=(.*) from the
c- get the id=(.*)&itag=(.*)
var myquerystring=url.parse(request.url,true).query;
3- create a file named id that contains the referer header v=(.*)
in directory called /data/YouTube/hacked/$id
and put inside the file the value of the referer header
4- update store_url_rewrite as follows
if( $QS =~ m/id=([a-z0-9A-Z\-\_]+)/ ){ $ID="&id=$1"; $ScalarID="
$1";}
$FILE='/data/YouTube/hacked/'.$ScalarID;
if ( -e $FILE ) {
local $/=undef;
open FILE,$FILE;

$CONTENT=<FILE>;
close FILE;
}else {
$CONTENT=$ID;
}
5- finally set your batch file to run endlessly in the background and po
int squid-cache to use url_regex (http://(.*)\.youtube.com/generate_204\?(.*)?&i
d=([0-9a-zA-Z\-\_]+)(.*)?) acl parent proxy 127.0.0.1 port 8888
6- Happy Caching

You might also like