Breaking News
Loading...
07 December 2013

squid.conf dan storeurl.pl terbaru untuk cache youtube 2013

langkah-langkah

1. apt-get install libfile-readbackwards-perl
2. edit squid.conf dan sisipkan : 

 strip_query_terms off
acl yutub dstdomain .youtube.com .youtu.be
logformat squid1 %{Referer}>h %ru
access_log /var/log/squid/access.log squid1 yutub
acl redirec urlpath_regex -i &redirect_counter=1&cms_redirect=yes &ir=1&rr=12
cache deny redirec
storeurl_access deny redirec
acl reddeny url_regex -i c\.youtube\.com\/videoplayback.*redirect_counter=1.*$
acl reddeny url_regex -i c\.youtube\.com\/videoplayback.*cms_redirect=yes.*$
storeurl_access deny reddeny
acl dontrewrite url_regex redbot\.org \.php
acl getmethod method GET

3. edit storeurl.pl dan sisipkan :

} elsif ($X[1] =~ m/^http\:\/\/.*(youtube|google).*videoplayback.*/){
        sleep(2);
        @itag = m/[&?](itag=[0-9]*)/;
        @CPN = m/[&?]cpn\=([a-zA-Z0-9\-\_]*)/;
        @IDS = m/[&?]id\=([a-zA-Z0-9\-\_]*)/;
        $id = &GetID($CPN[0], $IDS[0]);
        @range = m/[&?](range=[^\&\s]*)/;
        print $x . "http://video-srv.youtube.com.SQUIDINTERNAL/id=" . $id . "&@itag@range\n";


dan paling  bawah setelah if paling terakhir tambahkan :
sub GetID
{
use File::ReadBackwards;
my $lim = 200 ;
my $ref_log = File::ReadBackwards->new('/var/log/squid/access.log');
while (defined($line = $ref_log->readline))
{
if ($line =~ m/.*youtube.*\/watch\?.*v=([a-zA-Z0-9\-\_]*).*\s.*id=$IDS[0].*/){
$id = $1;
last;
}
if ($line =~ m/.*youtube.*\/.*cpn=$CPN[0].*[&](video_id|docid|v)=([a-zA-Z0-9\-\_]*).*/){
$id = $2;
last;
}
if ($line =~ m/.*youtube.*\/.*[&?](video_id|docid|v)=([a-zA-Z0-9\-\_]*).*cpn=$CPN[0].*/){
$id = $2;
last;
}
last if --$lim <= 0;
}
if ($id eq ''){
$id = $CPN[0];
}
$ref_log->close();
return $id;
}




============================================================================
acl youtube url_regex -i youtube.*(ptracking|stream_204|player_204|gen_204)[ada space disini].*$
acl youtube url_regex -i \.c\.(youtube|google)\.com\/(get_video|videoplayback|videoplay).*$

saya ubah jadi

acl youtube url_regex -i youtube.*(ptracking|stream_204|player_204|gen_204) .*$
acl youtube url_regex -i \.(youtube|google|googlevideo)\.com\/(get_video|videoplayback|videoplay).*$
storeurl_access allow youtube
====================================================================
 Seharusnya memang tidak ada spasi. Krn regex apapun tidak mengenal karakter spasi alias kosong/hampa udara.

2 komentar:

 
Toggle Footer