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

30 lines
24 KiB
Plaintext
Raw Normal View History

2019-05-14 09:55:27 +03:00
b0VIM 7.4rc<72>\l<00>vrageeepcserver~vrag/perl/mediafire/lib/Mediafire/Api.pmutf-8 3210#"! U
2019-05-08 16:18:51 +03:00
<00>
<00>
<00>
<00>
<00>
`
_
A
&
2019-05-14 09:55:27 +03:00
<00> <00> <00> j C , "  <00><00><00>tsiS@'&<00>Z<00>vP<00>3<00><00><00><00><00><00><00>_<00><00><00>~DC-<00><00><00>yB<00><00><00><00>}I<00> 'content-type' => 'application/x-www-form-urlencoded', 'cache-control' => 'max-age=0', 'accept-language' => 'ru,en-US;q=0.9,en;q=0.8', my %headers = ( ); login_remember => 'on', login_pass => $self->{password}, login_email => $self->{login}, security => $security_value, my %param = ( my $url = 'https://www.mediafire.com/dynamic/client_login/mediafire.php'; my $ua = $self->{ua}; my ($res, $code); my $security_value = $self->$getLoginSecurityValue(); $self->$openMainPage(); $self->{password} = $opt{-password} // croak "You must specify '-password' param"; $self->{login} = $opt{-login} // croak "You must specify '-login' param"; my ($self, %opt) = @_;sub login {} return $self; }; 'accept-language' => 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', 'accept-encoding' => 'gzip, deflate, br', 'a $self->{ua}->default_header('accep $self->{ua}->default_header('accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'); ); cookie_jar => {}, agent => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36', $self->{ua} = LWP::UserAgent->new ( bless $self, $class; my $self = {}; my ($class) = @_;sub new {########################################################################################}; croak "Can't find tag with name 'securyty' or can't get value of tag"; } } return $1; if ($tag =~ /value="(.+?)"/) { my $tag = $1; if ($res->decoded_content =~ /<(input [^<>]*name="security".+?)>/) { } croak "Can't get login_security_value. Code: $code"; if ($code ne '200') { my $code = $res->code; my $res = $ua->get($url); my $url = 'https://www.mediafire.com/login/'; my $ua = $self->{ua}; my ($self) = @_;my $getLoginSecurityValue = sub {}; croak "Can't found session_token from response. Url: '$url'"; } return $1; if ($body =~ /token=(.+?)['&"]/) { my $body = $res->decoded_content; } croak "Can't get session_token by url: '$url'. Code: $code"; if ($code ne '200') { my $code = $res->code; my $res = $self->{ua}->get($url, %headers); ); 'upgrade-insecure-requests' => '1', 'referer' => 'https://www.mediafire.com/', my %headers = ( my $url = 'https://www.mediafire.com/apps/myfiles/?shared=0&multikeys=0'; my ($self) = @_;my $getSessionToken = sub {}; return 1; } croak "Wrong response code from url: '$url'. Code: $code"; if ($code ne '200') { my $code = $res->code; my $res = $self->{ua}->get($url); my $url = 'https://www.mediafire.com'; my ($self) = @_; # Open main page for set cookiesmy $openMainPage = sub {############################ PRIVATE METHODS ############################################our $VERSION = '0.01';use Data::Printer;use Mediafire::Api::UploadFile;use JSON::XS;use HTTP::Request;use File::Basename;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;ad<00>Y\<00>qE>=<00><00><00><00>b2 <00> <00> <00> <00> <00> <00> <00> <00> <00> y t N  <00> <00> <00> v = 6 5 <00> k P 6 <00>
2019-05-08 16:18:51 +03:00
<00>
<00>
<00>
<00>
<00>
<00>
G
A
@

2019-05-14 09:55:27 +03:00
<00> <00> <00> { # !  <00><00><00><00>i6/<00><00><00><00>]M'<00><00>mF<00><00><00><00>D<00><00><00>ra_ZY<00><00><00><00>_921<00><00><00>@<00><00><00><00>RQLK-,+
 <00><00><00><00>~}utlkFE?>! <00><00><00>_^Y====cutthe same terms as the Perl 5 programming language system itself.This is free software; you can redistribute it and/or modify it underThis software is copyright (c) 2019 by Pavel Andryushin.=head1 COPYRIGHT AND LICENSE=backPavel Andryushin <vrag867@gmail.com>=item *=over 4=head1 AUTHORSL<LWP::UserAgent>, L<JSON::XS>, L<URI::Escape>, L<Encode>, L<HTTP::Request>, L<Carp>, L<File::Basename>=head1 DEPENDENCE=head2 login(%opt)=head2 new()=head1 Upload Files to server pri=cut} p $json_res; my $json_res = decode_json($res->decoded_content); } croak "Can't create dir '$dirname'. Code: $code"; if ($code ne '200') { my $code = $res->code; my $res = $self->{ua}->get($url); $url . = '?' . join('&', map {"$_=" . uri_escape($param{$_})} keys %param); ); 'response_format' => 'json', 'session_token' => $self->{session_token}, 'parent_key' => '', 'foldername' => $dirname, 'r' => 'sloe', my %param = ( my $url = 'https://www.mediafire.com/api/1.4/folder/create.php'; my $dirname = $opt{-dirname} // croak "You must specify '-dirname' param"; my ($self, %opt) = @_;sub createDir {=pod Вынести в отдельный класс с проверкой наличия такой директории} return $mediafire_file; my $mediafire_file = $upload_file->uploadFile(%opt); ); -session_token => $self->{session_token}, -ua => $self->{ua}, my $upload_file = Mediafire::Api::UploadFile->new( $self->renewSessionToken(); my ($self, %opt) = @_;sub uploadFile {} croak "Wrong result from response for renewSessionToken. Result: $response_result"; } return 1; $self->{session_token} = $json_res->{response}->{session_token}; if ($response_result eq 'Success') { my $response_result = $json_res->{response}->{result}; } croak "Can't decode response to json: $res->decoded_content"; if ($@) { }; decode_json($res->decoded_content); my $json_res = eval { } croak "Can't renew session token by url: '$url'. Code: $code"; if ($code ne '200') { my $code = $res->code; my $res = $self->{ua}->get($url, %headers); my $url = 'https://www.mediafire.com/api/1.4/user/renew_session_token.php?r=jrko&session_token=' . $self->{session_token} . '&response_format=json'; ); 'x-requested-with' => 'XMLHttpRequest', 'referer' => 'https://www.mediafire.com/widgets/notifications.php?event_load=1', my %headers = ( } return 1; $self->{session_token} = $self->$getSessionToken(); if (not $self->{session_token}) { my ($self) = @_;sub renewSessionToken {} return 1; $self->renewSessionToken(); } croak "Can't login to mediafire.com"; if (not $cookie =~ /session=/) { # If logged in, server set 'session' cookie my $cookie = $res->header('set-cookie'); } croak "Wrong response code on login url: '$url'. Code: $code"; if ($code ne '200') { $code = $res->code; $res = $ua->post($url, \%param, %headers); ); 'upgrade-insecure-requests' => '1', 'referer' => 'https://www.mediafire.com/login/', 'origin' => 'https://www.mediafire.com',ad <00> <00>XWECB6<00>QP43<00> <00> <00> <00> <00> y x f . <00> <00> <00> <00> <00> t 2 <00> <00> R (
I<00><00><00><00><00><00><00><00><00><00><00>rq`_ON?:"!<00><00><00><00><00><00>[TS7<00> <00> <00> b 1 <00> <00> <00> t s n m O N M @ ? , +   <00> <00> <00> <00> <00> <00> <00> <00> h g a ` C B  <00>
<00>
<00>
{
r
=cutthe=cutthe same terms as the Perl 5 programming language system itself.This is free software; you can redistribute it and/or modify it underThis software is copyright (c) 2019 by Pavel Andryushin.=head1 COPYRIGHT AND LICENSE=backPavel Andryushin <vrag867@gmail.com>=item *=over 4=head1 AUTHORSL<LWP::UserAgent>, L<JSON::XS>, L<URI::Escape>, L<Encode>, L<HTTP::Request>, L<Carp>, L<File::Basename>=head1 DEPENDENCE=head2 login(%opt)=head2 new()=head1 Upload Files to server print "Uploaded file key: " . $mediafire_file->getDouploadKey() . "\n"; # Get uploaded file key ); -path => $remote_dir, -file => $filename, my $mediafire_file = $mediafire->uploadFile( # Upload file on server. Return Mediafire::Api::UploadFile object my $filename = '/tmp/test_file.zip'; # Full file path to upload my $remote_dir = 'myfiles'; # Directory name on server # Upload file to server ); -password => $password, -login => $login, $mediafire->login( # Login on service my $mediafire = Mediafire::Api->new(); # Create Mediafire::Api object use Mediafire::Api; =head1 METHODS=head1 SYNOPSYS version 0.01=head1 VERSIONB<Mediafire::Api> - Upload and Download files from mediafire.com file sharing=head1 NAME=encoding UTF-8=pod__END__1;