mirror of https://github.com/aria2/aria2
Add DownloadHandle::getBtMetaInfo() API
parent
b0b5e0df38
commit
5dcc2b7842
|
@ -590,6 +590,26 @@ struct RequestGroupDH : public DownloadHandle {
|
|||
}
|
||||
return createFileData(dctx->getFileEntries()[index-1], index, &bf);
|
||||
}
|
||||
virtual BtMetaInfoData getBtMetaInfo()
|
||||
{
|
||||
BtMetaInfoData res;
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
if(group->getDownloadContext()->hasAttribute(CTX_ATTR_BT)) {
|
||||
SharedHandle<TorrentAttribute> torrentAttrs =
|
||||
bittorrent::getTorrentAttrs(group->getDownloadContext());
|
||||
res.announceList = torrentAttrs->announceList;
|
||||
res.comment = torrentAttrs->comment;
|
||||
res.creationDate = torrentAttrs->creationDate;
|
||||
// TODO Use BtFileMode for torrentAttrs->mode
|
||||
res.mode = torrentAttrs->mode == "single" ?
|
||||
BT_FILE_MODE_SINGLE : BT_FILE_MODE_MULTI;
|
||||
if(!torrentAttrs->metadata.empty()) {
|
||||
res.name = torrentAttrs->name;
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_BITTORRENT
|
||||
return res;
|
||||
}
|
||||
SharedHandle<RequestGroup> group;
|
||||
TransferStat ts;
|
||||
};
|
||||
|
@ -687,6 +707,10 @@ struct DownloadResultDH : public DownloadHandle {
|
|||
dr->bitfield.size());
|
||||
return createFileData(dr->fileEntries[index-1], index, &bf);
|
||||
}
|
||||
virtual BtMetaInfoData getBtMetaInfo()
|
||||
{
|
||||
return BtMetaInfoData();
|
||||
}
|
||||
SharedHandle<DownloadResult> dr;
|
||||
};
|
||||
} // namespace
|
||||
|
|
|
@ -447,6 +447,55 @@ struct FileData {
|
|||
std::vector<UriData> uris;
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum
|
||||
*
|
||||
* BitTorrent file mode
|
||||
*/
|
||||
enum BtFileMode {
|
||||
/**
|
||||
* Indicating single file torrent
|
||||
*/
|
||||
BT_FILE_MODE_SINGLE,
|
||||
/**
|
||||
* Indicating multi file torrent
|
||||
*/
|
||||
BT_FILE_MODE_MULTI
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct
|
||||
*
|
||||
* BitTorrent metainfo data retrieved from ".torrent" file.
|
||||
*/
|
||||
struct BtMetaInfoData {
|
||||
/**
|
||||
* List of lists of announce URI. If ".torrent" file contains
|
||||
* ``announce`` and no ``announce-list``, ``announce`` is converted
|
||||
* to ``announce-list`` format.
|
||||
*/
|
||||
std::vector<std::vector<std::string> > announceList;
|
||||
/**
|
||||
* ``comment`` for the torrent. ``comment.utf-8`` is used if
|
||||
* available.
|
||||
*/
|
||||
std::string comment;
|
||||
/**
|
||||
* The creation time of the torrent. The value is an integer since
|
||||
* the Epoch, measured in seconds.
|
||||
*/
|
||||
time_t creationDate;
|
||||
/**
|
||||
* File mode of the torrent.
|
||||
*/
|
||||
BtFileMode mode;
|
||||
/**
|
||||
* ``name`` in ``info`` dictionary. ``name.utf-8`` is used if
|
||||
* available.
|
||||
*/
|
||||
std::string name;
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum
|
||||
*
|
||||
|
@ -579,6 +628,13 @@ public:
|
|||
* is out-of-bound.
|
||||
*/
|
||||
virtual FileData getFile(int index) = 0;
|
||||
/**
|
||||
* Returns the information retrieved from ".torrent" file. This
|
||||
* function is only meaningful only when BitTorrent transfer is
|
||||
* involved in the download and the download is not
|
||||
* stopped/completed.
|
||||
*/
|
||||
virtual BtMetaInfoData getBtMetaInfo() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue