[SOLVED]Can download via web browser but got forbidden error if trying with my Qt code.
I am trying to make downloader and one of things that it should download are videos from youtube. I found out how to get exact download link to download YT video, it looks like this :
I tried it in web browser and it asked me if want play in vlc or save, ok I saved it, got video downloaded, everything seems good. But in my code I send get request and reply from server is: Error downloading (url) - server replied: Forbidden. I am not sure if problem is in my code only if I have to make custom request but I have no idea what to put there...
QString st = FileList.at(fileIndex[b]);
reply=nam.get(QNetworkRequest(QUrl(urls4Download.at(b)))); //actually only one url in list, the one from above
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
Thanks anyone who can help me.
Were you able to get/output any errors?
Anyways, some websites doesn't respond unless you set a "User Agent". I once encountered google ignoring simple search. But I was able to solve it by adding something like this:
Ya you must set user agent to avoid problems :)
I found out my problem was with , chars parts in link, they were translated into "," as I posted it here and in browser too, after longer time I found there was my problem. But thanks anyway this user-agent header may help me later :)