PDA

View Full Version : Download file thru rapidshare API



raj_iv
12th April 2012, 08:16
Hi,

How to download a file thru rapidshare API as a free user. I am using 'sub=download' as specified in http://images.rapidshare.com/apidoc.txt API with fileid and filename but the first response that i am getting is completely empty.

A sample code will be of better help.

Spitfire
12th April 2012, 17:16
Can you still download files as unregistered user from RapidShare?
I thought they've disabled it after Megaupload takedown.

raj_iv
20th April 2012, 11:13
I think we can download file thru Rapidshare as normal registered user.
We don't need RapidPro user for tat.

wysota
20th April 2012, 11:41
Hi,

How to download a file thru rapidshare API as a free user. I am using 'sub=download' as specified in http://images.rapidshare.com/apidoc.txt API with fileid and filename but the first response that i am getting is completely empty.

A sample code will be of better help.

You are probably getting a redirection you should follow. What is the status code of the reply you get from the server?

raj_iv
20th April 2012, 12:40
yes i am getting redirection with status code 302
but after handling redirection i m not getting any further reply.
Please go thru following code what i m doing (manager is defined as QNetworkAccessManager manager; in class WebServiceManager):

WebServiceManager::WebServiceManager()
: QObject(0)
{
connect(&manager, SIGNAL(finished(QNetworkReply*)),
SLOT(downloadFinished(QNetworkReply*)));
}

void WebServiceManager::downloadFinished(QNetworkReply* reply)
{
if(reply->error() > 0)
{
qDebug() << reply->errorString();
}
else
{
int v = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute ).toInt();

if (v >= 200 && v < 300) // Success
{
... file download code
}
else if (v >= 300 && v < 400) // Redirection - i m getting into this block
{
// Get the redirection url
QUrl newUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttrib ute).toUrl();
// Because the redirection url can be relative,
// we have to use the previous one to resolve it
newUrl = reply->url().resolved(newUrl);

QString nurl = newUrl.toString();

QNetworkAccessManager *manager2 = reply->manager();
QNetworkRequest redirection(newUrl);
QNetworkReply *newReply = manager2->get(redirection);

return; // to keep the manager for the next request
}
}
reply->manager()->deleteLater();
reply = 0;
}

Am i doing something wrong for my code to work after redirection.

wysota
20th April 2012, 13:13
You certainly shouldn't be calling deleteLater on the manager, it will crash your application upon exit.

So basically you are not getting any response for your second request?

raj_iv
20th April 2012, 13:30
yes, i m not getting any response for second request.

wysota
20th April 2012, 13:39
Can you show us the url and set of headers set on the second request? You can retrieve them with QNetworkRequest::url() and QNetworkRequest::rawHeaderList() respectively. Also show us the set of headers you get from the reply redirecting you to the new url.

raj_iv
20th April 2012, 14:33
This is the Url i am getting on the second request:
https//rs504p10.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=1117xxxxxx&filename=CPlxxxx.txt

i am not getting any set of headers on second request, its empty...i m printing it with following code:

QList<QByteArray> reqHeaders = redirection.rawHeaderList();

foreach( QByteArray reqName, reqHeaders )
{
QByteArray reqValue = redirection.rawHeader( reqName );
qDebug() << reqName << ": " << reqValue;
}

Also, the header list from reply of second request is also empty.

wysota
20th April 2012, 14:42
I can hardly believe that. No content-length, no cookies, no nothing? Note that the api docs says free download always uses http whereas your url uses https.

raj_iv
20th April 2012, 14:58
My original url uses http but after redirection i am getting https url.

wysota
20th April 2012, 15:30
What is the original url?

raj_iv
21st April 2012, 10:52
This is original url:
http//api.rapidshare.com/cgi-bin/rsapi.cgi?sub=download&fileid=1117xxxxxx&filename= CPlxxxx.txt

raj_iv
29th May 2012, 08:20
Can anyone pls tell me y i m always redirected to url that begins with https whereas my original url starts with http. How to handle URLs that starts with https using QNetworkAccessmanager.

wysota
30th May 2012, 20:16
QNetworkAccessManager doesn't care if your URL is http or https based.

raj_iv
31st May 2012, 15:16
But with https URL the slot connected to finished() signal not getting fired. It may be my Qt is not configured with SSL support thus nothing happening beyond tat point in my code...its just hanged.

wysota
31st May 2012, 15:28
It may be the other end of your connection does something different than you expect. Or it may be a dozen of other things. Take a network sniffer and find out.