Advertisement
albspirit86

working store-id.pl

Jul 8th, 2014
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.99 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # CONTENT OF STORE-ID
  3. # final working store-id http-https youtube
  4. # squid.conf http://pastebin.com/YrBPzaDs
  5. # send link from youtube contain >> (ptracking|stream_204|player_204|gen_204) to storeurl
  6.  
  7.  
  8. $|=1;
  9. while (<>) {
  10. @X = split;
  11.  
  12. if ( $X[0] =~ m/^http\:\/\/.*/) {
  13. $x = $X[0];
  14. $_ = $X[0];
  15. $u = $X[0];
  16. } else {
  17. $x = $X[1];
  18. $_ = $X[1];
  19. $u = $X[1];
  20. }
  21.  
  22. if ($x =~ m/^http(|s)\:\/\/.*youtube.*(ptracking|stream_204|player_204|gen_204).*(video_id|docid|v)\=([^\&\s]*).*/){
  23. $vid = $4 ;
  24. @cpn = m/[&?]cpn\=([^\&\s]*)/;
  25. $fn = "/var/log/squid/@cpn";
  26. unless (-e $fn) {
  27. open FH,">".$fn ;
  28. print FH "$vid\n";
  29. close FH;
  30. }
  31. $out = $x ;
  32.  
  33. } elsif ($x =~ m/^http(|s)\:\/\/.*(youtube|google).*videoplayback.*/){
  34. @itag = m/[&?](itag=[0-9]*)/;
  35. @ids = m/[&?]id\=([^\&\s]*)/;
  36. @mime = m/[&?](mime\=[^\&\s]*)/;
  37. @cpn = m/[&?]cpn\=([^\&\s]*)/;
  38. $fn = "/var/log/squid/@cpn";
  39. if (-e $fn) {
  40. open FH,"<".$fn ;
  41. $id = <FH>;
  42. chomp $id ;
  43. close FH ;
  44. } else {
  45. $id = $ids[0] ;
  46. }
  47. @range = m/[&?](range=[^\&\s]*)/;
  48. $out = "http://video-srv.youtube.com.SQUIDINTERNAL/id=" . $id . "&@itag@range@mime";
  49.  
  50. #} elsif ($x =~ m/^https?:\/\/.*\.akamaihd\.net\/((hphotos|hprofile|hvthumb|hvideo)(-ak-|-)(frc|snc|ash|prn)[0-9])?.*\/(.*)/) {
  51. #$out="http://fbcdn.net.squid.internal/" . $2 . $3 . $6 ;
  52.  
  53.  
  54. #} elsif ($x =~ m/^https?:\/\/[\w\d\-\.\%]*fbcdn[\w\d\-\.\%]*net\/safe\_image\.php\?(.*)/) {
  55. #$out="http://fbcdn.net.squid.internal/" . $1 . "/" . $2 . "/" . $3 ;
  56.  
  57. #} elsif ($x =~ m/^https?:\/\/[\w\d\-\.\%]*fbcdn[\w\d\-\.\%]*net\/rsrc\.php\/(.*)/) {
  58. #$out="http://fbcdn.net.squid.internal/" . $1 . "/" . $2 . "/" . $3 ;
  59.  
  60. #} elsif ($x =~ m/^https?:\/\/[\w\d\-\.\%]*fbcdn[\w\d\-\.\%]*net\/[\w\d\-\.\%]*\/(.*)/) {
  61. #$out="http://fbcdn.net.squid.internal/" . $1 . "/" . $2 . "/" . $3 ;
  62.  
  63. #} elsif ($x =~ m/^https?:\/\/[\w\d\-\.\%]*akamaihd[\w\d\-\.\%]*net\/[\w\d\-\.\%]*\/(.*)/) {
  64. #$out="http://fbcdn.net.squid.internal/" . $1 . "/" . $2 . "/" . $3 ;
  65.  
  66. } elsif ($x =~ m/^https?:\/\/[\w\d\-\.\%]*fbcdn[\w\d\-\.\%]*net\/safe\_image\.php\?(.*)/) {
  67. $out="http://fbcdn.net.squid.internal/" . $1 ;
  68.  
  69. } elsif ($x =~ m/^https?:\/\/[\w\d\-\.\%]*fbcdn[\w\d\-\.\%]*net\/rsrc\.php\/(.*)/) {
  70. $out="http://fbcdn.net.squid.internal/" . $1 ;
  71.  
  72. } elsif ($x =~ m/^https?:\/\/[\w\d\-\.\%]*fbcdn[\w\d\-\.\%]*net\/[\w\d\-\.\%]*\/(.*)/) {
  73. $out="http://fbcdn.net.squid.internal/" . $1 ;
  74.  
  75. } elsif ($x =~ m/^https?:\/\/[\w\d\-\.\%]*akamaihd[\w\d\-\.\%]*net\/[\w\d\-\.\%]*\/(.*)/) {
  76. $out="http://fbcdn.net.squid.internal/" . $1 ;
  77.  
  78.  
  79. #googlechrome
  80. } elsif ($x =~ m/^http:\/\/[\d\w\-]+\.c\.pack\.google\.com\/.*\/(.*?\.exe)\?.*/) {
  81. $out="http://googlechrome.squid.internal/" . $1 ;
  82.  
  83. } elsif ($x =~ m/^http:\/\/[\d\w\-]+\.c\.pack\.google\.com\/.*\/.*\/(.*?\.crx)\?.*/) {
  84. $out="http://googlechrome.squid.internal/" . $1 ;
  85.  
  86.  
  87. } elsif ($x =~ m/^http:\/\/i[1-4]\.ytimg\.com\/(.*)/) {
  88. $out="http://ytimg.com.squid.internal/" . $1 ;
  89.  
  90. } elsif ($x =~ m/^http:\/\/.*\.dl\.sourceforge\.net\/(.*)/) {
  91. $out="http://dl.sourceforge.net.squid.internal/" . $1 ;
  92.  
  93. #Speedtest
  94. } elsif ($x =~ m/^http\:\/\/.*\/speedtest\/(.*\.(jpg|txt)).*/) {
  95. $out="http://speedtest.squid.internal/" . $1 ;
  96.  
  97. #reverbnation
  98. } elsif ($x =~ m/^http:\/\/c2lo\.(reverbnation)\.com\/(audio)_player\/.*\/(.*)[\/\?]/) {
  99. $out = "http://reverbnation.squid.internal/" . $1 . "/" . $2 . "/" . $3 ;
  100.  
  101.  
  102. #BLOGSPOT
  103. } elsif ($x =~ m/^http:\/\/[1-4]\.bp\.(blogspot\.com.*)/) {
  104. $out="http://blog-cdn." . $1 ;
  105.  
  106. #AVAST
  107. } elsif ($x =~ m/^http:\/\/download[0-9]{3}.(avast.com.*)/) {
  108. $out="http://avast-cdn." . $1 ;
  109.  
  110. #AVAST
  111. } elsif ($x =~ m/^http:\/\/[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\/(iavs.*)/) {
  112. $out="http://avast-cdn.avast.com/" . $1 ;
  113.  
  114. #KAV
  115. } elsif ($x =~ m/^http:\/\/dnl-[0-9]{2}.(geo.kaspersky.com.*)/) {
  116. $out="http://kav-cdn." . $1 ;
  117.  
  118. #AVG
  119. } elsif ($x =~ m/^http:\/\/update.avg.com/) {
  120. $out="http://avg-cdn." . $1 ;
  121.  
  122. #maps.google.com
  123. } elsif ($x =~ m/^http:\/\/(cbk|mt|kh|mlt|tbn)[0-9]?(.google\.co(m|\.uk|\.id).*)/) {
  124. $out="http://" . $1 . $2 ;
  125.  
  126.  
  127. #maps.google.com
  128. } elsif ($x =~ m/^http:\/\/(kh|mt)[0-9]?(.google.com.*)/) {
  129. $out="http://" . $1 . $2 ;
  130.  
  131. #Google
  132. } elsif ($x =~ m/^http:\/\/(.*\.google-analytics\.com)\/(__utm\.gif)\?.*/) {
  133. $out="http://google-analytics.com.squid.internal/" . $1 . $2 ;
  134.  
  135.  
  136. } elsif ($x =~ m/^http:\/\/(www\.ziddu\.com.*\.[^\/]{3,4})\/(.*?)/) {
  137. $out="http://" . $1 ;
  138.  
  139. #cdn, varialble 1st path
  140. } elsif (($x =~ /filehippo/) && (m/^http:\/\/(.*?)\.(.*?)\/(.*?)\/(.*)\.([a-z0-9]{3,4})(\?.*)?/)) {
  141. @y = ($1,$2,$4,$5);
  142. $y[0] =~ s/[a-z0-9]{2,5}/cdn./;
  143. $out="http://" . $y[0] . $y[1] . "/" . $y[2] . "." . $y[3] ;
  144.  
  145. #rapidshare
  146. } elsif (($x =~ /rapidshare/) && (m/^http:\/\/(([A-Za-z]+[0-9-.]+)*?)([a-z]*\.[^\/]{3}\/[a-z]*\/[0-9]*)\/(.*?)\/([^\/\?\&]{4,})$/)) {
  147. $out="http://cdn." . $3 . "/squid.internal/" . $5 ;
  148.  
  149.  
  150. #domain/path/.*/path/filename
  151. } elsif (($X[1] =~ /fucktube/) && (m/^http:\/\/(.*?)(\.[^\.\-]*?[^\/]*\/[^\/]*)\/(.*)\/([^\/]*)\/([^\/\?\&]*)\.([^\/\?\&]{3,4})(\?.*?)$/)) {
  152. @y = ($1,$2,$4,$5,$6);
  153. $y[0] =~ s/(([a-zA-A]+[0-9]+(-[a-zA-Z])?$)|([^\.]*cdn[^\.]*)|([^\.]*cache[^\.]*))/cdn/;
  154. $out="http://" . $y[0] . $y[1] . "/" . $y[2] . "/" . $y[3] . "." . $y[4] ;
  155.  
  156. #youjizz. We use only domain and filename
  157. } elsif (($X[1] =~ /media[0-9]{1,5}\.youjizz/) && (m/^http:\/\/(.*?)(\.[^\.\-]*?\.[^\/]*)\/(.*)\/([^\/\?\&]*)\.([^\/\?\&]{3,4})(\?.*?)$/)) {
  158. @y = ($1,$2,$4,$5);
  159. $y[0] =~ s/(([a-zA-A]+[0-9]+(-[a-zA-Z])?$)|([^\.]*cdn[^\.]*)|([^\.]*cache[^\.]*))/cdn/;
  160. $out="http://" . $y[0] . $y[1] . "/" . $y[2] . "." . $y[3] ;
  161.  
  162. #general purpose for cdn servers. add above your specific servers.
  163. #} elsif (m/^http:\/\/([0-9.]*?)\/\/(.*?)\.(.*)\?(.*?)/) {
  164. #$out="http://squid-cdn-url/" . $2 . "." . $3 ;
  165.  
  166. #generic http://variable.domain.com/path/filename."ex", "ext" or "exte"
  167. #http://cdn1-28.projectplaylist.com
  168. #http://s1sdlod041.bcst.cdn.s1s.yimg.com
  169. } elsif (m/^http:\/\/(.*?)(\.[^\.\-]*?\..*?)\/([^\?\&\=]*)\.([\w\d]{2,4})\??.*$/) {
  170. @y = ($1,$2,$3,$4);
  171. $y[0] =~ s/([a-z][0-9][a-z]dlod[\d]{3})|((cache|cdn)[-\d]*)|([a-zA-A]+-?[0-9]+(-[a-zA-Z]*)?)/cdn/;
  172. $out="http://" . $y[0] . $y[1] . "/" . $y[2] . "." . $y[3] ;
  173.  
  174.  
  175. #for yimg.com video
  176. } elsif ($x =~ m/^http:\/\/(.*yimg.com)\/\/(.*)\/([^\/\?\&]*\/[^\/\?\&]*\.[^\/\?\&]{3,4})(\?.*)?$/) {
  177. $out="http://cdn.yimg.com/" . $3 ;
  178.  
  179. #for yimg.com doubled
  180. } elsif ($x =~ m/^http:\/\/(.*?)\.yimg\.com\/(.*?)\.yimg\.com\/(.*?)\?(.*)/) {
  181. $out="http://cdn.yimg.com/" . $3 ;
  182.  
  183. #for yimg.com with &sig=
  184. } elsif ($x =~ m/^http:\/\/([^\.]*)\.yimg\.com\/(.*)/) {
  185. @y = ($1,$2);
  186. $y[0] =~ s/[a-z]+([0-9]+)?/cdn/;
  187. $y[1] =~ s/&sig=.*//;
  188. $out="http://" . $y[0] . ".yimg.com/" . $y[1] ;
  189.  
  190. # all that ends with ;
  191. } elsif (m/^http:\/\/(.*?)\/(.*?)\;(.*)/) {
  192. $out="http://" . $1 . "/" . $2 ;
  193.  
  194.  
  195. } else {
  196. $out=$x;
  197.  
  198. }
  199. if ( $X[0] =~ m/^http\:\/\/.*/) {
  200. print "OK store-id=$out\n" ;
  201. } else {
  202. print $X[0] . " OK store-id=$out\n" ;
  203. }
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement