Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #### Debug Storeurl.pl ####
- use IO::File;
- $|=1;
- STDOUT->autoflush(1);
- $debug=1; ## recommended:0
- $sucks=""; ## unused
- $sucks="sucks" if ($debug>=1);
- $timenow="";
- $ptimenow=1; ## print timenow: 0|1
- my $logfile = '/tmp/storeurl.log';
- open my $logfh, '>>', $logfile
- or die "Couldn't open $logfile check directory tmp: $!\n" if $debug;
- $logfh->autoflush(1) if $debug;
- #### main function
- while (<>) {
- $timenow=time()." " if ($ptimenow);
- print $logfh "$timenow"."in : $_" if ($debug>=1);
- chop; ## strip eol
- @X = split;
- $x = $X[0]; ## 0
- $u = $X[1]; ## url
- $_ = $u; ## url
- #ipcheck
- my $ipcheck = do { (my $tmp = $X[2]) =~ s/\///; $tmp };
- my $ipcheck = do { (my $tmp = $ipcheck) =~ s/-//; $tmp };
- $file = "/tmp/".$ipcheck;
- if (m/.*\.youtube.*(ptracking|stream_204|player_204|gen_204).*(video_id|docid|v)\=([^\&\s]*).*/){
- $out= $x[1];
- put($3,$file);
- #youtube dynamic id & old id
- } elsif (m/(youtube|google).*videoplayback\?/) {
- @itag = m/[&?](itag=[0-9]*)/;
- @id = m/[&?](id=[^\&]*)/;
- @range = m/(&range=[^\&]*)/;
- @mime = m/(&mime=[^\&]*)/;
- @redirect = m/(&redirect_counter=[^\&]*)/;
- if (m/[&?](id=o-[^\&\s]*)/)
- {
- #Dynamic ID
- $v_id = &get($file);
- $out="http://video-srv.youtube.com.SQUIDINTERNAL/@itag&id=".$v_id."@range@mime@redirect";
- }
- #Old ID
- else{
- $out="http://video-srv.youtube.com.SQUIDINTERNAL/@itag&@id@range@mime@redirect";
- }
- } elsif (m/^http:\/\/i[0-9]?\.ytimg\.com\/(.*)/) {
- $out="http://cdn.ytimg.com/$1";
- } else {
- $out="$u";
- }
- print $logfh "$timenow"."out: $x $out $X[2] $X[3] $X[4] $X[5] $X[6] $X[7]\n" if ($debug>=1);
- print "$x $out $X[2] $X[3] $X[4] $X[5] $X[6] $X[7]\n";
- }
- ### sub function ###
- sub put {
- my ($string, $files) = @_;
- open FILE, '>'.$files;
- print FILE $string;
- close FILE;
- }
- sub get{
- my $filename = $_[0];
- open(INFO, $filename);
- @lines = <INFO>;
- close(INFO);
- my $string = "";
- foreach (@lines){
- $string .= $_;
- }
- return $string;
- }
- close $logfh if ($debug);
- ### end sub function ###
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement