Advertisement
suprianto

store-id

Oct 27th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 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/^http(|s)\:\/\/.*(youtube|google).*(ptracking|stream_204|playback|player_204|gen_204|watchtime|set_awesome|get_video|s\?|ads|qoe|csi).*(video_id|docid|\&v|content_v)\=([^\&\s]*).*/) {
  37. $vid = $5 ;
  38. @cpn = m/[&?]cpn\=([^\&\s]*)/;
  39. if (defined($vid )) {
  40. $fn = "/tmp/@cpn";
  41. unless (-e $fn ) {
  42. open FH,">".$fn ;
  43. print FH "$vid\n";
  44. close FH;
  45. }
  46. }
  47. $out = "ERR\n" ;
  48.  
  49. # youtube on iphone(apple-devices) and Black-Berry(BB) beta-1
  50. # youtube on browser
  51. } elsif ($anbel=~ m/^https?\:\/\/.*(youtube|google).*videoplayback.*/) {
  52. @cpn = m/[^\/\&]?cpn[\/|\=]([^\&\s]*)/;
  53. if (defined($cpn[0])) {
  54. $fn = "/tmp/@cpn";
  55. if (-e $fn ) {
  56. open FH,"<".$fn ;
  57. $id = <FH>;
  58. chomp $id ;
  59. close FH;
  60.  
  61. @itag = m/[&?\/](itag[=\/]\d*)/;
  62. $itag[0] =~ s/\//\=/g;
  63. #@ids = m/[\/\&]?id[\/|\=]([^\/\&\s]*)/;
  64. #@mime = m/[\/\&]?(mime[\/|\=][^\/\&\s\%]*)/;
  65. @slices = m/[\/?]slices\%3D\d\-\d+,([\d-\d]*)/;
  66. #@cver = m/[^\/\&]?(cver[\/|\=][^\&\s]*)/;
  67. #@clen = m/[^\/\=\&]?(clen[\/|\=][^\s\&\;]*)/;
  68. @range = m/[&?](range=[^\&\s]*)/;
  69. if (defined($range[0])) {
  70. $out="OK store-id=http://video-srv.youtube.anbel.SQUID/id=" . $id . "&@itag@range@mime";
  71. } else {
  72. $z = @slices ;
  73. $out="OK store-id=http://video-srv.youtube.anbel.SQUID/id=" . $id . "&@itag&@range=" . $z . "\n";
  74. }
  75. }
  76. } else {
  77. $out="ERR";
  78. }
  79. #?
  80. } elsif ($u=~ m/^https?\:\/\/(.*\/.*\?.*)/) {
  81. $out="OK store-id=http://" . $1;
  82.  
  83. } else {
  84. $out="ERR";
  85. }
  86. print "$chan $out\n";
  87. #stlog(); #menampilkan storeurl.log hanya out saja
  88. }
  89.  
  90. sub stlog {
  91. tie @array, 'Tie::File','/tmp/storeid.log';
  92. push @array, "$timenow out: $chan $out\n";
  93. untie @array;
  94. }
  95. close $logfh if ($debug);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement