Advertisement
ujiajah1

youtube audio/video/mp4/webm

May 30th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 5.02 KB | None | 0 0
  1. # youtube
  2. squid.conf =
  3. acl yt url_rgex -i ^https?:\/\/.*\.googlevideo\.com\/videoplayback\?
  4. acl yt url_regex -i ^https?:\/\/.*\.ytimg\.com.*\.(webp|jpg|gif)
  5. acl yt url_regex -i youtube.*(ptracking|stream_204|player_204|gen_204).*$
  6. acl yt url_regex -i  \.c\.(youtube|google)\.com\/(get_video|videoplayback|videoplay).*$
  7. acl yt url_regex -i (youtube|google).*\/videoplayback\?.*
  8.  
  9. store_id_extras "%>a/%>A %un %>rm myip=%la myport=%lp  %{Referer}>h"
  10. store_id_access allow yt
  11.  
  12. refresh_pattern =
  13. 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
  14. 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
  15. refresh_pattern -i (yimg|twimg)\.com\.* 1440 100% 129600 override-expire ignore-reload reload-into-ims
  16. refresh_pattern -i (ytimg|ggpht)\.com\.* 1440 80% 129600 override-expire override-lastmod ignore-auth ignore-reload reload-into-ims
  17. 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
  18. 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
  19. 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
  20.  
  21. =============================================================================================================================
  22.  
  23. store-id.pl =
  24.  
  25. #!/usr/bin/perl
  26. # faktor yang bisa menyelamatkan adalah mamam
  27. # storeid.pl with debug opt - based on storeurl.pl
  28. # jangan lupa mamam loh
  29. # hati hati telat mamam nanti sakit mah
  30. # BONBIN.NET http://172.16.0.2/
  31. chomp;
  32.  
  33. my $puji = "";
  34. if (s/^(\d+\s+)//o) { $puji = $1; }
  35.  
  36. @X = split;
  37. if (@X[0] =~ m/^(exit|quit|x|q)/) {
  38. print STDERR "quiting helper quietly\n";
  39. exit 0;
  40. }
  41. $url = $X[0];
  42. $referer = $X[1];
  43.  
  44. use IO::File;
  45. $|=1;
  46. STDOUT->autoflush(1);
  47. $debug=0;           ## recommended:0
  48. $bypassallrules=0;      ## recommended:0
  49. $sucks="";          ## unused
  50. $sucks="sucks" if ($debug>=1);
  51. $timenow="";
  52. $printtimenow=1;        ## print timenow: 0|1
  53. my $logfile = '/tmp/storeid.log';
  54.  
  55. open my $logfh, '>>', $logfile
  56.     or die "Couldn't open $logfile for appending: $!\n" if $debug;
  57. $logfh->autoflush(1) if $debug;
  58.  
  59. while (<>) {
  60. $timenow=time()." " if ($printtimenow);
  61. print $logfh "$timenow"."in : $_" if ($debug>=1);
  62. chop;
  63. my $myURL = $_;
  64. @X = split(" ",$myURL);
  65. $a = $X[0]; ## channel id
  66. $b = $X[1]; ## url
  67. $c = $X[2]; ## ip address
  68. $u = $b; ## url
  69.  
  70. if ($bypassallrules){
  71.  $out="$u"; ## map 1:1
  72.  
  73. } elsif ($u =~ m/^http:\/\/(.*?)\.yimg\.com\/(.*?)\.yimg\.com\/(.*?)\?(.*)/) {
  74.     $out="OK store-id=http://cdn.yimg.squid.internal/" . $3;
  75.  
  76. } elsif ($u=~ m/^https?\:\/\/.*youtube.*ptracking.*/){
  77.     @video_id = m/[&?]video_id\=([^\&\s]*)/;
  78.     @cpn = m/[&?]cpn\=([^\&\s]*)/;
  79.     unless (-e "/tmp/@cpn"){
  80.     open FILE, ">/tmp/@cpn";
  81.     print FILE "@video_id";
  82.     close FILE;
  83.     }
  84.     $out="ERR";
  85.  
  86. } elsif ($u=~ m/^https?\:\/\/.*youtube.*stream_204.*/){
  87.     @docid = m/[&?]docid\=([^\&\s]*)/;
  88.     @cpn = m/[&?]cpn\=([^\&\s]*)/;
  89.     unless (-e "/tmp/@cpn"){
  90.     open FILE, ">/tmp/@cpn";
  91.     print FILE "@docid";
  92.     close FILE;
  93.     }
  94.     $out="ERR";
  95.  
  96. } elsif ($u=~ m/^https?\:\/\/.*youtube.*player_204.*/){
  97.     @v = m/[&?]v\=([^\&\s]*)/;
  98.     @cpn = m/[&?]cpn\=([^\&\s]*)/;
  99.     unless (-e "/tmp/@cpn"){
  100.     open FILE, ">/tmp/@cpn";
  101.     print FILE "@v";
  102.     close FILE;
  103.     }
  104.     $out="ERR";
  105.  
  106. }elsif ($url =~ m/^https?:\/\/.*\.googlevideo\.com\/videoplayback\?.*/) {
  107.         @id = m/[\&?|\%?|\s?]id=([^\&\%\s]+)/;
  108.         @range = m/[\&?|\%?|\s?]range=([^\&\%\s]+)/;
  109.         @itag = m/[\&?|\%?|\s?]itag=([^\&\%\s]+)/;
  110.         @mime = m/[\&?|\%?|\s?]mime=([^\&\%\s]+)/;
  111.         @clen = m/[\&?|\%?|\s?]clen=([^\&\%\s]+)/;
  112.         if ($referer =~ m/^https?\:\/\/www\.youtube\.com\/(watch\?v\=|embed\/|v\/)(.*)/) {
  113.             $v = $2;
  114.         } else { $v = $id[0] }
  115.         $out = "http://youtube.puji-ganteng.com/" . $v . "@range@itag@mime@clen";
  116.  
  117. } elsif ($u=~ m/^https?\:\/\/.*(youtube|googlevideo).*videoplayback.*/){
  118.     @itag = m/[&?](itag\=[0-9]*)/;
  119.     @range = m/[&?](range\=[^\&\s]*)/;
  120.     @cpn = m/[&?]cpn\=([^\&\s]*)/;
  121.     @mime = m/[&?](mime\=[^\&\s]*)/;
  122.     @id = m/[&?]id\=([^\&\s]*)/;
  123.  
  124.     if (defined(@cpn[0])){
  125.         if (-e "/tmp/@cpn"){
  126.         open FILE, "/tmp/@cpn";
  127.         @id = <FILE>;
  128.         close FILE;}
  129.     }
  130.     $out="OK store-id=http://video-srv.squid.internal/id=@id@mime@range@referer";
  131.  
  132. } else {
  133.     $out="ERR";
  134. }
  135.     print $logfh "$timenow"."out: $a $out\n" if ($debug>=1);
  136.     print "$a $out\n";
  137. }
  138. if ($out =~ m/^http:\/\/.*/) {
  139.     print $puji, "OK store-id=$out\n";
  140. } else {
  141.     print $puji, "ERR\n";
  142. close $logfh if ($debug);
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement