Advertisement
suprianto

store-id yt

Nov 24th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # by : SJW
  3. # edited by suprianto_clg@yahoo.com
  4. # https://www.facebook.com/supri.anto.353
  5.  
  6. use LWP::Simple;
  7. use CGI qw/unescape/;
  8. #### var
  9. use IO::File;
  10. $|=1;
  11. $timenow="";
  12.  
  13. STDOUT->autoflush(1);
  14. $debug=1; ## recommended:0
  15. $bypassallrules=0; ## recommended:0
  16. $sucks=""; ## unused
  17. $sucks="sucks" if ($debug>=1);
  18. my $logfile = '/tmp/storeid.log';
  19. open my $logfh, '>>', $logfile
  20. or die "Couldn't open $logfile for appending: $!\n" if $debug;
  21. $logfh->autoflush(1) if $debug;
  22.  
  23. while (<>) {
  24. chop;
  25. my $myurl = $_;
  26. @X = split(" ",$myurl);
  27. $chan = $X[0]; ## channel id
  28. $url = $X[1]; ## url
  29. $ip = $X[2]; ## ip address
  30. $anbel = $url; ## url
  31.  
  32. #print $logfh "in : $_\n" if ($debug>=1);
  33.  
  34. if ($bypassallrules){
  35. $out="$anbel"; ## map 1:1
  36.  
  37. } 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]*).*/) {
  38. $vid = $5 ;
  39. @cpn = m/[&?]cpn\=([^\&\s]*)/;
  40. if (defined($vid )) {
  41. $fn = "/tmp/@cpn";
  42. unless (-e $fn ) {
  43. open FH,">".$fn ;
  44. print FH "$vid\n";
  45. close FH;
  46. }
  47. }
  48. $out = "ERR\n" ;
  49.  
  50. # youtube on iphone(apple-devices) and Black-Berry(BB) beta-1
  51. #} elsif ($anbel=~ m/^https?:\/\/.*\.c\.youtube\.com\/videoplayback\?id\=([^\&\s]*).*/) {
  52. # $out="OK store-id=http://mobilevideo/anbel.SQUID/" . $1;
  53.  
  54. # youtube on browser
  55. } elsif ($anbel =~ m/^https?\:\/\/.*(youtube|google).*videoplayback.*/) {
  56. @cpn = m/[^\/\&]?cpn[\/|\=]([^\&\s]*)/;
  57. if (defined($cpn[0])) {
  58. $fn = "/tmp/@cpn";
  59. if (-e $fn ) {
  60. open FH,"<".$fn ;
  61. $id = <FH>;
  62. chomp $id ;
  63. close FH;
  64.  
  65. @itag = m/[&?\/](itag[=\/]\d*)/;
  66. $itag[0] =~ s/\//\=/g;
  67. @ids = m/[\&?]id=([^\&\s]*)/;
  68. #@mime = m/[\/\&]?(mime[\/|\=][^\/\&\s\%]*)/;
  69. @slices = m/[\/?]slices\%3D\d\-\d+,([\d-\d]*)/;
  70. #@cver = m/[^\/\&]?(cver[\/|\=][^\&\s]*)/;
  71. #@clen = m/[^\/\=\&]?(clen[\/|\=][^\s\&\;]*)/;
  72. @range = m/[&?](range=[^\&\s]*)/;
  73. if (defined($range[0])) {
  74. $out="OK store-id=http://video-srv.youtube.anbel.SQUID/id=" . $id . "&@itag@range@mime";
  75. } elsif (m/[\&?]id=([^\&\s]*)/) {
  76. $out="OK store-id=http://video-static.youtube.anbel.SQUID/id=" . $ids . "@itag";
  77. } elsif (m/[\/?]slices\%3D\d\-\d+,([\d-\d]*)/) {
  78. $z = @slices ;
  79. $out="OK store-id=http://video-srv.youtube.anbel.SQUID/id=" . $id . "&@itag&@range=" . $z . "";
  80. }
  81. }
  82. } else {
  83. $out="ERR";
  84. }
  85.  
  86. } elsif ($anbel=~ m/^http:\/\/.*\.cnet\.com\/s\/(.*(exe|zip|dmg))\?/) {
  87. $out="OK store-id=http://file\.anbel.SQUID/" . $1;
  88.  
  89. #?
  90. } elsif ($anbel=~ m/^https?\:\/\/(.*\/.*\?.*)/) {
  91. $out="OK store-id=http://" . $1;
  92.  
  93. } else {
  94. $out="ERR";
  95. }
  96. print "$chan $out\n";
  97. #stlog(); #menampilkan storeurl.log hanya out saja
  98. }
  99.  
  100. sub stlog {
  101. tie @array, 'Tie::File','/tmp/storeid.log';
  102. push @array, "$timenow out: $chan $out\n";
  103. untie @array;
  104. }
  105. close $logfh if ($debug);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement