From 1c8b204573711edea12366e2dcf315c6690c1c01 Mon Sep 17 00:00:00 2001 From: APTX Date: Thu, 30 Jun 2011 00:13:34 +0200 Subject: [PATCH] Accept ed2k URIs as well. --- aniaddcli.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/aniaddcli.cpp b/aniaddcli.cpp index d84166a..06c4ab5 100644 --- a/aniaddcli.cpp +++ b/aniaddcli.cpp @@ -34,14 +34,26 @@ void AniAddCli::process(const QStringList &files, bool rename, bool add, bool se { foreach(const QString &fileName, files) { - QFileInfo fileInfo(fileName); - if (!fileInfo.exists()) + AniDBUdpClient::File *file = 0; + if (fileName.startsWith("ed2k://")) { - std::cout << "[FAIL] File " << fileInfo.absoluteFilePath().toUtf8().data() << " does not exist" << std::endl; - continue; + file = AniDBUdpClient::File::fromEd2k(fileName); + if (file == 0) + { + std::cout << "[FAIL] " << fileName.toUtf8().data() << " is not a valid ed2k uri" << std::endl; + continue; + } + } + else + { + QFileInfo fileInfo(fileName); + if (!fileInfo.exists()) + { + std::cout << "[FAIL] File " << fileInfo.absoluteFilePath().toUtf8().data() << " does not exist" << std::endl; + continue; + } + file = new AniDBUdpClient::File(fileInfo); } - - AniDBUdpClient::File *file = new AniDBUdpClient::File(fileInfo); connect(file, SIGNAL(statusUpdate(AniDBUdpClient::File::Action,AniDBUdpClient::File::ActionState,int)), this, SLOT(handleStatusUpdate(AniDBUdpClient::File::Action,AniDBUdpClient::File::ActionState,int))); file->setState(m_state); -- 2.52.0