mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 11:04:25 -04:00
Add controllers to provide comics information from reading lists and labels
This commit is contained in:
@ -0,0 +1,43 @@
|
||||
#include "readinglistinfocontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
|
||||
#include "folder.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
ReadingListInfoControllerV2::ReadingListInfoControllerV2(){}
|
||||
|
||||
void ReadingListInfoControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
qulonglong listId = pathElements.at(5).toULongLong();
|
||||
|
||||
serviceComics(libraryId, listId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void ReadingListInfoControllerV2::serviceComics(const int &library, const qulonglong &readingListId, HttpResponse &response)
|
||||
{
|
||||
QList<ComicDB> comics = DBHelper::getReadingListFullContent(library, readingListId);
|
||||
|
||||
for(const ComicDB &comic : comics)
|
||||
{
|
||||
response.write(QString("/v2/library/%1/comic/%2:%3:%4:%5:%6\r\n")
|
||||
.arg(library)
|
||||
.arg(comic.id)
|
||||
.arg(comic.getFileName())
|
||||
.arg(comic.getFileSize())
|
||||
.arg(comic.info.read ? 1 : 0)
|
||||
.arg(comic.info.hash)
|
||||
.toUtf8());
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
#ifndef READINGLISTINFOCONTROLLER_V2_H
|
||||
#define READINGLISTINFOCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ReadingListInfoControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ReadingListInfoControllerV2)
|
||||
public:
|
||||
|
||||
ReadingListInfoControllerV2();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceComics(const int &library, const qulonglong & readingListId, HttpResponse& response);
|
||||
};
|
||||
|
||||
|
||||
#endif // READINGLISTINFOCONTROLLER_V2_H
|
@ -0,0 +1,43 @@
|
||||
#include "taginfocontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
|
||||
#include "folder.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "template.h"
|
||||
#include "../static.h"
|
||||
|
||||
TagInfoControllerV2::TagInfoControllerV2() {}
|
||||
|
||||
void TagInfoControllerV2::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
qulonglong listId = pathElements.at(5).toULongLong();
|
||||
|
||||
serviceComics(libraryId, listId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void TagInfoControllerV2::serviceComics(const int &library, const qulonglong &tagId, HttpResponse &response)
|
||||
{
|
||||
QList<ComicDB> comics = DBHelper::getLabelComics(library, tagId);
|
||||
|
||||
for(const ComicDB &comic : comics)
|
||||
{
|
||||
response.write(QString("/v2/library/%1/comic/%2:%3:%4:%5:%6\r\n")
|
||||
.arg(library)
|
||||
.arg(comic.id)
|
||||
.arg(comic.getFileName())
|
||||
.arg(comic.getFileSize())
|
||||
.arg(comic.info.read ? 1 : 0)
|
||||
.arg(comic.info.hash)
|
||||
.toUtf8());
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef TAGINFOCONTROLLER_V2_H
|
||||
#define TAGINFOCONTROLLER_V2_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class TagInfoControllerV2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(TagInfoControllerV2)
|
||||
public:
|
||||
TagInfoControllerV2();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceComics(const int &library, const qulonglong & tagId, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // TAGINFOCONTROLLER_V2_H
|
Reference in New Issue
Block a user