Advertisement
grage95

yusub storeurl

Oct 16th, 2013
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.15 KB | None | 0 0
  1. #!/usr/bin/perl
  2. #### Debug  Storeurl.pl ####
  3. use IO::File;
  4. $|=1;
  5. STDOUT->autoflush(1);
  6. $debug=1;        ## recommended:0
  7. $sucks="";        ## unused
  8. $sucks="sucks" if ($debug>=1);
  9. $timenow="";
  10. $ptimenow=1;      ## print timenow: 0|1
  11. my $logfile = '/tmp/storeurl.log';
  12. open my $logfh, '>>', $logfile
  13.     or die "Couldn't open $logfile check directory tmp: $!\n" if $debug;
  14. $logfh->autoflush(1) if $debug;
  15.  
  16. #### main function
  17. while (<>) {
  18. $timenow=time()." " if ($ptimenow);
  19. print $logfh "$timenow"."in : $_" if ($debug>=1);
  20. chop; ## strip eol
  21. @X = split;
  22. $x = $X[0]; ## 0
  23. $u = $X[1]; ## url
  24. $_ = $u; ## url
  25.  
  26. #ipcheck
  27. my $ipcheck = do { (my $tmp = $X[2]) =~ s/\///; $tmp };
  28. my $ipcheck = do { (my $tmp = $ipcheck) =~ s/-//; $tmp };
  29. $file = "/tmp/".$ipcheck;
  30.  
  31. if (m/.*\.youtube.*(ptracking|stream_204|player_204|gen_204).*(video_id|docid|v)\=([^\&\s]*).*/){
  32.         $out= $x[1];
  33.         put($3,$file);
  34.  
  35. #youtube dynamic id & old id
  36. } elsif (m/(youtube|google).*videoplayback\?/) {
  37.         @itag = m/[&?](itag=[0-9]*)/;
  38.         @id = m/[&?](id=[^\&]*)/;
  39.         @range = m/(&range=[^\&]*)/;
  40.         @mime = m/(&mime=[^\&]*)/;
  41.         @redirect = m/(&redirect_counter=[^\&]*)/;
  42.         if (m/[&?](id=o-[^\&\s]*)/)
  43.         {
  44.     #Dynamic ID
  45.         $v_id = &get($file);
  46.         $out="http://video-srv.youtube.com.SQUIDINTERNAL/@itag&id=".$v_id."@range@mime@redirect";
  47.         }
  48.         #Old ID
  49.         else{
  50.         $out="http://video-srv.youtube.com.SQUIDINTERNAL/@itag&@id@range@mime@redirect";
  51.     }
  52. } elsif (m/^http:\/\/i[0-9]?\.ytimg\.com\/(.*)/) {
  53.         $out="http://cdn.ytimg.com/$1";
  54.  
  55.  
  56. } else {
  57.     $out="$u";
  58. }
  59.  print $logfh "$timenow"."out: $x $out $X[2] $X[3] $X[4] $X[5] $X[6] $X[7]\n" if ($debug>=1);
  60.  print "$x $out $X[2] $X[3] $X[4] $X[5] $X[6] $X[7]\n";
  61. }
  62.  
  63.  
  64. ### sub function ###
  65. sub put {
  66.   my ($string, $files) = @_;
  67.   open FILE, '>'.$files;
  68.   print FILE $string;
  69.   close FILE;
  70.   }
  71.  
  72. sub get{
  73.   my $filename = $_[0];
  74.   open(INFO, $filename);
  75.   @lines = <INFO>;
  76.   close(INFO);
  77.   my $string = "";
  78.   foreach (@lines){
  79.   $string .= $_;
  80.   }
  81.    return $string;
  82.   }
  83. close $logfh if ($debug);
  84. ### end sub function ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement