/* * Copyright 2015 Luca Beltrame * * This file is part of Danbooru Client. * * Danbooru Client is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Danbooru Client is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Danbooru Client. If not, see . */ #include "konachan.h" #include "danboorupost.h" #include "danboorupool.h" #include "danboorutag.h" #include "utils.h" // KF5 #include #include #include namespace Danbooru { /////// // URIs /////// const QLatin1String KonachanDanbooruService::postUri() const { return QLatin1String("post/index.json"); } const QLatin1String KonachanDanbooruService::poolUri() const { return QLatin1String("pool/index.json"); } const QLatin1String KonachanDanbooruService::artistUri() const { return QLatin1String("artist/index.json"); } const QLatin1String KonachanDanbooruService::tagUri() const { return QLatin1String("tag/index.xml"); } const QLatin1String KonachanDanbooruService::poolDataUri() const { return QLatin1String("pool/show.xml"); } const QLatin1String KonachanDanbooruService::relatedTagUri() const { return QLatin1String("tag/related.json"); } void KonachanDanbooruService::getPostList() { // We can't fetch more than 100 items, API limitation QMap parameters; parameters.insert("limit", QString::number(m_maxPosts)); parameters.insert("page", QString::number(m_currentPage)); QUrl danbooruUrl = requestUrl(m_url, POST_URL, m_username, m_password, parameters, m_tags); // qCDebug(LIBDANBOORU) << "Final constructed post URL" << danbooruUrl; KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload, KIO::HideProgressInfo); // This job can use JSON data job->setProperty("needsXML", false); connect(job, &KIO::StoredTransferJob::result, this, &KonachanDanbooruService::processPostList); } } //namespace Danbooru