[Web UI] Add Web Seeds (HTTP Sources) tab

This commit is contained in:
ngosang
2015-06-12 17:52:01 +02:00
committed by sledgehammer999
parent 1c5e6980e8
commit 54a444d37f
10 changed files with 175 additions and 2 deletions

View File

@@ -111,6 +111,9 @@ static const char KEY_TRACKER_STATUS[] = "status";
static const char KEY_TRACKER_MSG[] = "msg";
static const char KEY_TRACKER_PEERS[] = "num_peers";
// Web seed keys
static const char KEY_WEBSEED_URL[] = "url";
// Torrent keys (Properties)
static const char KEY_PROP_SAVE_PATH[] = "save_path";
static const char KEY_PROP_CREATION_DATE[] = "creation_date";
@@ -395,6 +398,31 @@ QByteArray btjson::getTrackersForTorrent(const QString& hash)
return json::toJson(tracker_list);
}
/**
* Returns the web seeds for a torrent in JSON format.
*
* The return value is a JSON-formatted list of dictionaries.
* The dictionary keys are:
* - "url": Web seed URL
*/
QByteArray btjson::getWebSeedsForTorrent(const QString& hash)
{
CACHED_VARIABLE_FOR_HASH(QVariantList, webSeedList, CACHE_DURATION_MS, hash);
QTorrentHandle torrent = QBtSession::instance()->getTorrentHandle(hash);
if (!torrent.is_valid()) {
qWarning() << Q_FUNC_INFO << "Invalid torrent " << qPrintable(hash);
return QByteArray();
}
foreach (const QString &webseed, torrent.url_seeds()) {
QVariantMap webSeedDict;
webSeedDict[KEY_WEBSEED_URL] = webseed;
webSeedList.append(webSeedDict);
}
return json::toJson(webSeedList);
}
/**
* Returns the properties for a torrent in JSON format.
*