Advertisement
suprianto

rewriteitagyoutube

Feb 15th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # edited by suprianto_clg@yahoo.com
  3. # https://www.facebook.com/supri.anto.353
  4.  
  5. use LWP::Simple;
  6. use CGI qw/unescape/;
  7. #### var
  8. use IO::File;
  9. #$|=1;
  10. $timenow="";
  11.  
  12. STDOUT->autoflush(1);
  13. $debug=1; ## recommended:0
  14. $bypassallrules=0; ## recommended:0
  15. $sucks=""; ## unused
  16. $sucks="sucks" if ($debug>=1);
  17. my $logfile = '/tmp/storeid.log';
  18. open my $logfh, '>>', $logfile
  19. or die "Couldn't open $logfile for appending: $!\n" if $debug;
  20. $logfh->autoflush(1) if $debug;
  21.  
  22. while (<>) {
  23. chop;
  24. my $myurl = $_;
  25. @X = split(" ",$myurl);
  26. $chan = $X[0]; ## channel id
  27. $url = $X[1]; ## url
  28. $ip = $X[2]; ## ip address
  29. $anbel = $url; ## url
  30.  
  31. ##print $logfh "in : $_\n" if ($debug>=1);
  32.  
  33. if ($bypassallrules){
  34. $out="$anbel"; ## map 1:1
  35.  
  36. } elsif ($anbel =~ m/^https?:\/\/.*googlevideo\.com\/videoplayback.*(&itag\=([0-9]*)).*(mime\=video).*/) {
  37. $video = $3;
  38. $itag = $2;
  39. $anbel =~ s/$2/itag=133/g;
  40. print "OK status=302 url=$anbel\n";
  41.  
  42. } elsif ($anbel =~ m/^https?:\/\/.*googlevideo\.com\/videoplayback.*(mime\=video).*(&itag\=([0-9]*)).*/) {
  43. $video = $2;
  44. $itag = $3;
  45. $anbel =~ s/$3/itag=133/g;
  46. print "OK status=302 url=$anbel\n";
  47.  
  48. } else {
  49. print "ERR\n";
  50. }
  51. }
  52.  
  53. #----------------------------
  54. #Squid tambahkan
  55. #helper Force240p
  56. #----------------------------
  57. acl ytmimevideo url_regex -i ^https?://.*&itag\=(133|134|135|136)\&.*&mime=video.*
  58. url_rewrite_program /etc/squid/force240p.pl
  59. url_rewrite_children 100
  60. url_rewrite_access allow ytmimevideo
  61. url_rewrite_access deny all
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement