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
 | 
					// URIs
 | 
				
			||||||
///////
 | 
					///////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QLatin1String MoebooruService::postUri() const {
 | 
					const QUrl Danbooru::MoebooruService::postUri() const
 | 
				
			||||||
    return QLatin1String("post/index.json");
 | 
					{
 | 
				
			||||||
 | 
					    auto url = QUrl(m_url);
 | 
				
			||||||
 | 
					    url.setPath("/post/index.json");
 | 
				
			||||||
 | 
					    return url;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QLatin1String MoebooruService::poolUri() const {
 | 
					const QUrl Danbooru::MoebooruService::poolUri() const
 | 
				
			||||||
    return QLatin1String("pool/index.json");
 | 
					{
 | 
				
			||||||
 | 
					    auto url = QUrl(m_url);
 | 
				
			||||||
 | 
					    url.setPath("/pool/index.json");
 | 
				
			||||||
 | 
					    return url;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QLatin1String MoebooruService::artistUri() const {
 | 
					const QUrl Danbooru::MoebooruService::artistUri() const {
 | 
				
			||||||
    return QLatin1String("artist/index.json");
 | 
					    auto url = QUrl(m_url);
 | 
				
			||||||
 | 
					    url.setPath("/artist/index.json");
 | 
				
			||||||
 | 
					    return url;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QLatin1String MoebooruService::tagUri() const {
 | 
					const QUrl Danbooru::MoebooruService::tagUri() const {
 | 
				
			||||||
    return QLatin1String("tag/index.xml");
 | 
					    auto url = QUrl(m_url);
 | 
				
			||||||
 | 
					    url.setPath("/tag/index.xml");
 | 
				
			||||||
 | 
					    return url;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QLatin1String MoebooruService::poolDataUri() const {
 | 
					const QUrl Danbooru::MoebooruService::poolDataUri() const {
 | 
				
			||||||
    return QLatin1String("pool/show.json");
 | 
					    auto url = QUrl(m_url);
 | 
				
			||||||
 | 
					    url.setPath("/pool/show.json");
 | 
				
			||||||
 | 
					    return url;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QLatin1String MoebooruService::relatedTagUri() const {
 | 
					const QUrl Danbooru::MoebooruService::relatedTagUri() const {
 | 
				
			||||||
    return QLatin1String("tag/related.json");
 | 
					    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("limit", QString::number(m_maxPosts));
 | 
				
			||||||
    parameters.insert("page", QString::number(m_currentPage));
 | 
					    parameters.insert("page", QString::number(m_currentPage));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QUrl danbooruUrl = requestUrl(m_url, postUri(), m_username,
 | 
					    QUrl danbooruUrl = requestUrl(postUri(), m_username, m_password,
 | 
				
			||||||
                                  m_password, parameters, m_tags);
 | 
					                                  parameters, m_tags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCDebug(LIBDANBOORU) << "Final constructed post URL" << danbooruUrl;
 | 
					    qCDebug(LIBDANBOORU) << "Final constructed post URL" << danbooruUrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -101,12 +116,12 @@ void MoebooruService::getPoolList(int limit)
 | 
				
			||||||
    QUrl danbooruUrl;
 | 
					    QUrl danbooruUrl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (m_currentPage == 1) {
 | 
					    if (m_currentPage == 1) {
 | 
				
			||||||
        danbooruUrl = requestUrl(m_url, poolUri(), m_username, m_password);
 | 
					        danbooruUrl = requestUrl(poolUri(), m_username, m_password);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        QMap<QString, QString> map;
 | 
					        QMap<QString, QString> map;
 | 
				
			||||||
        map.insert("page", QString::number(m_currentPage));
 | 
					        map.insert("page", QString::number(m_currentPage));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        danbooruUrl = requestUrl(m_url, poolUri(), m_username,
 | 
					        danbooruUrl = requestUrl(poolUri(), m_username,
 | 
				
			||||||
                                 m_password, map);
 | 
					                                 m_password, map);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -137,7 +152,7 @@ void MoebooruService::getPoolList(int limit)
 | 
				
			||||||
            poolList = poolList.mid(0, limit);
 | 
					            poolList = poolList.mid(0, limit);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (const QVariant element : qAsConst(poolList)) {
 | 
					        for (const QVariant &element : qAsConst(poolList)) {
 | 
				
			||||||
            QVariantMap map = element.toMap();
 | 
					            QVariantMap map = element.toMap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            DanbooruPool *pool = new DanbooruPool(map);
 | 
					            DanbooruPool *pool = new DanbooruPool(map);
 | 
				
			||||||
| 
						 | 
					@ -163,7 +178,7 @@ void MoebooruService::getPool(int poolId, int page)
 | 
				
			||||||
        parameters.insert("page", QString::number(page));
 | 
					        parameters.insert("page", QString::number(page));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QUrl danbooruUrl = requestUrl(m_url, poolDataUri(), m_username,
 | 
					    QUrl danbooruUrl = requestUrl(poolDataUri(), m_username,
 | 
				
			||||||
                                  m_password, parameters);
 | 
					                                  m_password, parameters);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    qCDebug(LIBDANBOORU) << "Final constructed URL pool" << danbooruUrl;
 | 
					    qCDebug(LIBDANBOORU) << "Final constructed URL pool" << danbooruUrl;
 | 
				
			||||||
| 
						 | 
					@ -187,7 +202,7 @@ void MoebooruService::getTagList(int limit, QString name)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    parameters.insert("order", "date");
 | 
					    parameters.insert("order", "date");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QUrl danbooruUrl = requestUrl(m_url, tagUri(), m_username, m_password,
 | 
					    QUrl danbooruUrl = requestUrl(tagUri(), m_username, m_password,
 | 
				
			||||||
                                  parameters);
 | 
					                                  parameters);
 | 
				
			||||||
//     qCDebug(LIBDANBOORU) << "Final constructed tag URL" << danbooruUrl.url();
 | 
					//     qCDebug(LIBDANBOORU) << "Final constructed tag URL" << danbooruUrl.url();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -223,7 +238,7 @@ void MoebooruService::getRelatedTags(const QStringList &tags,
 | 
				
			||||||
    QMap<QString, QString> parameters;
 | 
					    QMap<QString, QString> parameters;
 | 
				
			||||||
    parameters.insert("type", type);
 | 
					    parameters.insert("type", type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QUrl danbooruUrl = requestUrl(m_url, relatedTagUri(), m_username,
 | 
					    QUrl danbooruUrl = requestUrl(relatedTagUri(), m_username,
 | 
				
			||||||
                                  m_password, parameters, tags);
 | 
					                                  m_password, parameters, tags);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // qCDebug(LIBDANBOORU) << "Final constructed related tag URL" << danbooruUrl;
 | 
					    // qCDebug(LIBDANBOORU) << "Final constructed related tag URL" << danbooruUrl;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,12 +32,12 @@ class MoebooruService: public DanbooruServiceBase {
 | 
				
			||||||
Q_OBJECT
 | 
					Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    const QLatin1String postUri() const override;
 | 
					    const QUrl postUri() const override;
 | 
				
			||||||
    const QLatin1String poolUri() const override;
 | 
					    const QUrl poolUri() const override;
 | 
				
			||||||
    const QLatin1String artistUri() const override;
 | 
					    const QUrl artistUri() const override;
 | 
				
			||||||
    const QLatin1String tagUri() const override;
 | 
					    const QUrl tagUri() const override;
 | 
				
			||||||
    const QLatin1String poolDataUri() const override;
 | 
					    const QUrl poolDataUri() const override;
 | 
				
			||||||
    const QLatin1String relatedTagUri() const override;
 | 
					    const QUrl relatedTagUri() const override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue