- Use torrent addition dialog for Magnet URIs too

This commit is contained in:
Christophe Dumez 2010-01-03 14:20:31 +00:00
parent a1dd724220
commit ba0c7334b7
5 changed files with 132 additions and 43 deletions

View file

@ -41,6 +41,7 @@
#include <QList>
#include <QPair>
#include <QThread>
#include <QUrl>
#include <ctime>
#include <QDateTime>
#include <boost/date_time/posix_time/posix_time_types.hpp>
@ -435,6 +436,18 @@ public:
return false;
}
static QString magnetUriToName(QString magnet_uri) {
QString name = "";
QRegExp regHex("dn=([^&]+)");
int pos = regHex.indexIn(magnet_uri);
if(pos > -1) {
QString found = regHex.cap(1);
// URL decode
name = QUrl::fromPercentEncoding(found.toLocal8Bit()).replace("+", " ");
}
return name;
}
static QString magnetUriToHash(QString magnet_uri) {
QString hash = "";
QRegExp regHex("urn:btih:([0-9A-Za-z]+)");