Fixup the Moebooru class
This commit is contained in:
parent
6af8a41d48
commit
743f06d554
2 changed files with 43 additions and 28 deletions
|
@ -38,28 +38,43 @@ namespace Danbooru {
|
|||
// URIs
|
||||
///////
|
||||
|
||||
const QLatin1String MoebooruService::postUri() const {
|
||||
return QLatin1String("post/index.json");
|
||||
const QUrl Danbooru::MoebooruService::postUri() const
|
||||
{
|
||||
auto url = QUrl(m_url);
|
||||
url.setPath("/post/index.json");
|
||||
return url;
|
||||
}
|
||||
|
||||
const QLatin1String MoebooruService::poolUri() const {
|
||||
return QLatin1String("pool/index.json");
|
||||
const QUrl Danbooru::MoebooruService::poolUri() const
|
||||
{
|
||||
auto url = QUrl(m_url);
|
||||
url.setPath("/pool/index.json");
|
||||
return url;
|
||||
}
|
||||
|
||||
const QLatin1String MoebooruService::artistUri() const {
|
||||
return QLatin1String("artist/index.json");
|
||||
const QUrl Danbooru::MoebooruService::artistUri() const {
|
||||
auto url = QUrl(m_url);
|
||||
url.setPath("/artist/index.json");
|
||||
return url;
|
||||
}
|
||||
|
||||
const QLatin1String MoebooruService::tagUri() const {
|
||||
return QLatin1String("tag/index.xml");
|
||||
const QUrl Danbooru::MoebooruService::tagUri() const {
|
||||
auto url = QUrl(m_url);
|
||||
url.setPath("/tag/index.xml");
|
||||
return url;
|
||||
}
|
||||
|
||||
const QLatin1String MoebooruService::poolDataUri() const {
|
||||
return QLatin1String("pool/show.json");
|
||||
const QUrl Danbooru::MoebooruService::poolDataUri() const {
|
||||
auto url = QUrl(m_url);
|
||||
url.setPath("/pool/show.json");
|
||||
return url;
|
||||
}
|
||||
|
||||
const QLatin1String MoebooruService::relatedTagUri() const {
|
||||
return QLatin1String("tag/related.json");
|
||||
const QUrl Danbooru::MoebooruService::relatedTagUri() const {
|
||||
auto url = QUrl(m_url);
|
||||
url.setPath("/tag/related.json");
|
||||
return url;
|
||||
|
||||
}
|
||||
|
||||
////////////////
|
||||
|
@ -83,8 +98,8 @@ void MoebooruService::getPostList() {
|
|||
parameters.insert("limit", QString::number(m_maxPosts));
|
||||
parameters.insert("page", QString::number(m_currentPage));
|
||||
|
||||
QUrl danbooruUrl = requestUrl(m_url, postUri(), m_username,
|
||||
m_password, parameters, m_tags);
|
||||
QUrl danbooruUrl = requestUrl(postUri(), m_username, m_password,
|
||||
parameters, m_tags);
|
||||
|
||||
qCDebug(LIBDANBOORU) << "Final constructed post URL" << danbooruUrl;
|
||||
|
||||
|
@ -101,12 +116,12 @@ void MoebooruService::getPoolList(int limit)
|
|||
QUrl danbooruUrl;
|
||||
|
||||
if (m_currentPage == 1) {
|
||||
danbooruUrl = requestUrl(m_url, poolUri(), m_username, m_password);
|
||||
danbooruUrl = requestUrl(poolUri(), m_username, m_password);
|
||||
} else {
|
||||
QMap<QString, QString> map;
|
||||
map.insert("page", QString::number(m_currentPage));
|
||||
|
||||
danbooruUrl = requestUrl(m_url, poolUri(), m_username,
|
||||
danbooruUrl = requestUrl(poolUri(), m_username,
|
||||
m_password, map);
|
||||
}
|
||||
|
||||
|
@ -137,7 +152,7 @@ void MoebooruService::getPoolList(int limit)
|
|||
poolList = poolList.mid(0, limit);
|
||||
}
|
||||
|
||||
for (const QVariant element : qAsConst(poolList)) {
|
||||
for (const QVariant &element : qAsConst(poolList)) {
|
||||
QVariantMap map = element.toMap();
|
||||
|
||||
DanbooruPool *pool = new DanbooruPool(map);
|
||||
|
@ -163,14 +178,14 @@ void MoebooruService::getPool(int poolId, int page)
|
|||
parameters.insert("page", QString::number(page));
|
||||
}
|
||||
|
||||
QUrl danbooruUrl = requestUrl(m_url, poolDataUri(), m_username,
|
||||
QUrl danbooruUrl = requestUrl(poolDataUri(), m_username,
|
||||
m_password, parameters);
|
||||
|
||||
|
||||
qCDebug(LIBDANBOORU) << "Final constructed URL pool" << danbooruUrl;
|
||||
|
||||
KIO::StoredTransferJob *job = KIO::storedGet(danbooruUrl, KIO::NoReload,
|
||||
KIO::HideProgressInfo);
|
||||
|
||||
|
||||
job->setProperty("is_pool", true);
|
||||
|
||||
connect(job, &KIO::StoredTransferJob::result, this, &DanbooruServiceBase::processPostList);
|
||||
|
@ -187,7 +202,7 @@ void MoebooruService::getTagList(int limit, QString name)
|
|||
}
|
||||
parameters.insert("order", "date");
|
||||
|
||||
QUrl danbooruUrl = requestUrl(m_url, tagUri(), m_username, m_password,
|
||||
QUrl danbooruUrl = requestUrl(tagUri(), m_username, m_password,
|
||||
parameters);
|
||||
// qCDebug(LIBDANBOORU) << "Final constructed tag URL" << danbooruUrl.url();
|
||||
|
||||
|
@ -223,7 +238,7 @@ void MoebooruService::getRelatedTags(const QStringList &tags,
|
|||
QMap<QString, QString> parameters;
|
||||
parameters.insert("type", type);
|
||||
|
||||
QUrl danbooruUrl = requestUrl(m_url, relatedTagUri(), m_username,
|
||||
QUrl danbooruUrl = requestUrl(relatedTagUri(), m_username,
|
||||
m_password, parameters, tags);
|
||||
|
||||
// qCDebug(LIBDANBOORU) << "Final constructed related tag URL" << danbooruUrl;
|
||||
|
|
|
@ -32,12 +32,12 @@ class MoebooruService: public DanbooruServiceBase {
|
|||
Q_OBJECT
|
||||
|
||||
private:
|
||||
const QLatin1String postUri() const override;
|
||||
const QLatin1String poolUri() const override;
|
||||
const QLatin1String artistUri() const override;
|
||||
const QLatin1String tagUri() const override;
|
||||
const QLatin1String poolDataUri() const override;
|
||||
const QLatin1String relatedTagUri() const override;
|
||||
const QUrl postUri() const override;
|
||||
const QUrl poolUri() const override;
|
||||
const QUrl artistUri() const override;
|
||||
const QUrl tagUri() const override;
|
||||
const QUrl poolDataUri() const override;
|
||||
const QUrl relatedTagUri() const override;
|
||||
|
||||
public:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue