Files
Mediafire-Api/lib/Mediafire/Api/.UploadFile.pm.swp

29 lines
28 KiB
Plaintext
Raw Normal View History

2019-05-08 16:18:51 +03:00
b0VIM 7.4<00><><EFBFBD>\<5C><00>Ivrageeepcserver~vrag/perl/mediafire/lib/Mediafire/Api/UploadFile.pmutf-8 3210#"! U
<00>
<00>
<00>
`
4
<00> <00> ~ x ^ 2 +  <00><00><00><00><00>[,&%<00><00><00><00><00><00><<00><00><00><00><00><00><00><00>K9<00><00><00><00><00>y><00>]#<00><00><00>tL<00><00>TSx<00><00><00><00><00><00><00><00>f610<00><00><00>. my $ my $param_str = join('&', map {"$_=" . uri_escape($param{$_})} keys %param); ); 'response_format 'A 'Accept-Lang 'A 'Accept-Lang 'A 'Accept-Lang 'A 'A 'A 'A 'A 'A 'Accept-Language' 'Accept-Language' => 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', 'Accept-Encoding' => 'gzip, deflate, br', 'Accept' => '*/*', 'Access-Control-Request-Headers' => 'content-type,x-filehash,x-filename,x-filesize,x-filetype,x-unit-hash,x-unit-id,x-unit-size', 'Origin' => 'https://www.mediafire.com', 'Access-Control-Request-Method' => 'POST', my $headers = [ ); 'response_format' => 'json', 'uploadkey' => $self->{path}, 'session_token' => $self->{session_token}, my %param = ( my $url = 'https://ul.mediafireuserupload.com/api/1.5/upload/resumable.php'; my $ua = $self->{ua}; my ($self) = @_;my $checkResumeUpload = sub {}; return 1; $self->{upload_url} = $response->{upload_url}->{resumable}; $self->{preemptive_quickkey} = $response->{preemptive_quickkey}; p $response; } croak "Can't checkUploadFile. Storage limit exceeded"; if ($response->{storage_limit_exceeded} ne 'no') { # Limit exceeded } croak "checkUploadFile() not success"; if ($response->{result} ne 'Success') { my $response = $json_res->{response}; # Get json response } croak "Can't parse respone '" . $res->decoded_content . "' to json"; if ($@) { }; decode_json($res->decoded_content); my $json_res = eval { } croak "Wrong response code checkUploadFile(). Url: '$full_url'. Code: $code"; if ($code ne '200') { my $code = $res->code; my $res = $self->{ua}->get($full_url); my $full_url = $url . '?' . $param_str; my $param_str = join('&', map {"$_=" . uri_escape($param{$_})} keys %param); ); $microseconds => '', 'response_format' => 'json', 'session_token' => $self->{session_token}, 'folder_key' => $self->{path}, 'preemptive' => 'yes', 'resumable' => 'yes', 'unit_size' => $self->{buff_size}, 'filename' => $self->{basename}, 'size' => $self->{file_size}, 'hash' => $self->{file_hash}, my %param = ( my $microseconds = substr(join('', @sec), 0, 13); my @sec = gettimeofday(); my $url = 'https://www.mediafire.com/api/1.5/upload/check.php'; my ($self) = @_;my $checkUploadFile = sub {}; return $sha->hexdigest; $sha->addfile($fname); my $sha = Crypt::Digest::SHA256->new(); my ($fname) = @_;my $getSha256Sum = sub {############################ PRIVATE METHODS ############################################my $DEFAULT_BUFF_SIZE = 1048576;our $VERSION = '0.01';use Data::Printer;use IO::Socket::SSL;use Time::HiRes qw/gettimeofday/;use Crypt::Digest::SHA256 qw/sha256_hex/;use JSON::XS;use HTTP::Request;use File::Basename;use LWP::ConnCache;use LWP::UserAgent;use URI::Escape;use Carp qw/croak carp/;use open qw(:std :utf8);use warnings;use strict;use utf8;use 5.008001;package Mediafire::Api::UploadFile;ad<00>" <00><00><00>cB+)('&%"
b %<00><00><00><00>}$  <00><00><00><00><00>w<00> L 3 !   <00> <00> w 9 8 7  <00> <00> <00> <00> b e M % $  <00>
<00>
<00>
<00>
<00>
q
]
I
2

<00> <00> g 5 <00><00><00>,<00><00><00>M<00><00><00><00><00><00><00><00>jK!  <00><00><00><00><00>o^M  $ $self->{file_hash} = $getSha256Sum->($self-> $self->{file_ $self->{file_ $self->{file_hash} = $getSha256Sum->($self->{ $self->{file_hash} $s $self->{file_hash} $self->{file_hash} = $g $self->{file_has $self->{file_hash} = $getSha2 $self->{file_hash} $self->{file_hash} = $getSha256 $self->{file_hash} = $getS $s $self->{ $ $self->{file_hash} = $getS $self->{file_hash} = $getSha256Sum->($self->{upload_file}); # G $self->{file_hash} = $getSha256Sum->($self->{uplo $self->{file_hash} = $getSha256S $self->{file_hash} = $getSha256Sum->( $self->{file_hash} = $getSha256Sum->($self->{upload_f $self->{file_hash} = $getSha256Sum->($self->{upload_file}); # Get all in $self->{file_hash} = $getSha256Sum->($self->{upl $self->{file_hash} = $getSha256Sum->($self->{ $self->{file_hash} = $getSha256Sum->($self-> $self->{file_hash} = $getSha256Sum->( $self->{file_hash} = $getSha256Sum->($self->{ $self->{file_hash} = $getSha256Sum->($ $self->{file_hash} = $getSha256Sum $self->{file_hash} = $getSha256Sum $self->{file_hash} $self->{file_has $self->{file_has $self->{file_hash} = $self->{file_hash} = $getSha2 $self- $self->{file_hash} $self->{file_hash} $self->{file_hash} $self->{file_hash} = $getSh $self->{file_hash $self->{file_hash} = $getSha256Sum->($self->{upload_file}); # Get all info about file } croak "File '" . $self->{upload_file} . "' not exists"; if (not -f $self->{upload_file}) { $self->{path} = $opt{'-path'} || 'myfiles'; $self->{upload_file} = $opt{'-file'} || croak "You must specify -file param for method uploadFile"; my ($self, %opt) = @_;sub uploadFile {} return $self; bless $self, $class; $self->{buff_size} = $opt{-buff_zize} // $DEFAULT_BUFF_SIZE; $self->{session_token} = $opt{-session_token} // croak "You must specify '-session_token' param"; $self->{ua} = $opt{-ua} // croak "You must specify param '-ua' for method new"; my $self = {}; my ($class, %opt) = @_;sub new {########################################################################################}; return 1; } croak "Not all parts of file '$upload_file' uploaded. Wrong answer from server"; if ($json_res->{response}->{resumable_upload}->{all_units_ready} ne 'yes') { # Check all units ready close $FH; }ad<00>2<00><00><00><00>jYXF<00><00><00>I<00> <00> J  <00> <00> w H  <00> <00> <00> w X : <00>
<00>
<00>
<00>
<00>
<00>
v


<00> <00> <00> <00> n   <00><00><00><00><00><00><00><00><00>K <00><00>\W?<00><00><00><00><00><00><00>rG "User-Agent "User-Agent: " . $s "Us "User "User-Agen "U "U "U "User-Agent: " . "User-Agent: " . $self->{ua}->agent, "User-Agent: " . $self->{ua}->agent, "User-Agent: " . $self->{ua}->agent, "User-Agent: " . $self->{ua}->agent, "User ++$u ++$unit_id; } last; if ($json_res->{response}->{resumable_upload}->{all_units_ready} eq 'yes') { # Check all units ready } croak "Response on url '$url' not success"; if ($json_res->{response}->{result} ne 'Success') { } croak "Can't decode response to json. Response: '" . $res->decoded_content . "'"; if ($@) { }; decode_json($res->decoded_content); $json_res = eval { } croak "Wrong response code on request to url '$url'. Code: '$code'"; if ($code ne '200') { my $code = $res->code; my $res = $self->{ua}->post($url, @headers); ); "Content" => $filebuf, "X-Unit-Id" => $unit_id, "X-Unit-Size" => $bytes, "X-Unit-Hash" => $unit_hash, "X-Filehash" => $self->{file_hash}, "X-Filetype" => $file_type, "X-Filename" => $self->{basename}, "X-Filesize" => $self->{file_size}, "Origin" => "https://www.mediafire.com", "Referer" => "https://www.mediafire.com/uploads", "Content-Type" => "application/octet-stream", "Accept-Encoding" => "gzip, deflate, br", "Accept-Language" => "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7", "Accept" => "*/*", my @headers = ( my $unit_hash = sha256_hex($filebuf); while (my $bytes = read($FH, $filebuf, $self->{buff_size})) { my $json_res; binmode $FH; open my $FH, "<$upload_file" or croak "Can't open $upload_file $!"; my $filebuf; my $unit_id = 0; my $file_type = 'application/zip';adR <00> <00><00>|6<00><00><00><00><00><00>|{mYDC<00> <00> h a  <00> <00> <00> <00> <00> o 4 - <00> <00> <00> <00>