return readOpenFileData(q);
}
+OpenFileData Database::nextEpisode(int fid)
+{
+ QSqlQuery &q = prepare(R"(
+ SELECT f.fid, a.title_romaji, e.title_english, e.epno, fl.path, fl.host_id,
+ CASE WHEN split_part(f.resolution, 'x', 1) = '' OR split_part(f.resolution, 'x', 2) = '' THEN 0 ELSE split_part(f.resolution, 'x', 1)::int * split_part(f.resolution, 'x', 2)::int END pixels
+ FROM file f
+ JOIN episode e ON f.eid = e.eid
+ JOIN anime a ON a.aid = f.aid
+ JOIN file_location fl ON fl.fid = f.fid
+ WHERE f.fid = (SELECT f2.fid
+ FROM file f
+ JOIN episode e ON f.eid = e.eid
+ JOIN episode e2 ON e2.aid = e.aid AND ((e2.epno > e.epno AND e2.type = e.type) OR e2.type > e.type) -- No type ordering here (but it works as the enum is ordered)
+ JOIN episode_type et ON et.type = e2.type
+ JOIN file f2 ON f2.eid = e2.eid AND f2.fid <> f.fid
+ WHERE f.fid = :fid
+ ORDER BY et.ordering DESC, e2.epno ASC -- et.ordering should be DESC: 99 -> S1 (not O1)
+ LIMIT 1)
+ )");
+ q.bindValue(":fid", fid);
+
+ return readOpenFileData(q);
+}
+
+OpenFileData Database::previousEpisode(int fid)
+{
+ QSqlQuery &q = prepare(R"(
+ SELECT f.fid, a.title_romaji, e.title_english, e.epno, fl.path, fl.host_id,
+ CASE WHEN split_part(f.resolution, 'x', 1) = '' OR split_part(f.resolution, 'x', 2) = '' THEN 0 ELSE split_part(f.resolution, 'x', 1)::int * split_part(f.resolution, 'x', 2)::int END pixels
+ FROM file f
+ JOIN episode e ON f.eid = e.eid
+ JOIN anime a ON a.aid = f.aid
+ JOIN file_location fl ON fl.fid = f.fid
+ WHERE f.fid = (SELECT f2.fid
+ FROM file f
+ JOIN episode e ON f.eid = e.eid
+ JOIN episode e2 ON e2.aid = e.aid AND ((e2.epno < e.epno AND e2.type = e.type) OR e2.type < e.type) -- No type ordering here (but it works as the enum is ordered)
+ JOIN episode_type et ON et.type = e2.type
+ JOIN file f2 ON f2.eid = e2.eid AND f2.fid <> f.fid
+ WHERE f.fid = :fid
+ ORDER BY et.ordering ASC, e2.epno DESC -- et.ordering should be ASC: C1 -> S99 (not 99)
+ LIMIT 1)
+ )");
+ q.bindValue(":fid", fid);
+
+ return readOpenFileData(q);
+}
+
HostInfo Database::getHostInfo(const QString &hostName)
{
QSqlQuery &q = prepare(
LocalMyList::OpenFileData openFile(int fid);
LocalMyList::OpenFileData openEpisode(int aid, int epno, const QString &type = "");
+ /**
+ * @brief nextEpisode return the next available episode
+ * @param fid the id for which the next episode is to be found
+ * @return OpenFileData with fid != 0 if a next episode is found
+ */
+ LocalMyList::OpenFileData nextEpisode(int fid);
+
+ /**
+ * @brief previousEpisode return the prefioud available episode
+ * @param fid the id for which the previous episode is to be found
+ * @return OpenFileData with fid != 0 if a previous episode is found
+ */
+ LocalMyList::OpenFileData previousEpisode(int fid);
+
LocalMyList::HostInfo getHostInfo(const QString &hostName);
QVariantMap getConfig();