epno = 0;
length = 0;
state = 0;
- special = false;
recap = false;
- opening = false;
- ending = false;
rating = 0;
votes = 0;
myVote = 0;
QSqlQuery &q = prepare(
"SELECT e.eid, e.aid, e.anidb_update, e.entry_update, e.my_update, e.epno, "
" e.title_english, e.title_romaji, e.title_kanji, e.length, e.airdate, e.state, "
- " e.special, e.recap, e.opening, e.ending, e.rating, e.votes, e.my_vote, e.my_vote_date "
+ " e.type, e.recap, e.rating, e.votes, e.my_vote, e.my_vote_date "
" FROM episode e "
" JOIN anime a ON (a.aid = e.aid)"
" WHERE a.aid = :aid ");
QSqlQuery &q = prepare(
"SELECT eid, aid, anidb_update, entry_update, my_update, epno, "
" title_english, title_romaji, title_kanji, length, airdate, state, "
- " special, recap, opening, ending, rating, votes, my_vote, my_vote_date "
+ " type, recap, rating, votes, my_vote, my_vote_date "
" FROM episode "
" WHERE eid = :eid ");
" aid = :aid, anidb_update = :anidbUpdate, entry_update = :entryUpdate, "
" my_update = :myUpdate, epno = :epno, title_english = :titleEnglish, "
" title_romaji = :titleRomaji, title_kanji = :titleKanji, length = :length, "
- " airdate = :airdate, state = :state, special = :special, recap = :recap, "
- " opening = :opening, ending = :ending, rating = :rating, votes = :votes, "
+ " airdate = :airdate, state = :state, type = :type, recap = :recap, "
+ " rating = :rating, votes = :votes, "
" my_vote = :myVote, my_vote_date = :myVoteDate "
" WHERE eid = :eid ");
q.bindValue(":length", episode.length);
q.bindValue(":airdate", episode.airdate);
q.bindValue(":state", episode.state);
- q.bindValue(":special", episode.special);
+ q.bindValue(":type", episode.type);
q.bindValue(":recap", episode.recap);
- q.bindValue(":opening", episode.opening);
- q.bindValue(":ending", episode.ending);
q.bindValue(":rating", episode.rating);
q.bindValue(":votes", episode.votes);
q.bindValue(":myVote", episode.myVote);
QSqlQuery &q = prepare(
"INSERT INTO episode VALUES(:eid, :aid, :anidbUpdate, :entryUpdate, :myUpdate, :epno, "
" :titleEnglish, :titleRomaji, :titleKanji, :length, :airdate, "
- " :state, :special, :recap, :openineg, :ending, :rating, "
+ " :state, :type, :recap, :rating, "
" :votes, :myVote, :myVoteDate) ");
q.bindValue(":eid", episode.eid);
q.bindValue(":length", episode.length);
q.bindValue(":airdate", episode.airdate);
q.bindValue(":state", episode.state);
- q.bindValue(":special", episode.special);
+ q.bindValue(":type", episode.type);
q.bindValue(":recap", episode.recap);
- q.bindValue(":opening", episode.opening);
- q.bindValue(":ending", episode.ending);
q.bindValue(":rating", episode.rating);
q.bindValue(":votes", episode.votes);
q.bindValue(":myVote", episode.myVote);
e.length = q.value(9).toInt();
e.airdate = q.value(10).toDateTime();
e.state = q.value(11).toInt();
- e.special = q.value(12).toBool();
+ e.type = q.value(12).toString();
e.recap = q.value(13).toBool();
- e.opening = q.value(14).toBool();
- e.ending = q.value(15).toBool();
- e.rating = q.value(16).toDouble();
- e.votes = q.value(17).toInt();
- e.myVote = q.value(18).toDouble();
- e.myVoteDate = q.value(19).toDateTime();
+ e.rating = q.value(14).toDouble();
+ e.votes = q.value(15).toInt();
+ e.myVote = q.value(16).toDouble();
+ e.myVoteDate = q.value(17).toDateTime();
return e;
}
int length;
QDateTime airdate;
int state;
- bool special;
+ QString type;
bool recap;
- bool opening;
- bool ending;
double rating;
int votes;
double myVote;
e.state = readElementText().toInt();
}
else if (name() == "EpStateSpecial") {
- e.special = bool(readElementText().toInt());
+ if (bool(readElementText().toInt()))
+ e.type = "S";
}
else if (name() == "EpStateRecap") {
e.recap = bool(readElementText().toInt());
}
else if (name() == "EpStateOp") {
- e.opening = bool(readElementText().toInt());
+ if (bool(readElementText().toInt()))
+ e.type = "C";
}
else if (name() == "EpStateEnd") {
- e.ending = bool(readElementText().toInt());
+ if (bool(readElementText().toInt()))
+ e.type = "C";
}
else if (name() == "EpRating") {
e.rating = readElementText().toDouble();
if (e.airdate.isValid())
current.airdate = e.airdate;
current.state = e.state;
- current.special = e.special;
+ current.type = e.type;
current.recap = e.recap;
- current.opening = e.opening;
- current.ending = e.ending;
}else{qDebug() << "No update required" << current.eid;}
current.entryUpdate = QDateTime::currentDateTime();
next.length = reply->length();
next.airdate = reply->airDate();
// next.state - State is a bitfield and will be split into parts
- next.special = reply->type() == 'S';
- // I see no way of getting these via UDP api.
+ next.type = reply->type();
+ // I see no way of getting this via UDP api.
// next.recap
- // next.opening
- // next.ending
next.rating = reply->rating();
next.votes = reply->votes();
o->state = val;
}
-bool Episode::read_special() const
+QString Episode::read_type() const
{
auto o = thisObj();
- if (!o) return bool();
- return o->special;
+ if (!o) return QString();
+ return o->type;
}
-void Episode::write_special(bool val)
+void Episode::write_type(QString val)
{
auto o = thisObj();
if (!o) return;
- o->special = val;
+ o->type = val;
}
bool Episode::read_recap() const
o->recap = val;
}
-bool Episode::read_opening() const
-{
- auto o = thisObj();
- if (!o) return bool();
- return o->opening;
-}
-
-void Episode::write_opening(bool val)
-{
- auto o = thisObj();
- if (!o) return;
- o->opening = val;
-}
-
-bool Episode::read_ending() const
-{
- auto o = thisObj();
- if (!o) return bool();
- return o->ending;
-}
-
-void Episode::write_ending(bool val)
-{
- auto o = thisObj();
- if (!o) return;
- o->ending = val;
-}
-
double Episode::read_rating() const
{
auto o = thisObj();
Q_PROPERTY(int length READ read_length WRITE write_length)
Q_PROPERTY(QDateTime airdate READ read_airdate WRITE write_airdate)
Q_PROPERTY(int state READ read_state WRITE write_state)
- Q_PROPERTY(bool special READ read_special WRITE write_special)
+ Q_PROPERTY(QString type READ read_type WRITE write_type)
Q_PROPERTY(bool recap READ read_recap WRITE write_recap)
- Q_PROPERTY(bool opening READ read_opening WRITE write_opening)
- Q_PROPERTY(bool ending READ read_ending WRITE write_ending)
Q_PROPERTY(double rating READ read_rating WRITE write_rating)
Q_PROPERTY(int votes READ read_votes WRITE write_votes)
Q_PROPERTY(double myVote READ read_myVote WRITE write_myVote)
int read_state() const;
void write_state(int val);
- bool read_special() const;
- void write_special(bool val);
+ QString read_type() const;
+ void write_type(QString val);
bool read_recap() const;
void write_recap(bool val);
- bool read_opening() const;
- void write_opening(bool val);
-
- bool read_ending() const;
- void write_ending(bool val);
-
double read_rating() const;
void write_rating(double val);
INSERT INTO config VALUES ('enableRename', '0', true);
INSERT INTO config VALUES ('fileFilters', '*.mkv *.mp4 *.ogg *.ogm *.wmv *.avi *.mpg *.flv', true);
+
+
+-- Episode types
+INSERT INTO episode_type VALUES ('', 'Normal', 0);
+INSERT INTO episode_type VALUES ('S', 'Special', 1);
+INSERT INTO episode_type VALUES ('C', 'Credits/Opening/Ending', 2);
+INSERT INTO episode_type VALUES ('T', 'Trailer/Promo/Ads', 3);
+INSERT INTO episode_type VALUES ('P', 'Parody/Fandub', 4);
+INSERT INTO episode_type VALUES ('O', 'Other', 5);
+INSERT INTO episode_type VALUES ('OP', 'Opening/Ending', 6);
+CREATE TYPE episode_type_enum AS ENUM ('', 'S', 'C', 'T', 'P', 'O', 'OP');
+
CREATE TABLE anime (
aid integer NOT NULL,
anidb_update timestamp without time zone,
length integer,
airdate timestamp without time zone,
state integer,
- special boolean,
+ type episode_type_enum NOT NULL DEFAULT '',
recap boolean,
- opening boolean,
- ending boolean,
rating numeric(4,2),
votes integer,
my_vote numeric(4,2),
);
CREATE INDEX episode_aid_fk ON episode USING btree (aid);
+CREATE TABLE episode_type
+(
+ type episode_type_enum NOT NULL,
+ name character varying(200),
+ ordering integer NOT NULL DEFAULT 0,
+ CONSTRAINT episode_type_pk PRIMARY KEY (type )
+);
+
CREATE TABLE file (
fid integer NOT NULL,
eid integer,
a.temp_rating, a.temp_votes, a.my_vote AS anime_my_vote, a.my_vote_date AS anime_my_vote_date, a.my_temp_vote, a.my_temp_vote_date,
(SELECT max(episode.epno) AS highest_epno FROM episode WHERE episode.aid = f.aid) AS highest_epno,
e.anidb_update AS episode_anidb_update, e.entry_update AS episode_entry_update, e.my_update AS episode_my_update, e.epno, e.title_english AS episode_title_english, e.title_romaji AS episode_title_romaji,
- e.title_kanji AS episode_title_kanji, e.length AS episode_length, e.airdate, e.state, e.special, e.recap, e.opening, e.ending, e.rating, e.votes, e.my_vote, e.my_vote_date,
+ e.title_kanji AS episode_title_kanji, e.length AS episode_length, e.airdate, e.state, e.type, e.recap, e.rating, e.votes, e.my_vote, e.my_vote_date,
f.anidb_update, f.entry_update, f.my_update, f.ed2k, f.size, f.length, f.extension, f.group_name, f.group_name_short, f.crc, f.release_date, f.version, f.censored, f.source, f.quality_id,
f.quality, f.resolution, f.video_codec, f.audio_codec, f.audio_language, f.subtitle_language, f.aspect_ratio, f.my_watched, f.my_state, f.my_file_state, f.my_storage, f.my_source,
f.my_other, fl.host_id, fl.path, fl.renamed, fl.failed_rename