But in our enthusiasm, we could not resist a radical overhaul of the system, in which all of its major weaknesses have been exposed, analyzed, and replaced with new weaknesses.
Hello,
I am working on creating the same script for other sites (DailyMotion, MySpace, Metacafe, etc) but I got stuck on the DailyMotion script.
I've tried creating this script also in Java and I get the exactly same error (Error 500: Connection reset).
Here is the perl version of the dailymotion upload script. I've tried to figure out for more than 12 hours what is the problem but I couldn't figure out.
Any help would be highly appreaciated.
#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use Getopt::Std;
use Net::SSLeay;
use Data::Dumper;
use HTML::Entities;
$Getopt::Std::STANDARD_HELP_VERSION = 1;
# various urls
my $login_url = 'http://www.dailymotion.com/login';
my $upload_url = 'http://www.dailymotion.com/xupload';
# create the user agent, have it store cookies and
# pretend to be an even cooler Linux firefox browser
my $ua = LWP::UserAgent->new(
cookie_jar => {},
agent => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4'
);
# let the user agent follow redirects after a POST request
push @{$ua->requests_redirectable}, 'POST';
print "Logging in to DailyMotion…\n";
login();
print "Uploading the video…\n";
upload();
print "Done!\n";
sub login {
# submit the login form
my $res = $ua->post($login_url,
{
username => "dmtesting",
password => "dmtesting",
login_submit => "Login",
form_name => "dm_pageitem_login"
}
);
unless ($res->is_success){
die "Failed logging in: failed submitting login form: ",
$res->status_line;
}
# We have no good way to check if we really logged in.
# I found that when you have logged in the upper right menu changes
# and you have access to ‘Log Out’ option.
# We check for this string to see if we have logged in.
unless ($res->content =~ /logout/){
die $res->content;
die "Failed logging in: username/password incorrect";
}
}
sub upload {
# upload is actually a two step process, first we set the video info,
# and then we post the actual video file
#
my $resp = $ua->get($upload_url);
unless ($resp->is_success) {
die "Failed getting $upload_url: ", $resp->status_line;
}
my $form_action = extract_form_action($resp->content);
unless (defined $form_action) {
die "Failed extracting form action, DailyMotion might have redesigned!";
}
#print $form_action;
# let’s prepare the video field hash which we will need in both steps
my %vid_fields = (
file => [ "testmovie.avi" ],
send => "Upload"
);
$resp = upload_step_one(\%vid_fields, $form_action);
}
sub extract_form_action {
my $content = shift;
if ($content =~ m{}) {
return $1;
}
return;
}
sub upload_step_one {
my ($vid_fields, $action_url) = @_;
my $resp = $ua->post($action_url, $vid_fields,
"Content_Type" => "form-data");
unless ($resp->is_success) {
die "First upload step failed: ", $resp->status_line;
}
return $resp;
}
PS: I'll post all the upload scripts here after I'll finish with them.
Reply To This Comment
About the site:
Peter Krumins' blog about programming, hacking, software reuse, software ideas, computer security, browserling, google and technology.
Hello,
I am working on creating the same script for other sites (DailyMotion, MySpace, Metacafe, etc) but I got stuck on the DailyMotion script.
I've tried creating this script also in Java and I get the exactly same error (Error 500: Connection reset).
Here is the perl version of the dailymotion upload script. I've tried to figure out for more than 12 hours what is the problem but I couldn't figure out.
Any help would be highly appreaciated.
PS: I'll post all the upload scripts here after I'll finish with them.
Reply To This Comment