mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-31 00:44:19 +00:00
FEATURE: Added support for BitComet links (bc://bt/...)
This commit is contained in:
parent
7a2c0d5d5a
commit
3d4c1fe7da
@ -15,6 +15,7 @@
|
|||||||
- FEATURE: Torrents can be automatically paused once they reach a given ratio
|
- FEATURE: Torrents can be automatically paused once they reach a given ratio
|
||||||
- FEATURE: Several files can now be disabled at once
|
- FEATURE: Several files can now be disabled at once
|
||||||
- FEATURE: Added "Select All/None" buttons to files list
|
- FEATURE: Added "Select All/None" buttons to files list
|
||||||
|
- FEATURE: Added support for BitComet links (bc://bt/...)
|
||||||
- BUGFIX: Hide seeding torrents files priorities in Web UI
|
- BUGFIX: Hide seeding torrents files priorities in Web UI
|
||||||
- BUGFIX: The user can disable permanently recursive torrent download
|
- BUGFIX: The user can disable permanently recursive torrent download
|
||||||
- BUGFIX: Peer Exchange status is now correctly reported
|
- BUGFIX: Peer Exchange status is now correctly reported
|
||||||
|
14
src/GUI.cpp
14
src/GUI.cpp
@ -683,6 +683,10 @@ void GUI::dropEvent(QDropEvent *event) {
|
|||||||
BTSession->downloadFromUrl(file);
|
BTSession->downloadFromUrl(file);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(file.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||||||
|
qDebug("Converting bc link to magnet link");
|
||||||
|
file = misc::bcLinkToMagnet(file);
|
||||||
|
}
|
||||||
if(file.startsWith("magnet:", Qt::CaseInsensitive)) {
|
if(file.startsWith("magnet:", Qt::CaseInsensitive)) {
|
||||||
// FIXME: Possibly skipped torrent addition dialog
|
// FIXME: Possibly skipped torrent addition dialog
|
||||||
BTSession->addMagnetUri(file);
|
BTSession->addMagnetUri(file);
|
||||||
@ -756,6 +760,10 @@ void GUI::processParams(const QStringList& params) {
|
|||||||
if(param.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
|
if(param.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
|
||||||
BTSession->downloadFromUrl(param);
|
BTSession->downloadFromUrl(param);
|
||||||
}else{
|
}else{
|
||||||
|
if(param.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||||||
|
qDebug("Converting bc link to magnet link");
|
||||||
|
param = misc::bcLinkToMagnet(param);
|
||||||
|
}
|
||||||
if(param.startsWith("magnet:", Qt::CaseInsensitive)) {
|
if(param.startsWith("magnet:", Qt::CaseInsensitive)) {
|
||||||
if(useTorrentAdditionDialog) {
|
if(useTorrentAdditionDialog) {
|
||||||
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
|
||||||
@ -938,7 +946,11 @@ void GUI::showNotificationBaloon(QString title, QString msg) const {
|
|||||||
void GUI::downloadFromURLList(const QStringList& url_list) {
|
void GUI::downloadFromURLList(const QStringList& url_list) {
|
||||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
|
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
|
||||||
foreach(const QString& url, url_list) {
|
foreach(QString url, url_list) {
|
||||||
|
if(url.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||||||
|
qDebug("Converting bc link to magnet link");
|
||||||
|
url = misc::bcLinkToMagnet(url);
|
||||||
|
}
|
||||||
if(url.startsWith("magnet:", Qt::CaseInsensitive)) {
|
if(url.startsWith("magnet:", Qt::CaseInsensitive)) {
|
||||||
if(useTorrentAdditionDialog) {
|
if(useTorrentAdditionDialog) {
|
||||||
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this, BTSession);
|
||||||
|
@ -51,7 +51,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
|
|||||||
show();
|
show();
|
||||||
// Paste clipboard if there is an URL in it
|
// Paste clipboard if there is an URL in it
|
||||||
QString clip_txt = qApp->clipboard()->text();
|
QString clip_txt = qApp->clipboard()->text();
|
||||||
if(clip_txt.startsWith("http://", Qt::CaseInsensitive) || clip_txt.startsWith("https://", Qt::CaseInsensitive) || clip_txt.startsWith("ftp://", Qt::CaseInsensitive) || clip_txt.startsWith("magnet:", Qt::CaseInsensitive)) {
|
if(clip_txt.startsWith("http://", Qt::CaseInsensitive) || clip_txt.startsWith("https://", Qt::CaseInsensitive) || clip_txt.startsWith("ftp://", Qt::CaseInsensitive) || clip_txt.startsWith("magnet:", Qt::CaseInsensitive) || clip_txt.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||||||
textUrls->setText(clip_txt);
|
textUrls->setText(clip_txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,10 @@ public slots:
|
|||||||
if(param.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
|
if(param.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
|
||||||
BTSession->downloadFromUrl(param);
|
BTSession->downloadFromUrl(param);
|
||||||
}else{
|
}else{
|
||||||
|
if(param.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||||||
|
qDebug("Converting bc link to magnet link");
|
||||||
|
param = misc::bcLinkToMagnet(param);
|
||||||
|
}
|
||||||
if(param.startsWith("magnet:", Qt::CaseInsensitive)) {
|
if(param.startsWith("magnet:", Qt::CaseInsensitive)) {
|
||||||
BTSession->addMagnetUri(param);
|
BTSession->addMagnetUri(param);
|
||||||
} else {
|
} else {
|
||||||
|
@ -333,6 +333,10 @@ void HttpConnection::respondCommand(QString command)
|
|||||||
foreach(QString url, list){
|
foreach(QString url, list){
|
||||||
url = url.trimmed();
|
url = url.trimmed();
|
||||||
if(!url.isEmpty()){
|
if(!url.isEmpty()){
|
||||||
|
if(url.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||||||
|
qDebug("Converting bc link to magnet link");
|
||||||
|
url = misc::bcLinkToMagnet(url);
|
||||||
|
}
|
||||||
if(url.startsWith("magnet:", Qt::CaseInsensitive)) {
|
if(url.startsWith("magnet:", Qt::CaseInsensitive)) {
|
||||||
emit MagnetReadyToBeDownloaded(url);
|
emit MagnetReadyToBeDownloaded(url);
|
||||||
} else {
|
} else {
|
||||||
|
14
src/misc.cpp
14
src/misc.cpp
@ -475,6 +475,20 @@ bool misc::removeEmptyTree(QString path) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString misc::bcLinkToMagnet(QString bc_link) {
|
||||||
|
QByteArray raw_bc = bc_link.toUtf8();
|
||||||
|
raw_bc = raw_bc.mid(8); // skip bc://bt/
|
||||||
|
raw_bc = QByteArray::fromBase64(raw_bc); // Decode base64
|
||||||
|
// Format is now AA/url_encoded_filename/size_bytes/info_hash/ZZ
|
||||||
|
QStringList parts = QString(raw_bc).split("/");
|
||||||
|
if(parts.size() != 5) return QString::null;
|
||||||
|
QString filename = parts.at(1);
|
||||||
|
QString hash = parts.at(3);
|
||||||
|
QString magnet = "magnet:?xt=urn:btih:" + hash;
|
||||||
|
magnet += "&dn=" + filename;
|
||||||
|
return magnet;
|
||||||
|
}
|
||||||
|
|
||||||
QString misc::magnetUriToName(QString magnet_uri) {
|
QString misc::magnetUriToName(QString magnet_uri) {
|
||||||
QString name = "";
|
QString name = "";
|
||||||
QRegExp regHex("dn=([^&]+)");
|
QRegExp regHex("dn=([^&]+)");
|
||||||
|
@ -116,6 +116,7 @@ public:
|
|||||||
static bool removeEmptyTree(QString path);
|
static bool removeEmptyTree(QString path);
|
||||||
static QString magnetUriToName(QString magnet_uri);
|
static QString magnetUriToName(QString magnet_uri);
|
||||||
static QString magnetUriToHash(QString magnet_uri);
|
static QString magnetUriToHash(QString magnet_uri);
|
||||||
|
static QString bcLinkToMagnet(QString bc_link);
|
||||||
static QString boostTimeToQString(const boost::optional<boost::posix_time::ptime> boostDate);
|
static QString boostTimeToQString(const boost::optional<boost::posix_time::ptime> boostDate);
|
||||||
// Replace ~ in path
|
// Replace ~ in path
|
||||||
static QString expandPath(QString path);
|
static QString expandPath(QString path);
|
||||||
|
@ -403,6 +403,10 @@ void SearchEngine::saveResultsColumnsWidth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url) {
|
void SearchEngine::downloadTorrent(QString engine_url, QString torrent_url) {
|
||||||
|
if(torrent_url.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||||||
|
qDebug("Converting bc link to magnet link");
|
||||||
|
torrent_url = misc::bcLinkToMagnet(torrent_url);
|
||||||
|
}
|
||||||
if(torrent_url.startsWith("magnet:")) {
|
if(torrent_url.startsWith("magnet:")) {
|
||||||
QStringList urls;
|
QStringList urls;
|
||||||
urls << torrent_url;
|
urls << torrent_url;
|
||||||
|
@ -3,7 +3,7 @@ LANG_PATH = lang
|
|||||||
ICONS_PATH = Icons
|
ICONS_PATH = Icons
|
||||||
|
|
||||||
# Set the following variable to 1 to enable debug
|
# Set the following variable to 1 to enable debug
|
||||||
DEBUG_MODE = 0
|
DEBUG_MODE = 1
|
||||||
|
|
||||||
# Global
|
# Global
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
|
Loading…
x
Reference in New Issue
Block a user