.
This commit is contained in:
+150
@@ -0,0 +1,150 @@
|
||||
#include "cfanart.h"
|
||||
|
||||
|
||||
cFanart::cFanart(Type type) :
|
||||
m_type(type),
|
||||
m_iID(-1),
|
||||
m_szURL(""),
|
||||
m_szLanguage(""),
|
||||
m_iLikes(0),
|
||||
m_iSeason(-1),
|
||||
m_szDisc(""),
|
||||
m_szDiscType(""),
|
||||
m_bActive(false)
|
||||
{
|
||||
}
|
||||
|
||||
void cFanart::setType(const Type& type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
cFanart::Type cFanart::type()
|
||||
{
|
||||
return(m_type);
|
||||
}
|
||||
|
||||
void cFanart::setID(const qint32& iID)
|
||||
{
|
||||
m_iID = iID;
|
||||
}
|
||||
|
||||
qint32 cFanart::id()
|
||||
{
|
||||
return(m_iID);
|
||||
}
|
||||
|
||||
void cFanart::setURL(const QString& szURL)
|
||||
{
|
||||
m_szURL = szURL;
|
||||
}
|
||||
|
||||
QString cFanart::url()
|
||||
{
|
||||
return(m_szURL);
|
||||
}
|
||||
|
||||
void cFanart::setLanguage(const QString& szLanguage)
|
||||
{
|
||||
m_szLanguage = szLanguage;
|
||||
}
|
||||
|
||||
QString cFanart::language()
|
||||
{
|
||||
return(m_szLanguage);
|
||||
}
|
||||
|
||||
void cFanart::setLikes(const qint32& iLikes)
|
||||
{
|
||||
m_iLikes = iLikes;
|
||||
}
|
||||
|
||||
qint32 cFanart::likes()
|
||||
{
|
||||
return(m_iLikes);
|
||||
}
|
||||
|
||||
void cFanart::setSeason(const qint16& iSeason)
|
||||
{
|
||||
m_iSeason = iSeason;
|
||||
}
|
||||
|
||||
qint16 cFanart::season()
|
||||
{
|
||||
return(m_iSeason);
|
||||
}
|
||||
|
||||
void cFanart::setDisc(const QString& szDisc)
|
||||
{
|
||||
m_szDisc = szDisc;
|
||||
}
|
||||
|
||||
QString cFanart::disc()
|
||||
{
|
||||
return(m_szDisc);
|
||||
}
|
||||
|
||||
void cFanart::setDiscType(const QString& szDiscType)
|
||||
{
|
||||
m_szDiscType = szDiscType;
|
||||
}
|
||||
|
||||
QString cFanart::discType()
|
||||
{
|
||||
return(m_szDiscType);
|
||||
}
|
||||
|
||||
void cFanart::setActive(const bool& bActive)
|
||||
{
|
||||
m_bActive = bActive;
|
||||
}
|
||||
|
||||
bool cFanart::active()
|
||||
{
|
||||
return(m_bActive);
|
||||
}
|
||||
|
||||
cFanart* cFanartList::add(const cFanart::Type& type)
|
||||
{
|
||||
cFanart* lpNew = new cFanart(type);
|
||||
append(lpNew);
|
||||
return(lpNew);
|
||||
}
|
||||
|
||||
cFanart* cFanartList::search(const cFanart::Type& type, const QString& szLanguage)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(szLanguage.length())
|
||||
{
|
||||
if(at(x)->type() == type && !at(x)->language().compare(szLanguage, Qt::CaseInsensitive))
|
||||
return(at(x));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(at(x)->type() == type)
|
||||
return(at(x));
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
cFanart* cFanartList::search(const cFanart::Type& type, const bool bActive, const QString& szLanguage)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(szLanguage.length())
|
||||
{
|
||||
if(at(x)->type() == type &&
|
||||
!at(x)->language().compare(szLanguage, Qt::CaseInsensitive) &&
|
||||
at(x)->active() == bActive)
|
||||
return(at(x));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(at(x)->type() == type && at(x)->active() == bActive)
|
||||
return(at(x));
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
#ifndef CFANART_H
|
||||
#define CFANART_H
|
||||
|
||||
|
||||
#include <QString>
|
||||
#include <QMetaType>
|
||||
#include <QList>
|
||||
|
||||
|
||||
class cFanart
|
||||
{
|
||||
public:
|
||||
enum Type
|
||||
{
|
||||
TypeUnknown = 0,
|
||||
TypeHDTVLogo = 1,
|
||||
TypeClearLogo = 2,
|
||||
TypeTVPoster = 3,
|
||||
TypeClearArt = 4,
|
||||
TypeHDClearArt = 5,
|
||||
TypeShowBackground = 6,
|
||||
TypeSeasonPoster = 7,
|
||||
TypeTVThumb = 8,
|
||||
TypeSeasonBanner = 9,
|
||||
TypeCharacterArt = 10,
|
||||
TypeSeasonThumb = 11,
|
||||
TypeTVBanner = 12,
|
||||
TypeHDMovieLogo = 13,
|
||||
TypeMovieDisc = 14,
|
||||
TypeMovieLogo = 15,
|
||||
TypeMoviePoster = 16,
|
||||
TypeHDMovieClearArt = 17,
|
||||
TypeMovieArt = 18,
|
||||
TypeMovieBackground = 19,
|
||||
TypeMovieBanner = 20,
|
||||
TypeMovieThumb = 21,
|
||||
};
|
||||
|
||||
cFanart(Type type = TypeUnknown);
|
||||
|
||||
void setType(const Type& type);
|
||||
Type type();
|
||||
|
||||
void setID(const qint32& iID);
|
||||
qint32 id();
|
||||
|
||||
void setURL(const QString& szURL);
|
||||
QString url();
|
||||
|
||||
void setLanguage(const QString& szLanguage);
|
||||
QString language();
|
||||
|
||||
void setLikes(const qint32& iLikes);
|
||||
qint32 likes();
|
||||
|
||||
void setSeason(const qint16& iSeason);
|
||||
qint16 season();
|
||||
|
||||
void setDisc(const QString& szDisc);
|
||||
QString disc();
|
||||
|
||||
void setDiscType(const QString& szDiscType);
|
||||
QString discType();
|
||||
|
||||
void setActive(const bool& bActive);
|
||||
bool active();
|
||||
private:
|
||||
Type m_type;
|
||||
qint32 m_iID;
|
||||
QString m_szURL;
|
||||
QString m_szLanguage;
|
||||
qint32 m_iLikes;
|
||||
qint16 m_iSeason;
|
||||
QString m_szDisc;
|
||||
QString m_szDiscType;
|
||||
bool m_bActive;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cFanart*)
|
||||
|
||||
class cFanartList : public QList<cFanart*>
|
||||
{
|
||||
public:
|
||||
cFanart* add(const cFanart::Type& type);
|
||||
cFanart* search(const cFanart::Type& type, const QString& szLanguage = "");
|
||||
cFanart* search(const cFanart::Type& type, const bool bActive, const QString& szLanguage = "");
|
||||
};
|
||||
|
||||
#endif // CFANART_H
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
#include "cfanarttv.h"
|
||||
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include <QEventLoop>
|
||||
#include <QByteArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
|
||||
cFanartTV::cFanartTV() :
|
||||
m_szAPIKey("5c31661038de56f110b5f2fc4d49a7d1")
|
||||
{
|
||||
}
|
||||
|
||||
void cFanartTV::processArray(const QJsonArray& array, cFanartList& fanartList, cFanart::Type type)
|
||||
{
|
||||
cFanart* lpFanart;
|
||||
|
||||
for(int x = 0;x < array.count();x++)
|
||||
{
|
||||
QJsonObject obj = array.at(x).toObject();
|
||||
lpFanart = fanartList.add(type);
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case cFanart::TypeHDTVLogo:
|
||||
case cFanart::TypeClearLogo:
|
||||
case cFanart::TypeTVPoster:
|
||||
case cFanart::TypeClearArt:
|
||||
case cFanart::TypeHDClearArt:
|
||||
case cFanart::TypeTVThumb:
|
||||
case cFanart::TypeCharacterArt:
|
||||
case cFanart::TypeTVBanner:
|
||||
lpFanart->setID(obj["id"].toString().toInt());
|
||||
lpFanart->setLanguage(obj["lang"].toString());
|
||||
lpFanart->setLikes(obj["likes"].toString().toInt());
|
||||
lpFanart->setURL(obj["url"].toString());
|
||||
break;
|
||||
case cFanart::TypeShowBackground:
|
||||
case cFanart::TypeSeasonPoster:
|
||||
case cFanart::TypeSeasonBanner:
|
||||
case cFanart::TypeSeasonThumb:
|
||||
lpFanart->setID(obj["id"].toString().toInt());
|
||||
lpFanart->setLanguage(obj["lang"].toString());
|
||||
lpFanart->setLikes(obj["likes"].toString().toInt());
|
||||
lpFanart->setURL(obj["url"].toString());
|
||||
if(!obj["season"].toString().compare("all"))
|
||||
lpFanart->setSeason(-1);
|
||||
else
|
||||
lpFanart->setSeason(obj["season"].toString().toInt());
|
||||
break;
|
||||
case cFanart::TypeHDMovieLogo:
|
||||
case cFanart::TypeMovieLogo:
|
||||
case cFanart::TypeMoviePoster:
|
||||
case cFanart::TypeHDMovieClearArt:
|
||||
case cFanart::TypeMovieArt:
|
||||
case cFanart::TypeMovieBackground:
|
||||
case cFanart::TypeMovieBanner:
|
||||
case cFanart::TypeMovieThumb:
|
||||
lpFanart->setID(obj["id"].toString().toInt());
|
||||
lpFanart->setLanguage(obj["lang"].toString());
|
||||
lpFanart->setLikes(obj["likes"].toString().toInt());
|
||||
lpFanart->setURL(obj["url"].toString());
|
||||
break;
|
||||
case cFanart::TypeMovieDisc:
|
||||
lpFanart->setID(obj["id"].toString().toInt());
|
||||
lpFanart->setLanguage(obj["lang"].toString());
|
||||
lpFanart->setLikes(obj["likes"].toString().toInt());
|
||||
lpFanart->setURL(obj["url"].toString());
|
||||
lpFanart->setDisc(obj["disc"].toString());
|
||||
lpFanart->setDiscType(obj["disc_type"].toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cFanartList cFanartTV::loadFanartSerie(const qint32 &iID)
|
||||
{
|
||||
cFanartList fanartList;
|
||||
QNetworkAccessManager networkManager;
|
||||
QNetworkRequest request(QUrl(QString("http://webservice.fanart.tv/v3/tv/%1?api_key=%2").arg(iID).arg(m_szAPIKey)));
|
||||
|
||||
request.setRawHeader("Content-Type", "application/json");
|
||||
|
||||
QNetworkReply* reply = networkManager.get(request);
|
||||
QEventLoop loop;
|
||||
|
||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
|
||||
if (reply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
QString strReply = (QString)reply->readAll();
|
||||
QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
|
||||
QJsonObject jsonObj = jsonResponse.object();
|
||||
|
||||
delete reply;
|
||||
|
||||
processArray(jsonObj["hdtvlogo"].toArray(), fanartList, cFanart::TypeHDTVLogo);
|
||||
processArray(jsonObj["clearlogo"].toArray(), fanartList, cFanart::TypeClearLogo);
|
||||
processArray(jsonObj["tvposter"].toArray(), fanartList, cFanart::TypeTVPoster);
|
||||
processArray(jsonObj["clearart"].toArray(), fanartList, cFanart::TypeClearArt);
|
||||
processArray(jsonObj["hdclearart"].toArray(), fanartList, cFanart::TypeHDClearArt);
|
||||
processArray(jsonObj["showbackground"].toArray(), fanartList, cFanart::TypeShowBackground);
|
||||
processArray(jsonObj["seasonposter"].toArray(), fanartList, cFanart::TypeSeasonPoster);
|
||||
processArray(jsonObj["tvthumb"].toArray(), fanartList, cFanart::TypeTVThumb);
|
||||
processArray(jsonObj["seasonbanner"].toArray(), fanartList, cFanart::TypeSeasonBanner);
|
||||
processArray(jsonObj["characterart"].toArray(), fanartList, cFanart::TypeCharacterArt);
|
||||
processArray(jsonObj["seasonthumb"].toArray(), fanartList, cFanart::TypeSeasonThumb);
|
||||
processArray(jsonObj["tvbanner"].toArray(), fanartList, cFanart::TypeTVBanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << reply->errorString();
|
||||
delete reply;
|
||||
}
|
||||
return(fanartList);
|
||||
}
|
||||
|
||||
cFanartList cFanartTV::loadFanartMovie(const QString &szIMDBID)
|
||||
{
|
||||
cFanartList fanartList;
|
||||
QNetworkAccessManager networkManager;
|
||||
QNetworkRequest request(QUrl(QString("http://webservice.fanart.tv/v3/movies/%1?api_key=%2").arg(szIMDBID).arg(m_szAPIKey)));
|
||||
|
||||
request.setRawHeader("Content-Type", "application/json");
|
||||
|
||||
QNetworkReply* reply = networkManager.get(request);
|
||||
QEventLoop loop;
|
||||
|
||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
loop.exec();
|
||||
|
||||
if (reply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
QString strReply = (QString)reply->readAll();
|
||||
QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
|
||||
QJsonObject jsonObj = jsonResponse.object();
|
||||
|
||||
delete reply;
|
||||
|
||||
processArray(jsonObj["hdmovielogo"].toArray(), fanartList, cFanart::TypeHDMovieLogo);
|
||||
processArray(jsonObj["movielogo"].toArray(), fanartList, cFanart::TypeMovieLogo);
|
||||
processArray(jsonObj["movieposter"].toArray(), fanartList, cFanart::TypeMoviePoster);
|
||||
processArray(jsonObj["hdmovieclearart"].toArray(), fanartList, cFanart::TypeHDMovieClearArt);
|
||||
processArray(jsonObj["movieart"].toArray(), fanartList, cFanart::TypeMovieArt);
|
||||
processArray(jsonObj["moviebackground"].toArray(), fanartList, cFanart::TypeMovieBackground);
|
||||
processArray(jsonObj["moviebanner"].toArray(), fanartList, cFanart::TypeMovieBanner);
|
||||
processArray(jsonObj["moviethumb"].toArray(), fanartList, cFanart::TypeMovieThumb);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << reply->errorString();
|
||||
delete reply;
|
||||
}
|
||||
return(fanartList);
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#ifndef CFANARTTV_H
|
||||
#define CFANARTTV_H
|
||||
|
||||
|
||||
#include "cfanart.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
class cFanartTV
|
||||
{
|
||||
public:
|
||||
cFanartTV();
|
||||
|
||||
cFanartList loadFanartSerie(const qint32 &iID);
|
||||
cFanartList loadFanartMovie(const QString& szIMDBID);
|
||||
private:
|
||||
QString m_szAPIKey;
|
||||
|
||||
void processArray(const QJsonArray& array, cFanartList& fanartList, cFanart::Type type);
|
||||
};
|
||||
|
||||
#endif // CFANARTTV_H
|
||||
+95
-34
@@ -252,6 +252,22 @@ void cMainWindow::initDB()
|
||||
|
||||
}
|
||||
|
||||
if(!m_db.tables().contains("fanart"))
|
||||
{
|
||||
query.exec("CREATE TABLE fanart ("
|
||||
" id INTEGER,"
|
||||
" type INTEGER,"
|
||||
" url STRING,"
|
||||
" language STRING,"
|
||||
" likes INTEGER,"
|
||||
" season INTEGER,"
|
||||
" discType STRING,"
|
||||
" disc STRING,"
|
||||
" active BOOL,"
|
||||
" seriesID INTEGER,"
|
||||
" movieID INTEGER);");
|
||||
}
|
||||
|
||||
if(!m_db.tables().contains("movie"))
|
||||
{
|
||||
query.exec("CREATE TABLE movie ("
|
||||
@@ -291,6 +307,13 @@ void cMainWindow::loadDB()
|
||||
// convertSeries();
|
||||
loadSeriesDB();
|
||||
loadMoviesDB();
|
||||
|
||||
cMovie* lpMovie = m_movieList.at(0);
|
||||
lpMovie->loadFanart();
|
||||
lpMovie->del(m_db);
|
||||
lpMovie->save(m_db);
|
||||
|
||||
lpMovie = 0;
|
||||
}
|
||||
|
||||
void cMainWindow::convertSeries()
|
||||
@@ -359,6 +382,8 @@ void cMainWindow::loadSeriesDB()
|
||||
qint32 iSeasonNumber;
|
||||
cSeason* lpSeason;
|
||||
cEpisode* lpEpisode;
|
||||
cSerie* lpSerie = 0;
|
||||
|
||||
QString szQuery =
|
||||
" SELECT serie.seriesID seriesID,"
|
||||
" serie.seriesName seriesName,"
|
||||
@@ -432,43 +457,42 @@ void cMainWindow::loadSeriesDB()
|
||||
|
||||
if(iSeriesID != iOldSeriesID)
|
||||
{
|
||||
m_serieList.add(iSeriesID);
|
||||
iOldSeriesID = iSeriesID;
|
||||
iOldSeasonNumber = -1;
|
||||
}
|
||||
|
||||
cSerie* lpSerie = m_serieList.add(iSeriesID);
|
||||
lpSerie->setSeriesName(query.value("seriesName").toString());
|
||||
lpSerie->setOriginalName(query.value("originalName").toString());
|
||||
lpSerie->setBackdropPath(query.value("backdropPath").toString());
|
||||
lpSerie->setCreatedBy(query.value("createdBy").toString());
|
||||
lpSerie->setHomepage(query.value("homepage").toString());
|
||||
lpSerie->setLastAired(query.value("lastAired").toString());
|
||||
lpSerie->setLanguages(query.value("languages").toString());
|
||||
lpSerie->setNetworks(query.value("networks").toString());
|
||||
lpSerie->setEpisodes(query.value("nrEpisodes").toInt());
|
||||
lpSerie->setSeasons(query.value("nrSeasons").toInt());
|
||||
lpSerie->setOriginCountries(query.value("originCountries").toString());
|
||||
lpSerie->setOriginalLanguage(query.value("originalLanguage").toString());
|
||||
lpSerie->setPopularity(query.value("popularity").toDouble());
|
||||
lpSerie->setPosterPath(query.value("posterPath").toString());
|
||||
lpSerie->setProductionCompanies(query.value("productionCompanies").toString());
|
||||
lpSerie->setType(query.value("type").toString());
|
||||
lpSerie->setVoteAverage(query.value("voteAverage").toDouble());
|
||||
lpSerie->setVoteCount(query.value("voteCount").toInt());
|
||||
lpSerie->setOverview(query.value("overview").toString());
|
||||
lpSerie->setFirstAired(query.value("firstAired").toString());
|
||||
lpSerie->setCast(query.value("cast").toString().split("|"));
|
||||
lpSerie->setCrew(query.value("crew").toString().split("|"));
|
||||
lpSerie->setGenre(query.value("genre").toString());
|
||||
lpSerie->setIMDBID(query.value("imdbid").toString());
|
||||
lpSerie->setFreebaseMID(query.value("freebasemid").toString());
|
||||
lpSerie->setFreebaseID(query.value("freebaseid").toString());
|
||||
lpSerie->setTVDBID(query.value("tvdbid").toInt());
|
||||
lpSerie->setTVRageID(query.value("tvrageid").toInt());
|
||||
lpSerie->setStatus(query.value("status").toString());
|
||||
lpSerie->setDownload(query.value("download").toString());
|
||||
lpSerie->setCliffhanger(query.value("cliffhanger").toBool());
|
||||
lpSerie = m_serieList.add(iSeriesID);
|
||||
lpSerie->setSeriesName(query.value("seriesName").toString());
|
||||
lpSerie->setOriginalName(query.value("originalName").toString());
|
||||
lpSerie->setBackdropPath(query.value("backdropPath").toString());
|
||||
lpSerie->setCreatedBy(query.value("createdBy").toString());
|
||||
lpSerie->setHomepage(query.value("homepage").toString());
|
||||
lpSerie->setLastAired(query.value("lastAired").toString());
|
||||
lpSerie->setLanguages(query.value("languages").toString());
|
||||
lpSerie->setNetworks(query.value("networks").toString());
|
||||
lpSerie->setEpisodes(query.value("nrEpisodes").toInt());
|
||||
lpSerie->setSeasons(query.value("nrSeasons").toInt());
|
||||
lpSerie->setOriginCountries(query.value("originCountries").toString());
|
||||
lpSerie->setOriginalLanguage(query.value("originalLanguage").toString());
|
||||
lpSerie->setPopularity(query.value("popularity").toDouble());
|
||||
lpSerie->setPosterPath(query.value("posterPath").toString());
|
||||
lpSerie->setProductionCompanies(query.value("productionCompanies").toString());
|
||||
lpSerie->setType(query.value("type").toString());
|
||||
lpSerie->setVoteAverage(query.value("voteAverage").toDouble());
|
||||
lpSerie->setVoteCount(query.value("voteCount").toInt());
|
||||
lpSerie->setOverview(query.value("overview").toString());
|
||||
lpSerie->setFirstAired(query.value("firstAired").toString());
|
||||
lpSerie->setCast(query.value("cast").toString().split("|"));
|
||||
lpSerie->setCrew(query.value("crew").toString().split("|"));
|
||||
lpSerie->setGenre(query.value("genre").toString());
|
||||
lpSerie->setIMDBID(query.value("imdbid").toString());
|
||||
lpSerie->setFreebaseMID(query.value("freebasemid").toString());
|
||||
lpSerie->setFreebaseID(query.value("freebaseid").toString());
|
||||
lpSerie->setTVDBID(query.value("tvdbid").toInt());
|
||||
lpSerie->setTVRageID(query.value("tvrageid").toInt());
|
||||
lpSerie->setStatus(query.value("status").toString());
|
||||
lpSerie->setDownload(query.value("download").toString());
|
||||
lpSerie->setCliffhanger(query.value("cliffhanger").toBool());
|
||||
}
|
||||
|
||||
if(iSeasonNumber != iOldSeasonNumber)
|
||||
{
|
||||
@@ -500,6 +524,42 @@ void cMainWindow::loadSeriesDB()
|
||||
lpEpisode->setCrew(query.value("e_crew").toString());
|
||||
lpEpisode->setState((cEpisode::State)query.value("e_state").toInt());
|
||||
}
|
||||
|
||||
iOldSeriesID = -1;
|
||||
cFanartList fanartList;
|
||||
|
||||
szQuery = "SELECT id, type, url, language, likes, season, active, seriesID FROM fanart ORDER BY seriesID;";
|
||||
if(query.exec(szQuery))
|
||||
{
|
||||
cSerie* lpSerie = 0;
|
||||
|
||||
while(query.next())
|
||||
{
|
||||
iSeriesID = query.value("seriesID").toInt();
|
||||
|
||||
if(iSeriesID != iOldSeriesID)
|
||||
{
|
||||
if(lpSerie)
|
||||
lpSerie->setFanartList(fanartList);
|
||||
|
||||
fanartList.clear();
|
||||
|
||||
lpSerie = m_serieList.find(iSeriesID);
|
||||
iOldSeriesID = iSeriesID;
|
||||
}
|
||||
|
||||
cFanart* lpFanart = fanartList.add((cFanart::Type)query.value("type").toInt());
|
||||
lpFanart->setActive(query.value("active").toBool());
|
||||
lpFanart->setID(query.value("id").toInt());
|
||||
lpFanart->setURL(query.value("url").toString());
|
||||
lpFanart->setLanguage(query.value("language").toString());
|
||||
lpFanart->setLikes(query.value("likes").toInt());
|
||||
lpFanart->setSeason(query.value("season").toInt());
|
||||
}
|
||||
|
||||
if(lpSerie && fanartList.count())
|
||||
lpSerie->setFanartList(fanartList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1104,6 +1164,7 @@ void cMainWindow::onActionAdd()
|
||||
lpDialog->setMessage("Updating");
|
||||
lpDialog->show();
|
||||
|
||||
lpSerie->loadFanart();
|
||||
lpSerie->save(m_db);
|
||||
}
|
||||
else
|
||||
|
||||
+45
@@ -1,4 +1,5 @@
|
||||
#include "cmovie.h"
|
||||
#include "cfanarttv.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <QStringList>
|
||||
@@ -326,13 +327,31 @@ cMovie::State cMovie::state()
|
||||
return(m_iState);
|
||||
}
|
||||
|
||||
void cMovie::loadFanart()
|
||||
{
|
||||
cFanartTV fanartTV;
|
||||
m_fanartList = fanartTV.loadFanartMovie(imdbID());
|
||||
}
|
||||
|
||||
cFanartList cMovie::fanartList()
|
||||
{
|
||||
return(m_fanartList);
|
||||
}
|
||||
|
||||
void cMovie::setFanartList(const cFanartList& fanartList)
|
||||
{
|
||||
m_fanartList = fanartList;
|
||||
}
|
||||
|
||||
bool cMovie::save(QSqlDatabase &db)
|
||||
{
|
||||
QSqlQuery query;
|
||||
QSqlQuery queryMovie;
|
||||
QSqlQuery queryFanart;
|
||||
|
||||
queryMovie.prepare("INSERT INTO movie (movieID,movieTitle,originalTitle,backdropPath,posterPath,overview,releaseDate,genre,imdbid,originalLanguage,popularity,productionCompanies,productionCountries,voteAverage,voteCount,adult,belongsToCollection,budget,homepage,revenue,runtime,spokenLanguages,status,tagline,video,cast,crew,state)"
|
||||
" VALUES (:movieID,:movieTitle,:originalTitle,:backdropPath,:posterPath,:overview,:releaseDate,:genre,:imdbid,:originalLanguage,:popularity,:productionCompanies,:productionCountries,:voteAverage,:voteCount,:adult,:belongsToCollection,:budget,:homepage,:revenue,:runtime,:spokenLanguages,:status,:tagline,:video,:cast,:crew,:state);");
|
||||
queryFanart.prepare("INSERT INTO fanart (id,type,url,language,likes,discType,disc,active,movieID) VALUES (:id,:type,:url,:language,:likes,:discType,:disc,:active,:movieID);");
|
||||
|
||||
db.transaction();
|
||||
query.exec(QString("SELECT movieID FROM movie WHERE movieID=%1;").arg(movieID()));
|
||||
@@ -369,6 +388,24 @@ bool cMovie::save(QSqlDatabase &db)
|
||||
|
||||
if(queryMovie.exec())
|
||||
{
|
||||
for(int x = 0;x < m_fanartList.count();x++)
|
||||
{
|
||||
cFanart* lpFanart = m_fanartList.at(x);
|
||||
queryFanart.bindValue(":id", lpFanart->id());
|
||||
queryFanart.bindValue(":type", lpFanart->type());
|
||||
queryFanart.bindValue(":url", lpFanart->url());
|
||||
queryFanart.bindValue(":language", lpFanart->language());
|
||||
queryFanart.bindValue(":likes", lpFanart->likes());
|
||||
queryFanart.bindValue(":discType", lpFanart->discType());
|
||||
queryFanart.bindValue(":disc", lpFanart->disc());
|
||||
queryFanart.bindValue(":active", lpFanart->active());
|
||||
queryFanart.bindValue(":movieID", movieID());
|
||||
if(queryFanart.exec())
|
||||
{
|
||||
}
|
||||
else
|
||||
qDebug() << queryFanart.lastError().text();
|
||||
}
|
||||
}
|
||||
else
|
||||
qDebug() << queryMovie.lastError().text();
|
||||
@@ -383,6 +420,14 @@ bool cMovie::del(QSqlDatabase& db)
|
||||
QSqlQuery query;
|
||||
|
||||
db.transaction();
|
||||
|
||||
if(m_fanartList.count())
|
||||
{
|
||||
query.prepare("DELETE FROM fanart WHERE movieID=:movieID;");
|
||||
query.bindValue(":movieID", movieID());
|
||||
query.exec();
|
||||
}
|
||||
|
||||
query.prepare("DELETE FROM movie WHERE movieID=:movieID;");
|
||||
query.bindValue(":movieID", movieID());
|
||||
query.exec();
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define CMOVIE_H
|
||||
|
||||
|
||||
#include "cfanart.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QDate>
|
||||
#include <QSqlDatabase>
|
||||
@@ -112,6 +114,10 @@ public:
|
||||
|
||||
bool save(QSqlDatabase& db);
|
||||
bool del(QSqlDatabase& db);
|
||||
|
||||
void loadFanart();
|
||||
void setFanartList(const cFanartList& fanartList);
|
||||
cFanartList fanartList();
|
||||
private:
|
||||
QString m_szMovieTitle;
|
||||
qint32 m_iID;
|
||||
@@ -142,6 +148,7 @@ private:
|
||||
QStringList m_szCast;
|
||||
QStringList m_szCrew;
|
||||
State m_iState;
|
||||
cFanartList m_fanartList;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(cMovie*)
|
||||
|
||||
+5
-4
@@ -28,11 +28,12 @@ cSeason::~cSeason()
|
||||
deleteResources();
|
||||
}
|
||||
|
||||
void cSeason::set_ID(const qint16& _iID)
|
||||
void cSeason::set_ID(const qint32& _iID)
|
||||
{
|
||||
m_i_ID = _iID;
|
||||
}
|
||||
qint16 cSeason::_id()
|
||||
|
||||
qint32 cSeason::_id()
|
||||
{
|
||||
return(m_i_ID);
|
||||
}
|
||||
@@ -72,12 +73,12 @@ QString cSeason::overview()
|
||||
return(m_szOverview);
|
||||
}
|
||||
|
||||
void cSeason::setID(const qint16& iID)
|
||||
void cSeason::setID(const qint32& iID)
|
||||
{
|
||||
m_iID = iID;
|
||||
}
|
||||
|
||||
qint16 cSeason::id()
|
||||
qint32 cSeason::id()
|
||||
{
|
||||
return(m_iID);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ public:
|
||||
cSeason();
|
||||
~cSeason();
|
||||
|
||||
void set_ID(const qint16& _iID);
|
||||
qint16 _id();
|
||||
void set_ID(const qint32& _iID);
|
||||
qint32 _id();
|
||||
|
||||
void setAirDate(const QString& szAirDate);
|
||||
void setAirDate(const QDate& airDate);
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
void setOverview(const QString& szOverview);
|
||||
QString overview();
|
||||
|
||||
void setID(const qint16& iID);
|
||||
qint16 id();
|
||||
void setID(const qint32& iID);
|
||||
qint32 id();
|
||||
|
||||
void setPosterPath(const QString& szPosterPath);
|
||||
QString posterPath();
|
||||
@@ -74,11 +74,11 @@ public:
|
||||
QPushButton* allProgressButton();
|
||||
QPushButton* allDoneButton();
|
||||
private:
|
||||
qint16 m_i_ID;
|
||||
qint32 m_i_ID;
|
||||
QDate m_airDate;
|
||||
QString m_szName;
|
||||
QString m_szOverview;
|
||||
qint16 m_iID;
|
||||
qint32 m_iID;
|
||||
QString m_szPosterPath;
|
||||
qint16 m_iSeasonNumber;
|
||||
QList<cEpisode*> m_episodeList;
|
||||
|
||||
+79
-31
@@ -1,4 +1,5 @@
|
||||
#include "cserie.h"
|
||||
#include "cfanarttv.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <QStringList>
|
||||
@@ -346,22 +347,22 @@ QString cSerie::freebaseID()
|
||||
return(m_szFreebaseID);
|
||||
}
|
||||
|
||||
void cSerie::setTVDBID(const qint16& iTVDBID)
|
||||
void cSerie::setTVDBID(const qint32& iTVDBID)
|
||||
{
|
||||
m_iTVDBID = iTVDBID;
|
||||
}
|
||||
|
||||
qint16 cSerie::tvdbID()
|
||||
qint32 cSerie::tvdbID()
|
||||
{
|
||||
return(m_iTVDBID);
|
||||
}
|
||||
|
||||
void cSerie::setTVRageID(const qint16& iTVRageID)
|
||||
void cSerie::setTVRageID(const qint32& iTVRageID)
|
||||
{
|
||||
m_iTVRageID = iTVRageID;
|
||||
}
|
||||
|
||||
qint16 cSerie::tvrageID()
|
||||
qint32 cSerie::tvrageID()
|
||||
{
|
||||
return(m_iTVRageID);
|
||||
}
|
||||
@@ -484,12 +485,15 @@ bool cSerie::save(QSqlDatabase &db)
|
||||
QSqlQuery querySerie;
|
||||
QSqlQuery querySeason;
|
||||
QSqlQuery queryEpisode;
|
||||
QSqlQuery queryFanart;
|
||||
|
||||
querySerie.prepare("INSERT INTO serie (seriesID,seriesName,originalName,backdropPath,createdBy,homepage,lastAired,languages,networks,nrEpisodes,nrSeasons,originCountries,originalLanguage,popularity,posterPath,productionCompanies,type,voteAverage,voteCount,overview,firstAired,cast,crew,genre,imdbid,freebasemid,freebaseid,tvdbid,tvrageid,status,download,cliffhanger)"
|
||||
" VALUES (:seriesID,:seriesName,:originalName,:backdropPath,:createdBy,:homepage,:lastAired,:languages,:networks,:nrEpisodes,:nrSeasons,:originCountries,:originalLanguage,:popularity,:posterPath,:productionCompanies,:type,:voteAverage,:voteCount,:overview,:firstAired,:cast,:crew,:genre,:imdbid,:freebasemid,:freebaseid,:tvdbid,:tvrageid,:status,:download,:cliffhanger);");
|
||||
querySeason.prepare("INSERT INTO season (_id,airDate,name,overview,id,posterPath,seasonNumber,seriesID) VALUES (:_id,:airDate,:name,:overview,:id,:posterPath,:seasonNumber,:seriesID);");
|
||||
queryEpisode.prepare("INSERT INTO episode (id,name,episodeNumber,airDate,guestStars,overview,productioncode,seasonNumber,seasonID,seriesID,stillPath,voteAverage,voteCount,crew,state)"
|
||||
" VALUES (:id,:name,:episodeNumber,:airDate,:guestStars,:overview,:productioncode,:seasonNumber,:seasonID,:seriesID,:stillPath,:voteAverage,:voteCount,:crew,:state);");
|
||||
queryFanart.prepare("INSERT INTO fanart (id,type,url,language,likes,season,active,seriesID) VALUES (:id,:type,:url,:language,:likes,:season,:active,:seriesID);");
|
||||
|
||||
db.transaction();
|
||||
query.exec(QString("SELECT seriesID FROM serie WHERE seriesID=%1;").arg(seriesID()));
|
||||
if(!query.next())
|
||||
@@ -551,31 +555,44 @@ bool cSerie::save(QSqlDatabase &db)
|
||||
{
|
||||
cEpisode* lpEpisode = episodeList.at(episode);
|
||||
|
||||
//query.bindValue(":episodeID", lpEpisode->id());
|
||||
//query.exec();
|
||||
//if(!query.next())
|
||||
queryEpisode.bindValue(":id", lpEpisode->id());
|
||||
queryEpisode.bindValue(":name", lpEpisode->name());
|
||||
queryEpisode.bindValue(":episodeNumber", lpEpisode->episodeNumber());
|
||||
queryEpisode.bindValue(":airDate", lpEpisode->airDate());
|
||||
queryEpisode.bindValue(":guestStars", lpEpisode->guestStars().join("|"));
|
||||
queryEpisode.bindValue(":overview", lpEpisode->overview());
|
||||
queryEpisode.bindValue(":productioncode", lpEpisode->productionCode());
|
||||
queryEpisode.bindValue(":seasonNumber", lpEpisode->seasonNumber());
|
||||
queryEpisode.bindValue(":seasonID", lpEpisode->seasonID());
|
||||
queryEpisode.bindValue(":seriesID", lpEpisode->seriesID());
|
||||
queryEpisode.bindValue(":stillPath", lpEpisode->stillPath());
|
||||
queryEpisode.bindValue(":voteAverage", lpEpisode->voteAverage());
|
||||
queryEpisode.bindValue(":voteCount", lpEpisode->voteCount());
|
||||
queryEpisode.bindValue(":crew", lpEpisode->crew().join("|"));
|
||||
queryEpisode.bindValue(":state", lpEpisode->state());
|
||||
if(queryEpisode.exec())
|
||||
{
|
||||
queryEpisode.bindValue(":id", lpEpisode->id());
|
||||
queryEpisode.bindValue(":name", lpEpisode->name());
|
||||
queryEpisode.bindValue(":episodeNumber", lpEpisode->episodeNumber());
|
||||
queryEpisode.bindValue(":airDate", lpEpisode->airDate());
|
||||
queryEpisode.bindValue(":guestStars", lpEpisode->guestStars().join("|"));
|
||||
queryEpisode.bindValue(":overview", lpEpisode->overview());
|
||||
queryEpisode.bindValue(":productioncode", lpEpisode->productionCode());
|
||||
queryEpisode.bindValue(":seasonNumber", lpEpisode->seasonNumber());
|
||||
queryEpisode.bindValue(":seasonID", lpEpisode->seasonID());
|
||||
queryEpisode.bindValue(":seriesID", lpEpisode->seriesID());
|
||||
queryEpisode.bindValue(":stillPath", lpEpisode->stillPath());
|
||||
queryEpisode.bindValue(":voteAverage", lpEpisode->voteAverage());
|
||||
queryEpisode.bindValue(":voteCount", lpEpisode->voteCount());
|
||||
queryEpisode.bindValue(":crew", lpEpisode->crew().join("|"));
|
||||
queryEpisode.bindValue(":state", lpEpisode->state());
|
||||
if(queryEpisode.exec())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int x = 0;x < m_fanartList.count();x++)
|
||||
{
|
||||
cFanart* lpFanart = m_fanartList.at(x);
|
||||
queryFanart.bindValue(":id", lpFanart->id());
|
||||
queryFanart.bindValue(":type", lpFanart->type());
|
||||
queryFanart.bindValue(":url", lpFanart->url());
|
||||
queryFanart.bindValue(":language", lpFanart->language());
|
||||
queryFanart.bindValue(":likes", lpFanart->likes());
|
||||
queryFanart.bindValue(":season", lpFanart->season());
|
||||
queryFanart.bindValue(":active", lpFanart->active());
|
||||
queryFanart.bindValue(":seriesID", seriesID());
|
||||
if(queryFanart.exec())
|
||||
{
|
||||
}
|
||||
else
|
||||
qDebug() << queryFanart.lastError().text();
|
||||
}
|
||||
}
|
||||
else
|
||||
qDebug() << querySerie.lastError().text();
|
||||
@@ -590,6 +607,14 @@ bool cSerie::del(QSqlDatabase& db)
|
||||
QSqlQuery query;
|
||||
|
||||
db.transaction();
|
||||
|
||||
if(m_fanartList.count())
|
||||
{
|
||||
query.prepare("DELETE FROM fanart WHERE seriesID=:seriesID;");
|
||||
query.bindValue(":seriesID", seriesID());
|
||||
query.exec();
|
||||
}
|
||||
|
||||
query.prepare("DELETE FROM episode WHERE seriesID=:seriesID;");
|
||||
query.bindValue(":seriesID", seriesID());
|
||||
query.exec();
|
||||
@@ -672,14 +697,27 @@ void cSerie::deleteResources()
|
||||
m_seasonList.at(z)->deleteResources();
|
||||
}
|
||||
|
||||
void cSerie::loadFanart()
|
||||
{
|
||||
cFanartTV fanartTV;
|
||||
m_fanartList = fanartTV.loadFanartSerie(tvdbID());
|
||||
}
|
||||
|
||||
cFanartList cSerie::fanartList()
|
||||
{
|
||||
return(m_fanartList);
|
||||
}
|
||||
|
||||
void cSerie::setFanartList(const cFanartList& fanartList)
|
||||
{
|
||||
m_fanartList = fanartList;
|
||||
}
|
||||
|
||||
cSerie* cSerieList::add(const qint32& iID)
|
||||
{
|
||||
for(int z = 0;z < count();z++)
|
||||
{
|
||||
if(at(z)->seriesID() == iID)
|
||||
return(at(z));
|
||||
}
|
||||
cSerie* lpNew = new cSerie;
|
||||
cSerie* lpNew = find(iID);
|
||||
if(!lpNew)
|
||||
lpNew = new cSerie;
|
||||
lpNew->setSeriesID(iID);
|
||||
append(lpNew);
|
||||
return(lpNew);
|
||||
@@ -696,6 +734,16 @@ cSerie* cSerieList::add(cSerie* lpSerie)
|
||||
return(lpSerie);
|
||||
}
|
||||
|
||||
cSerie* cSerieList::find(const qint32& iID)
|
||||
{
|
||||
for(int x = 0;x < count();x++)
|
||||
{
|
||||
if(at(x)->seriesID() == iID)
|
||||
return(at(x));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
qint16 cSerieList::minSeason()
|
||||
{
|
||||
qint16 iMin = 9999;
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
#include "cseason.h"
|
||||
#include "cfanart.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QDate>
|
||||
@@ -103,11 +104,11 @@ public:
|
||||
void setFreebaseID(const QString& szFreebaseID);
|
||||
QString freebaseID();
|
||||
|
||||
void setTVDBID(const qint16& iTVDBID);
|
||||
qint16 tvdbID();
|
||||
void setTVDBID(const qint32& iTVDBID);
|
||||
qint32 tvdbID();
|
||||
|
||||
void setTVRageID(const qint16& iTVRageID);
|
||||
qint16 tvrageID();
|
||||
void setTVRageID(const qint32& iTVRageID);
|
||||
qint32 tvrageID();
|
||||
|
||||
void setStatus(const QString& szStatus);
|
||||
QString status();
|
||||
@@ -145,6 +146,10 @@ public:
|
||||
|
||||
void updateState();
|
||||
void deleteResources();
|
||||
|
||||
void loadFanart();
|
||||
void setFanartList(const cFanartList& fanartList);
|
||||
cFanartList fanartList();
|
||||
private:
|
||||
QString m_szSeriesName;
|
||||
QString m_szOriginalName;
|
||||
@@ -173,11 +178,12 @@ private:
|
||||
QString m_szIMDBID;
|
||||
QString m_szFreebaseMID;
|
||||
QString m_szFreebaseID;
|
||||
qint16 m_iTVDBID;
|
||||
qint16 m_iTVRageID;
|
||||
qint32 m_iTVDBID;
|
||||
qint32 m_iTVRageID;
|
||||
QString m_szStatus;
|
||||
QString m_szDownload;
|
||||
bool m_bCliffhanger;
|
||||
cFanartList m_fanartList;
|
||||
QList<cSeason*> m_seasonList;
|
||||
};
|
||||
|
||||
@@ -189,6 +195,8 @@ public:
|
||||
cSerie* add(const qint32& iID);
|
||||
cSerie* add(cSerie* lpSerie);
|
||||
|
||||
cSerie* find(const qint32& iID);
|
||||
|
||||
qint16 minSeason();
|
||||
qint16 maxSeason();
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
using std::pair;
|
||||
//using std::pair;
|
||||
|
||||
|
||||
cTheMovieDBV3::cTheMovieDBV3()
|
||||
|
||||
@@ -23,9 +23,6 @@ public:
|
||||
cSerie* loadSerie(const QString& szIMDBID);
|
||||
private:
|
||||
QString m_szToken;
|
||||
// QStringList getActors(const qint32& iID);
|
||||
// void getEpisodes(cSerie* lpSerie, const QString& szLanguage);
|
||||
// cEpisode* getEpisode(const qint32& iID, const QString& szLanguage);
|
||||
};
|
||||
|
||||
#endif // CTHEMOVIEDBV3_H
|
||||
|
||||
@@ -49,6 +49,23 @@ void cUpdateThread::run()
|
||||
szFailed += lpSerie->seriesName();
|
||||
continue;
|
||||
}
|
||||
lpSerieNew->loadFanart();
|
||||
cFanartList fanartList = lpSerie->fanartList();
|
||||
cFanartList fanartListNew = lpSerieNew->fanartList();
|
||||
for(int x = 0;x < fanartListNew.count();x++)
|
||||
{
|
||||
cFanart* lpFanartNew = fanartListNew.at(x);
|
||||
|
||||
for(int y = 0;y < fanartList.count();y++)
|
||||
{
|
||||
cFanart* lpFanart = fanartList.at(y);
|
||||
if(lpFanartNew->id() == lpFanart->id())
|
||||
{
|
||||
lpFanartNew->setActive(lpFanart->active());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
lpSerieNew->setDownload(lpSerie->download());
|
||||
for(int x = 0;x < lpSerieNew->seasonList().count();x++)
|
||||
{
|
||||
|
||||
+6
-2
@@ -35,7 +35,9 @@ SOURCES += main.cpp\
|
||||
cmovieedit.cpp \
|
||||
cmovieimage.cpp \
|
||||
cscrollarea.cpp \
|
||||
cpixmapwidget.cpp
|
||||
cpixmapwidget.cpp \
|
||||
cfanart.cpp \
|
||||
cfanarttv.cpp
|
||||
|
||||
HEADERS += cmainwindow.h \
|
||||
cserie.h \
|
||||
@@ -59,7 +61,9 @@ HEADERS += cmainwindow.h \
|
||||
cmovieedit.h \
|
||||
cmovieimage.h \
|
||||
cscrollarea.h \
|
||||
cpixmapwidget.h
|
||||
cpixmapwidget.h \
|
||||
cfanart.h \
|
||||
cfanarttv.h
|
||||
|
||||
FORMS += cmainwindow.ui \
|
||||
csearch.ui \
|
||||
|
||||
Reference in New Issue
Block a user