Advertisement
ujiajah1

youtube.pl

Jan 4th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. #### var
  4. use IO::File;
  5. $|=1;
  6. STDOUT->autoflush(1);
  7. $debug=1; ## recommended:0
  8. $bypassallrules=0; ## recommended:0
  9. $sucks=""; ## unused
  10. $sucks="sucks" if ($debug>=1);
  11. $timenow="";
  12. $printtimenow=1; ## print timenow: 0|1
  13. my $logfile = '/tmp/urlrewrite.log';
  14.  
  15. open my $logfh, '>>', $logfile
  16. or die "Couldn't open $logfile for appending: $!\n" if $debug;
  17. $logfh->autoflush(1) if $debug;
  18.  
  19.  
  20. while () {
  21. $timenow=time()." " if ($printtimenow);
  22. #print $logfh "$timenow"."in : $_" if ($debug>=1);
  23. #print $logfh "in : $_" if ($debug>=1);
  24. chop; ## strip eol
  25. my $urlku = $_;
  26. #@X = split;
  27. @X = split(" ",$urlku);
  28. $a = $X[0]; ## chanel
  29. $b = $X[1]; ## url
  30. $c = $X[2]; ## ip
  31. $u = $b; ## url
  32.  
  33. print $logfh "in : $_\n" if ($debug>=1);
  34.  
  35. if ($bypassallrules){
  36. $out="$u"; ## map 1:1
  37.  
  38. #utmgif
  39. } elsif ($u=~ m/^https?\:\/\/.*youtube\.com\/watch\?.*/) {
  40. $out="OK rewrite-url=$u&html5=1";
  41.  
  42.  
  43.  
  44.  
  45. } else {
  46. $out="ERR";
  47. }
  48. print $logfh "out: $a $out\n" if ($debug>=1);
  49. print "$a $out\n";
  50. }
  51. close $logfh if ($debug);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement