Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # youtube
- squid.conf =
- acl yt url_rgex -i ^https?:\/\/.*\.googlevideo\.com\/videoplayback\?
- acl yt url_regex -i ^https?:\/\/.*\.ytimg\.com.*\.(webp|jpg|gif)
- acl yt url_regex -i youtube.*(ptracking|stream_204|player_204|gen_204).*$
- acl yt url_regex -i \.c\.(youtube|google)\.com\/(get_video|videoplayback|videoplay).*$
- acl yt url_regex -i (youtube|google).*\/videoplayback\?.*
- store_id_extras "%>a/%>A %un %>rm myip=%la myport=%lp %{Referer}>h"
- store_id_access allow yt
- refresh_pattern =
- refresh_pattern -i ^http.*\.puji\-ganteng\.com.* 432000 100% 432000 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-store ignore-private ignore-auth ignore-must-revalidate
- refresh_pattern (audio|video)\/(webm|mp4) 129600 99% 129600 ignore-reload override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth store-stale
- refresh_pattern -i (yimg|twimg)\.com\.* 1440 100% 129600 override-expire ignore-reload reload-into-ims
- refresh_pattern -i (ytimg|ggpht)\.com\.* 1440 80% 129600 override-expire override-lastmod ignore-auth ignore-reload reload-into-ims
- refresh_pattern -i (get_video\?|videoplayback\?|videodownload\?|\.mp4|\.webm|\.flv|((audio|video)\/(webm|mp4))) 241920 100% 241920 override-expire ignore-reload ignore-private ignore-no-store ignore-must-revalidate reload-into-ims ignore-auth store-stale
- refresh_pattern -i ^https?\:\/\/.*\.googlevideo\.com\/videoplayback.* 10080 99% 43200 override-lastmod override-expire ignore-reload reload-into-ims ignore-private reload-into-ims ignore-auth store-stale
- refresh_pattern -i \.*\.*(webm|mp4).* 129600 99% 129600 ignore-reload override-expire override-lastmod ignore-must-revalidate ignore-private ignore-no-store ignore-auth store-stale
- =============================================================================================================================
- store-id.pl =
- #!/usr/bin/perl
- # faktor yang bisa menyelamatkan adalah mamam
- # storeid.pl with debug opt - based on storeurl.pl
- # jangan lupa mamam loh
- # hati hati telat mamam nanti sakit mah
- # BONBIN.NET http://172.16.0.2/
- chomp;
- my $puji = "";
- if (s/^(\d+\s+)//o) { $puji = $1; }
- @X = split;
- if (@X[0] =~ m/^(exit|quit|x|q)/) {
- print STDERR "quiting helper quietly\n";
- exit 0;
- }
- $url = $X[0];
- $referer = $X[1];
- use IO::File;
- $|=1;
- STDOUT->autoflush(1);
- $debug=0; ## recommended:0
- $bypassallrules=0; ## recommended:0
- $sucks=""; ## unused
- $sucks="sucks" if ($debug>=1);
- $timenow="";
- $printtimenow=1; ## print timenow: 0|1
- my $logfile = '/tmp/storeid.log';
- open my $logfh, '>>', $logfile
- or die "Couldn't open $logfile for appending: $!\n" if $debug;
- $logfh->autoflush(1) if $debug;
- while (<>) {
- $timenow=time()." " if ($printtimenow);
- print $logfh "$timenow"."in : $_" if ($debug>=1);
- chop;
- my $myURL = $_;
- @X = split(" ",$myURL);
- $a = $X[0]; ## channel id
- $b = $X[1]; ## url
- $c = $X[2]; ## ip address
- $u = $b; ## url
- if ($bypassallrules){
- $out="$u"; ## map 1:1
- } elsif ($u =~ m/^http:\/\/(.*?)\.yimg\.com\/(.*?)\.yimg\.com\/(.*?)\?(.*)/) {
- $out="OK store-id=http://cdn.yimg.squid.internal/" . $3;
- } elsif ($u=~ m/^https?\:\/\/.*youtube.*ptracking.*/){
- @video_id = m/[&?]video_id\=([^\&\s]*)/;
- @cpn = m/[&?]cpn\=([^\&\s]*)/;
- unless (-e "/tmp/@cpn"){
- open FILE, ">/tmp/@cpn";
- print FILE "@video_id";
- close FILE;
- }
- $out="ERR";
- } elsif ($u=~ m/^https?\:\/\/.*youtube.*stream_204.*/){
- @docid = m/[&?]docid\=([^\&\s]*)/;
- @cpn = m/[&?]cpn\=([^\&\s]*)/;
- unless (-e "/tmp/@cpn"){
- open FILE, ">/tmp/@cpn";
- print FILE "@docid";
- close FILE;
- }
- $out="ERR";
- } elsif ($u=~ m/^https?\:\/\/.*youtube.*player_204.*/){
- @v = m/[&?]v\=([^\&\s]*)/;
- @cpn = m/[&?]cpn\=([^\&\s]*)/;
- unless (-e "/tmp/@cpn"){
- open FILE, ">/tmp/@cpn";
- print FILE "@v";
- close FILE;
- }
- $out="ERR";
- }elsif ($url =~ m/^https?:\/\/.*\.googlevideo\.com\/videoplayback\?.*/) {
- @id = m/[\&?|\%?|\s?]id=([^\&\%\s]+)/;
- @range = m/[\&?|\%?|\s?]range=([^\&\%\s]+)/;
- @itag = m/[\&?|\%?|\s?]itag=([^\&\%\s]+)/;
- @mime = m/[\&?|\%?|\s?]mime=([^\&\%\s]+)/;
- @clen = m/[\&?|\%?|\s?]clen=([^\&\%\s]+)/;
- if ($referer =~ m/^https?\:\/\/www\.youtube\.com\/(watch\?v\=|embed\/|v\/)(.*)/) {
- $v = $2;
- } else { $v = $id[0] }
- $out = "http://youtube.puji-ganteng.com/" . $v . "@range@itag@mime@clen";
- } elsif ($u=~ m/^https?\:\/\/.*(youtube|googlevideo).*videoplayback.*/){
- @itag = m/[&?](itag\=[0-9]*)/;
- @range = m/[&?](range\=[^\&\s]*)/;
- @cpn = m/[&?]cpn\=([^\&\s]*)/;
- @mime = m/[&?](mime\=[^\&\s]*)/;
- @id = m/[&?]id\=([^\&\s]*)/;
- if (defined(@cpn[0])){
- if (-e "/tmp/@cpn"){
- open FILE, "/tmp/@cpn";
- @id = <FILE>;
- close FILE;}
- }
- $out="OK store-id=http://video-srv.squid.internal/id=@id@mime@range@referer";
- } else {
- $out="ERR";
- }
- print $logfh "$timenow"."out: $a $out\n" if ($debug>=1);
- print "$a $out\n";
- }
- if ($out =~ m/^http:\/\/.*/) {
- print $puji, "OK store-id=$out\n";
- } else {
- print $puji, "ERR\n";
- close $logfh if ($debug);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement