Headlines News :

POPULAR POST

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;
}
 
Copyright © 2011. COMASTNET - All Rights Reserved