mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
getting most of the info from comic vine
This commit is contained in:
parent
9c4ecd72af
commit
bbb74b64b9
@ -151,7 +151,9 @@ void ComicVineDialog::goNext()
|
|||||||
|
|
||||||
//ComicDB-ComicVineID
|
//ComicDB-ComicVineID
|
||||||
QList<QPair<ComicDB,QString> > matchingInfo = sortVolumeComicsWidget->getMatchingInfo();
|
QList<QPair<ComicDB,QString> > matchingInfo = sortVolumeComicsWidget->getMatchingInfo();
|
||||||
QtConcurrent::run(this, &ComicVineDialog::getComicsInfo,matchingInfo);
|
int count = selectVolumeWidget->getSelectedVolumeNumIssues();
|
||||||
|
QString publisher = selectVolumeWidget->getSelectedVolumePublisher();
|
||||||
|
QtConcurrent::run(this, &ComicVineDialog::getComicsInfo,matchingInfo,count,publisher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +357,7 @@ void ComicVineDialog::queryTimeOut()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingInfo)
|
void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingInfo, int count,const QString & publisher)
|
||||||
{
|
{
|
||||||
QPair<ComicDB, QString> p;
|
QPair<ComicDB, QString> p;
|
||||||
QList<ComicDB> comics;
|
QList<ComicDB> comics;
|
||||||
@ -366,7 +368,7 @@ void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingIn
|
|||||||
//connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
|
//connect(comicVineClient,SIGNAL(finished()),comicVineClient,SLOT(deleteLater()));
|
||||||
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)); //TODO check result error
|
comics.push_back(parseComicInfo(p.first,result,count,publisher)); //TODO check result error
|
||||||
}
|
}
|
||||||
|
|
||||||
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
QSqlDatabase db = DataBaseManagement::loadDatabase(databasePath);
|
||||||
@ -384,7 +386,7 @@ void ComicVineDialog::getComicsInfo(QList<QPair<ComicDB, QString> > & matchingIn
|
|||||||
emit accepted();
|
emit accepted();
|
||||||
}
|
}
|
||||||
|
|
||||||
ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json)
|
ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json, int count, const QString & publisher)
|
||||||
{
|
{
|
||||||
QScriptEngine engine;
|
QScriptEngine engine;
|
||||||
QScriptValue sc;
|
QScriptValue sc;
|
||||||
@ -405,46 +407,114 @@ ComicDB ComicVineDialog::parseComicInfo(ComicDB & comic, const QString & json)
|
|||||||
QString title = result.property("name").toString();
|
QString title = result.property("name").toString();
|
||||||
|
|
||||||
QString number = result.property("issue_number").toString();
|
QString number = result.property("issue_number").toString();
|
||||||
QString count; //get from select volume
|
//QString count; //get from select volume
|
||||||
|
|
||||||
|
|
||||||
QString volume = result.property("volume").property("name").toString();
|
QString volume = result.property("volume").property("name").toString();
|
||||||
QString storyArc; //story_arc
|
QString storyArc; //story_arc
|
||||||
QString arcNumber; //??
|
QString arcNumber; //??
|
||||||
QString arcCount; //count_of_issue_appearances
|
QString arcCount; //count_of_issue_appearances -> NO
|
||||||
|
|
||||||
QString genere; //no
|
QString genere; //no
|
||||||
|
|
||||||
QString writer;
|
QMap<QString,QString> authors = getAuthors(result.property("person_credits"));
|
||||||
QString penciller;
|
|
||||||
QString inker;
|
QString writer = QStringList(authors.values("writer")).join("\n");
|
||||||
QString colorist;
|
QString penciller = QStringList(authors.values("penciller")).join("\n");
|
||||||
QString letterer;
|
QString inker = QStringList(authors.values("inker")).join("\n");
|
||||||
QString coverArtist;
|
QString colorist = QStringList(authors.values("colorist")).join("\n");
|
||||||
|
QString letterer = QStringList(authors.values("letterer")).join("\n");
|
||||||
|
QString coverArtist = QStringList(authors.values("cover")).join("\n");
|
||||||
|
|
||||||
QString date = result.property("cover_date").toString();
|
QString date = result.property("cover_date").toString();
|
||||||
|
|
||||||
QString publisher; //get from select volume
|
//QString publisher; //get from select volume
|
||||||
QString format; //no
|
QString format; //no
|
||||||
bool color; //no
|
bool color; //no
|
||||||
QString ageRating; //no
|
QString ageRating; //no
|
||||||
|
|
||||||
QString synopsis = result.property("description").toString(); //description
|
QString synopsis = result.property("description").toString().remove(QRegExp("<[^>]*>")); //description
|
||||||
QString characters;
|
QString characters = getCharacters(result.property("character_credits"));
|
||||||
|
|
||||||
comic.info.setTitle(title);
|
comic.info.setTitle(title);
|
||||||
|
|
||||||
comic.info.setNumber(number.toInt());
|
comic.info.setNumber(number.toInt());
|
||||||
|
comic.info.setCount(count);
|
||||||
|
|
||||||
|
comic.info.setWriter(writer);
|
||||||
|
comic.info.setPenciller(penciller);
|
||||||
|
comic.info.setInker(inker);
|
||||||
|
comic.info.setColorist(colorist);
|
||||||
|
comic.info.setLetterer(letterer);
|
||||||
|
comic.info.setCoverArtist(coverArtist);
|
||||||
|
|
||||||
QStringList tempList = date.split("-");
|
QStringList tempList = date.split("-");
|
||||||
std::reverse(tempList.begin(),tempList.end());
|
std::reverse(tempList.begin(),tempList.end());
|
||||||
comic.info.setDate(tempList.join("/"));
|
comic.info.setDate(tempList.join("/"));
|
||||||
comic.info.setVolume(volume);
|
comic.info.setVolume(volume);
|
||||||
|
|
||||||
|
comic.info.setPublisher(publisher);
|
||||||
|
|
||||||
|
comic.info.setSynopsis(synopsis);
|
||||||
|
comic.info.setCharacters(characters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return comic;
|
return comic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ComicVineDialog::getCharacters(const QScriptValue &json_characters)
|
||||||
|
{
|
||||||
|
QString characters;
|
||||||
|
|
||||||
|
QScriptValueIterator it(json_characters);
|
||||||
|
QScriptValue resultsValue;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
if(it.flags() & QScriptValue::SkipInEnumeration)
|
||||||
|
continue;
|
||||||
|
resultsValue = it.value();
|
||||||
|
|
||||||
|
characters += resultsValue.property("name").toString() + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return characters;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, QString> ComicVineDialog::getAuthors(const QScriptValue &json_authors)
|
||||||
|
{
|
||||||
|
QMap<QString, QString> authors;
|
||||||
|
|
||||||
|
QScriptValueIterator it(json_authors);
|
||||||
|
QScriptValue resultsValue;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
if(it.flags() & QScriptValue::SkipInEnumeration)
|
||||||
|
continue;
|
||||||
|
resultsValue = it.value();
|
||||||
|
|
||||||
|
QString authorName = resultsValue.property("name").toString();
|
||||||
|
|
||||||
|
QStringList roles = resultsValue.property("role").toString().split(",");
|
||||||
|
foreach(QString role, roles)
|
||||||
|
{
|
||||||
|
if(role.trimmed() == "writer")
|
||||||
|
authors.insertMulti("writer",authorName);
|
||||||
|
else if(role.trimmed() == "inker")
|
||||||
|
authors.insertMulti("inker",authorName);
|
||||||
|
else if(role.trimmed() == "penciler" || role.trimmed() == "penciller")
|
||||||
|
authors.insertMulti("penciller",authorName);
|
||||||
|
else if(role.trimmed() == "colorist")
|
||||||
|
authors.insertMulti("colorist",authorName);
|
||||||
|
else if(role.trimmed() == "letterer")
|
||||||
|
authors.insertMulti("letterer",authorName);
|
||||||
|
else if(role.trimmed() == "cover")
|
||||||
|
authors.insertMulti("cover",authorName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return authors;
|
||||||
|
}
|
||||||
|
|
||||||
void ComicVineDialog::showLoading()
|
void ComicVineDialog::showLoading()
|
||||||
{
|
{
|
||||||
content->setCurrentIndex(0);
|
content->setCurrentIndex(0);
|
||||||
|
@ -18,6 +18,7 @@ class SearchVolume;
|
|||||||
class SelectComic;
|
class SelectComic;
|
||||||
class SelectVolume;
|
class SelectVolume;
|
||||||
class SortVolumeComics;
|
class SortVolumeComics;
|
||||||
|
class QScriptValue;
|
||||||
|
|
||||||
//TODO this should use a QStateMachine
|
//TODO this should use a QStateMachine
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
@ -54,11 +55,14 @@ protected slots:
|
|||||||
void showSelectComic(const QString & json);
|
void showSelectComic(const QString & json);
|
||||||
void showSortVolumeComics(const QString & json);
|
void showSortVolumeComics(const QString & json);
|
||||||
void queryTimeOut();
|
void queryTimeOut();
|
||||||
void getComicsInfo(QList<QPair<ComicDB,QString> > & matchingInfo);
|
void getComicsInfo(QList<QPair<ComicDB,QString> > & matchingInfo, int count, const QString & publisher);
|
||||||
ComicDB parseComicInfo(ComicDB &comic, const QString & json);
|
ComicDB parseComicInfo(ComicDB &comic, const QString & json, int count, const QString &publisher);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
QString getCharacters(const QScriptValue & json_characters);
|
||||||
|
QMap<QString,QString> getAuthors(const QScriptValue & json_authors);
|
||||||
|
|
||||||
enum ScraperMode
|
enum ScraperMode
|
||||||
{
|
{
|
||||||
SingleComic, //the scraper has been opened for a single comic
|
SingleComic, //the scraper has been opened for a single comic
|
||||||
|
@ -29,12 +29,13 @@ void VolumeComicsModel::load(const QString & json)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int numResults = sc.property("number_of_total_results").toString().toInt(); //fix to weird behaviour using hasNext
|
|
||||||
QScriptValueIterator it(sc.property("results"));
|
QScriptValueIterator it(sc.property("results"));
|
||||||
//bool test;
|
//bool test;
|
||||||
QScriptValue resultsValue;
|
QScriptValue resultsValue;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
|
if(it.flags() & QScriptValue::SkipInEnumeration)
|
||||||
|
continue;
|
||||||
resultsValue = it.value();
|
resultsValue = it.value();
|
||||||
QString issueNumber = resultsValue.property("issue_number").toString();
|
QString issueNumber = resultsValue.property("issue_number").toString();
|
||||||
QString name = resultsValue.property("name").toString();
|
QString name = resultsValue.property("name").toString();
|
||||||
@ -42,10 +43,7 @@ void VolumeComicsModel::load(const QString & json)
|
|||||||
QString id = resultsValue.property("id").toString();
|
QString id = resultsValue.property("id").toString();
|
||||||
QStringList l;
|
QStringList l;
|
||||||
l << issueNumber << name << coverURL << id;
|
l << issueNumber << name << coverURL << id;
|
||||||
//test = name.isEmpty() && year.isEmpty() && numIssues.isEmpty() && url.isEmpty();
|
|
||||||
if(numResults > 0)
|
|
||||||
_data.push_back(l);
|
_data.push_back(l);
|
||||||
numResults--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qSort(_data.begin(),_data.end(),lessThan);
|
qSort(_data.begin(),_data.end(),lessThan);
|
||||||
|
@ -144,6 +144,16 @@ QString VolumesModel::getVolumeId(const QModelIndex &index) const
|
|||||||
return _data[index.row()][ID];
|
return _data[index.row()][ID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VolumesModel::getNumIssues(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
return _data[index.row()][ISSUES].toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString VolumesModel::getPublisher(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
return _data[index.row()][PUBLISHER];
|
||||||
|
}
|
||||||
|
|
||||||
QString VolumesModel::getCoverURL(const QModelIndex &index) const
|
QString VolumesModel::getCoverURL(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
return _data[index.row()][COVER_URL];
|
return _data[index.row()][COVER_URL];
|
||||||
|
@ -23,6 +23,8 @@ public:
|
|||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
||||||
QString getVolumeId(const QModelIndex & index) const;
|
QString getVolumeId(const QModelIndex & index) const;
|
||||||
|
int getNumIssues(const QModelIndex & index) const;
|
||||||
|
QString getPublisher(const QModelIndex & index) const;
|
||||||
QString getCoverURL(const QModelIndex & index) const;
|
QString getCoverURL(const QModelIndex & index) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -149,3 +149,13 @@ QString SelectVolume::getSelectedVolumeId()
|
|||||||
return model->getVolumeId(tableVolumes->currentIndex());
|
return model->getVolumeId(tableVolumes->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SelectVolume::getSelectedVolumeNumIssues()
|
||||||
|
{
|
||||||
|
return model->getNumIssues(tableVolumes->currentIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SelectVolume::getSelectedVolumePublisher()
|
||||||
|
{
|
||||||
|
return model->getPublisher(tableVolumes->currentIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ public slots:
|
|||||||
void setCover(const QByteArray &);
|
void setCover(const QByteArray &);
|
||||||
void setDescription(const QString & jsonDetail);
|
void setDescription(const QString & jsonDetail);
|
||||||
QString getSelectedVolumeId();
|
QString getSelectedVolumeId();
|
||||||
|
int getSelectedVolumeNumIssues();
|
||||||
|
QString getSelectedVolumePublisher();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel * cover;
|
QLabel * cover;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user