mirror of https://github.com/aria2/aria2
2008-12-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Print the contents of Torrent/Metalink files are printed without -T/-M options. * src/main.ccpull/1/head
parent
c3a4b82e87
commit
65ebe6918a
|
@ -1,3 +1,9 @@
|
||||||
|
2008-12-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Print the contents of Torrent/Metalink files are printed without
|
||||||
|
-T/-M options.
|
||||||
|
* src/main.cc
|
||||||
|
|
||||||
2008-12-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2008-12-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Escaped '--' with '\--'
|
Escaped '--' with '\--'
|
||||||
|
|
49
src/main.cc
49
src/main.cc
|
@ -66,6 +66,7 @@
|
||||||
#include "NullStatCalc.h"
|
#include "NullStatCalc.h"
|
||||||
#include "download_helper.h"
|
#include "download_helper.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
|
#include "ProtocolDetector.h"
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
# include "MetalinkHelper.h"
|
# include "MetalinkHelper.h"
|
||||||
# include "MetalinkEntry.h"
|
# include "MetalinkEntry.h"
|
||||||
|
@ -102,6 +103,41 @@ std::ostream& getSummaryOut(const Option* op)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void showTorrentFile(const std::string& uri)
|
||||||
|
{
|
||||||
|
SharedHandle<DefaultBtContext> btContext(new DefaultBtContext());
|
||||||
|
btContext->load(uri);
|
||||||
|
std::cout << btContext << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void showMetalinkFile(const std::string& uri, const Option* op)
|
||||||
|
{
|
||||||
|
std::deque<SharedHandle<MetalinkEntry> > metalinkEntries;
|
||||||
|
MetalinkHelper::parseAndQuery(metalinkEntries, uri, op);
|
||||||
|
std::deque<SharedHandle<FileEntry> > fileEntries;
|
||||||
|
MetalinkEntry::toFileEntry(fileEntries, metalinkEntries);
|
||||||
|
Util::toStream(std::cout, fileEntries);
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void showFiles(const std::deque<std::string>& uris, const Option* op)
|
||||||
|
{
|
||||||
|
ProtocolDetector dt;
|
||||||
|
for(std::deque<std::string>::const_iterator i = uris.begin();
|
||||||
|
i != uris.end(); ++i) {
|
||||||
|
printf("Printing the contents of file '%s'...", (*i).c_str());
|
||||||
|
printf("\n");
|
||||||
|
if(dt.guessTorrentFile(*i)) {
|
||||||
|
showTorrentFile(*i);
|
||||||
|
} else if(dt.guessMetalinkFile(*i)) {
|
||||||
|
showMetalinkFile(*i, op);
|
||||||
|
} else {
|
||||||
|
printf("This file is not Torrent/Metalink file. Skipping.");
|
||||||
|
printf("\n\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern Option* option_processing(int argc, char* const argv[]);
|
extern Option* option_processing(int argc, char* const argv[]);
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
@ -143,9 +179,7 @@ int main(int argc, char* argv[])
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
if(!op->blank(PREF_TORRENT_FILE)) {
|
if(!op->blank(PREF_TORRENT_FILE)) {
|
||||||
if(op->get(PREF_SHOW_FILES) == V_TRUE) {
|
if(op->get(PREF_SHOW_FILES) == V_TRUE) {
|
||||||
DefaultBtContextHandle btContext(new DefaultBtContext());
|
showTorrentFile(op->get(PREF_TORRENT_FILE));
|
||||||
btContext->load(op->get(PREF_TORRENT_FILE));
|
|
||||||
std::cout << btContext << std::endl;
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
createRequestGroupForBitTorrent(requestGroups, op, args);
|
createRequestGroupForBitTorrent(requestGroups, op, args);
|
||||||
|
@ -156,12 +190,7 @@ int main(int argc, char* argv[])
|
||||||
#ifdef ENABLE_METALINK
|
#ifdef ENABLE_METALINK
|
||||||
if(!op->blank(PREF_METALINK_FILE)) {
|
if(!op->blank(PREF_METALINK_FILE)) {
|
||||||
if(op->get(PREF_SHOW_FILES) == V_TRUE) {
|
if(op->get(PREF_SHOW_FILES) == V_TRUE) {
|
||||||
std::deque<SharedHandle<MetalinkEntry> > metalinkEntries;
|
showMetalinkFile(op->get(PREF_METALINK_FILE), op);
|
||||||
MetalinkHelper::parseAndQuery(metalinkEntries,
|
|
||||||
op->get(PREF_METALINK_FILE), op);
|
|
||||||
std::deque<SharedHandle<FileEntry> > fileEntries;
|
|
||||||
MetalinkEntry::toFileEntry(fileEntries, metalinkEntries);
|
|
||||||
Util::toStream(std::cout, fileEntries);
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
createRequestGroupForMetalink(requestGroups, op);
|
createRequestGroupForMetalink(requestGroups, op);
|
||||||
|
@ -171,6 +200,8 @@ int main(int argc, char* argv[])
|
||||||
#endif // ENABLE_METALINK
|
#endif // ENABLE_METALINK
|
||||||
if(!op->blank(PREF_INPUT_FILE)) {
|
if(!op->blank(PREF_INPUT_FILE)) {
|
||||||
createRequestGroupForUriList(requestGroups, op);
|
createRequestGroupForUriList(requestGroups, op);
|
||||||
|
} else if(op->get(PREF_SHOW_FILES) == V_TRUE) {
|
||||||
|
showFiles(args, op);
|
||||||
} else {
|
} else {
|
||||||
createRequestGroupForUri(requestGroups, op, args);
|
createRequestGroupForUri(requestGroups, op, args);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue