mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
scraper for single comic working
This commit is contained in:
parent
bbb74b64b9
commit
ff37db33e9
@ -114,7 +114,7 @@ void ComicVineDialog::goNext()
|
|||||||
showSearchVolume();
|
showSearchVolume();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
showLoading();
|
showLoading(tr("Looking for volume..."));
|
||||||
searchVolume(volumeSearchString);
|
searchVolume(volumeSearchString);
|
||||||
status = AutoSearching;
|
status = AutoSearching;
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ void ComicVineDialog::goNext()
|
|||||||
ComicDB comic = comics[currentIndex];
|
ComicDB comic = comics[currentIndex];
|
||||||
QString title = comic.getTitleOrFileName();
|
QString title = comic.getTitleOrFileName();
|
||||||
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title));
|
titleHeader->setSubTitle(tr("comic %1 of %2 - %3").arg(currentIndex+1).arg(comics.length()).arg(title));
|
||||||
showLoading();
|
showLoading(tr("Looking for volume..."));
|
||||||
|
|
||||||
searchVolume(title);
|
searchVolume(title);
|
||||||
status = AutoSearching;
|
status = AutoSearching;
|
||||||
@ -134,7 +134,7 @@ void ComicVineDialog::goNext()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (content->currentWidget() == selectVolumeWidget) {
|
else if (content->currentWidget() == selectVolumeWidget) {
|
||||||
showLoading();
|
showLoading(tr("Retrieving volume info..."));
|
||||||
|
|
||||||
status = GettingVolumeComics;
|
status = GettingVolumeComics;
|
||||||
|
|
||||||
@ -147,14 +147,21 @@ void ComicVineDialog::goNext()
|
|||||||
connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
|
connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
|
||||||
comicVineClient->getVolumeComicsInfo(selectVolumeWidget->getSelectedVolumeId());
|
comicVineClient->getVolumeComicsInfo(selectVolumeWidget->getSelectedVolumeId());
|
||||||
} else if (content->currentWidget() == sortVolumeComicsWidget) {
|
} else if (content->currentWidget() == sortVolumeComicsWidget) {
|
||||||
showLoading();
|
showLoading();
|
||||||
|
|
||||||
//ComicDB-ComicVineID
|
//ComicDB-ComicVineID
|
||||||
QList<QPair<ComicDB,QString> > matchingInfo = sortVolumeComicsWidget->getMatchingInfo();
|
QList<QPair<ComicDB,QString> > matchingInfo = sortVolumeComicsWidget->getMatchingInfo();
|
||||||
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
|
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
|
||||||
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
|
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
|
||||||
QtConcurrent::run(this, &ComicVineDialog::getComicsInfo,matchingInfo,count,publisher);
|
QtConcurrent::run(this, &ComicVineDialog::getComicsInfo,matchingInfo,count,publisher);
|
||||||
}
|
} else if (content->currentWidget() == selectComicWidget)
|
||||||
|
{
|
||||||
|
showLoading();
|
||||||
|
QString comicId = selectComicWidget->getSelectedComicId();
|
||||||
|
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
|
||||||
|
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
|
||||||
|
QtConcurrent::run(this, &ComicVineDialog::getComicInfo,comicId,count,publisher);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicVineDialog::goBack()
|
void ComicVineDialog::goBack()
|
||||||
@ -169,6 +176,10 @@ void ComicVineDialog::goBack()
|
|||||||
case SortingComics:
|
case SortingComics:
|
||||||
showSelectVolume();
|
showSelectVolume();
|
||||||
break;
|
break;
|
||||||
|
case SelectingComic:
|
||||||
|
if(mode == SingleComic)
|
||||||
|
showSelectVolume();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -190,7 +201,7 @@ void ComicVineDialog::show()
|
|||||||
ComicDB singleComic = comics[0];
|
ComicDB singleComic = comics[0];
|
||||||
QString title = singleComic.getTitleOrFileName();
|
QString title = singleComic.getTitleOrFileName();
|
||||||
titleHeader->setSubTitle(title);
|
titleHeader->setSubTitle(title);
|
||||||
showLoading();
|
showLoading(tr("Looking for volume..."));
|
||||||
|
|
||||||
searchVolume(title);
|
searchVolume(title);
|
||||||
status = AutoSearching;
|
status = AutoSearching;
|
||||||
@ -209,10 +220,15 @@ void ComicVineDialog::doLoading()
|
|||||||
QVBoxLayout * l = new QVBoxLayout;
|
QVBoxLayout * l = new QVBoxLayout;
|
||||||
|
|
||||||
YACReaderBusyWidget * bw = new YACReaderBusyWidget;
|
YACReaderBusyWidget * bw = new YACReaderBusyWidget;
|
||||||
|
loadingMessage = new QLabel;
|
||||||
|
|
||||||
|
loadingMessage->setStyleSheet("QLabel {color:white; font-size:12px;font-family:Arial;}");
|
||||||
|
|
||||||
l->addStretch();
|
l->addStretch();
|
||||||
l->addWidget(bw,0,Qt::AlignHCenter);
|
l->addWidget(bw,0,Qt::AlignHCenter);
|
||||||
l->addStretch();
|
l->addStretch();
|
||||||
|
l->addWidget(loadingMessage);
|
||||||
|
|
||||||
|
|
||||||
l->setContentsMargins(0,0,0,0);
|
l->setContentsMargins(0,0,0,0);
|
||||||
w->setLayout(l);
|
w->setLayout(l);
|
||||||
@ -311,8 +327,15 @@ void ComicVineDialog::showSelectVolume()
|
|||||||
|
|
||||||
void ComicVineDialog::showSelectComic(const QString &json)
|
void ComicVineDialog::showSelectComic(const QString &json)
|
||||||
{
|
{
|
||||||
|
status = SelectingComic;
|
||||||
|
|
||||||
content->setCurrentWidget(selectComicWidget);
|
content->setCurrentWidget(selectComicWidget);
|
||||||
selectComicWidget->load(json);
|
selectComicWidget->load(json);
|
||||||
|
|
||||||
|
backButton->setVisible(true);
|
||||||
|
nextButton->setVisible(true);
|
||||||
|
searchButton->setHidden(true);
|
||||||
|
closeButton->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicVineDialog::showSortVolumeComics(const QString &json)
|
void ComicVineDialog::showSortVolumeComics(const QString &json)
|
||||||
@ -369,6 +392,8 @@ void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingIn
|
|||||||
QByteArray result = comicVineClient->getComicDetail(p.second); //TODO check timeOut or Connection error
|
QByteArray result = comicVineClient->getComicDetail(p.second); //TODO check timeOut or Connection error
|
||||||
|
|
||||||
comics.push_back(parseComicInfo(p.first,result,count,publisher)); //TODO check result error
|
comics.push_back(parseComicInfo(p.first,result,count,publisher)); //TODO check result error
|
||||||
|
|
||||||
|
setLoadingMessage(tr("Retrieving tags for : %1").arg(p.first.getFileName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
||||||
@ -383,7 +408,37 @@ void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingIn
|
|||||||
QSqlDatabase::removeDatabase(databasePath);
|
QSqlDatabase::removeDatabase(databasePath);
|
||||||
|
|
||||||
close();
|
close();
|
||||||
emit accepted();
|
emit accepted();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicVineDialog::getComicInfo(const QString &comicId, int count, const QString &publisher)
|
||||||
|
{
|
||||||
|
|
||||||
|
ComicVineClient * comicVineClient = new ComicVineClient;
|
||||||
|
QByteArray result = comicVineClient->getComicDetail(comicId); //TODO check timeOut or Connection error
|
||||||
|
|
||||||
|
ComicDB comic = parseComicInfo(comics[currentIndex],result,count,publisher); //TODO check result error
|
||||||
|
|
||||||
|
setLoadingMessage(tr("Retrieving tags for : %1").arg(comics[currentIndex].getFileName()));
|
||||||
|
|
||||||
|
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
||||||
|
db.open();
|
||||||
|
db.transaction();
|
||||||
|
|
||||||
|
DBHelper::update(&(comic.info),db);
|
||||||
|
|
||||||
|
db.commit();
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(databasePath);
|
||||||
|
|
||||||
|
if(mode == SingleComic || currentIndex == (comics.count()-1))
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
emit accepted();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
currentIndex++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, int count, const QString & publisher)
|
ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, int count, const QString & publisher)
|
||||||
@ -515,9 +570,10 @@ QMap<QString, QString> ComicVineDialog::getAuthors(const QScriptValue &json_auth
|
|||||||
return authors;
|
return authors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicVineDialog::showLoading()
|
void ComicVineDialog::showLoading(const QString &message)
|
||||||
{
|
{
|
||||||
content->setCurrentIndex(0);
|
content->setCurrentIndex(0);
|
||||||
|
loadingMessage->setText(message);
|
||||||
backButton->setHidden(true);
|
backButton->setHidden(true);
|
||||||
skipButton->setHidden(true);
|
skipButton->setHidden(true);
|
||||||
nextButton->setHidden(true);
|
nextButton->setHidden(true);
|
||||||
@ -525,6 +581,11 @@ void ComicVineDialog::showLoading()
|
|||||||
closeButton->setVisible(true);
|
closeButton->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComicVineDialog::setLoadingMessage(const QString &message)
|
||||||
|
{
|
||||||
|
loadingMessage->setText(message);
|
||||||
|
}
|
||||||
|
|
||||||
void ComicVineDialog::search()
|
void ComicVineDialog::search()
|
||||||
{
|
{
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
@ -550,14 +611,14 @@ void ComicVineDialog::searchVolume(const QString &v)
|
|||||||
|
|
||||||
void ComicVineDialog::launchSearchVolume()
|
void ComicVineDialog::launchSearchVolume()
|
||||||
{
|
{
|
||||||
showLoading();
|
showLoading(tr("Looking for volume..."));
|
||||||
//TODO: check if volume info is empty.
|
//TODO: check if volume info is empty.
|
||||||
searchVolume(searchVolumeWidget->getVolumeInfo());
|
searchVolume(searchVolumeWidget->getVolumeInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicVineDialog::launchSearchComic()
|
void ComicVineDialog::launchSearchComic()
|
||||||
{
|
{
|
||||||
showLoading();
|
showLoading(tr("Looking for comic..."));
|
||||||
|
|
||||||
QString volumeInfo = searchSingleComicWidget->getVolumeInfo();
|
QString volumeInfo = searchSingleComicWidget->getVolumeInfo();
|
||||||
QString comicInfo = searchSingleComicWidget->getComicInfo();
|
QString comicInfo = searchSingleComicWidget->getComicInfo();
|
||||||
|
@ -45,7 +45,7 @@ protected slots:
|
|||||||
void showSeriesQuestion();
|
void showSeriesQuestion();
|
||||||
void showSearchSingleComic();
|
void showSearchSingleComic();
|
||||||
void showSearchVolume();
|
void showSearchVolume();
|
||||||
void showLoading();
|
void showLoading(const QString & message = "");
|
||||||
void search();
|
void search();
|
||||||
void searchVolume(const QString & v);
|
void searchVolume(const QString & v);
|
||||||
void launchSearchVolume();
|
void launchSearchVolume();
|
||||||
@ -56,8 +56,11 @@ protected slots:
|
|||||||
void showSortVolumeComics(const QString & json);
|
void showSortVolumeComics(const QString & json);
|
||||||
void queryTimeOut();
|
void queryTimeOut();
|
||||||
void getComicsInfo(QList<QPair<ComicDB,QString> > & matchingInfo, int count, const QString & publisher);
|
void getComicsInfo(QList<QPair<ComicDB,QString> > & matchingInfo, int count, const QString & publisher);
|
||||||
|
void getComicInfo(const QString & comicId, int count, const QString & publisher);
|
||||||
|
|
||||||
ComicDB parseComicInfo(ComicDB &comic, const QString & json, int count, const QString &publisher);
|
ComicDB parseComicInfo(ComicDB &comic, const QString & json, int count, const QString &publisher);
|
||||||
|
|
||||||
|
void setLoadingMessage(const QString &message);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QString getCharacters(const QScriptValue & json_characters);
|
QString getCharacters(const QScriptValue & json_characters);
|
||||||
@ -101,6 +104,8 @@ private:
|
|||||||
QWidget * infoNotFound;
|
QWidget * infoNotFound;
|
||||||
QWidget * singleComicBrowser;
|
QWidget * singleComicBrowser;
|
||||||
|
|
||||||
|
QLabel * loadingMessage;
|
||||||
|
|
||||||
void doLayout();
|
void doLayout();
|
||||||
void doStackedWidgets();
|
void doStackedWidgets();
|
||||||
void doLoading();
|
void doLoading();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user