[mythtv] [PATCH] optionally re-record auto-expired programs
Ed Wildgoose
lists at wildgooses.com
Tue Oct 5 12:25:18 UTC 2004
Aran Cox wrote:
>This is a version of a patch that I've been applying to mythtv since
>0.11. It adds an option in the Mythfrontend/Setup/TV/General settings
>which causes the backend to delete the oldrecorded entry for any show
>which is auto-expired due to lack of disk space. (I don't think this
>effects the min/max episode expiry, but perhaps it does.) The default
>is the current behavior, that is retain the oldrecorded entry.
>
>
What about making it re-record only shows that haven't been watched?
To add a "watched" flag I started adding some code in
programs/mythfrontend/playbackbox.cpp
diff -u -r1.171 playbackbox.cpp
--- ../../programs/mythfrontend/playbackbox.cpp 17 Sep 2004 21:57:47
-0000 1.171
+++ ../../programs/mythfrontend/playbackbox.cpp 5 Oct 2004 11:49:04 -0000
@@ -1400,6 +1400,7 @@
if (tv->Playback(tvrec))
{
+cerr << "Starting playback\n";
while (tv->GetState() != kState_None)
{
qApp->unlock();
@@ -1407,6 +1408,7 @@
usleep(10000);
qApp->lock();
}
+cerr << "Finishing playback\n";
}
playingSomething = false;
Change the above to test length of playback period is something
reasonable like: "5 mins, or more than half the show length, whichever
is less". This should cover the case of people previewing a film to
check it's recorded OK, yet also cover the case of someone recording a 5
min cartoon and really watching it.
I added an extra column to the programs table, which you then need to
add some helper stubs to fill in (programinfo.cpp)
diff -u -r1.160 programinfo.cpp
--- ../libmythtv/programinfo.cpp 6 Sep 2004 19:43:59 -0000
1.160
+++ ../libmythtv/programinfo.cpp 5 Oct 2004 12:21:17 -0000
@@ -1096,6 +1096,47 @@
MythContext::DBError("Edit status update", querystr);
}
+bool ProgramInfo::IsViewed(QSqlDatabase *db)
+{
+ MythContext::KickDatabase(db);
+
+ bool result = false;
+
+ QString starts = recstartts.toString("yyyyMMddhhmm");
+ starts += "00";
+
+ QString querystr = QString("SELECT viewed FROM recorded WHERE "
+ "chanid = '%1' AND starttime = '%2';")
+ .arg(chanid).arg(starts);
+
+ QSqlQuery query = db->exec(querystr);
+ if (query.isActive() && query.numRowsAffected() > 0)
+ {
+ query.next();
+
+ result = query.value(0).toInt();
+ }
+
+ return result;
+}
+
+void ProgramInfo::SetViewed(bool viewed, QSqlDatabase *db)
+{
+ MythContext::KickDatabase(db);
+
+ QString starts = recstartts.toString("yyyyMMddhhmm");
+ starts += "00";
+
+ QString querystr = QString("UPDATE recorded SET viewed = '%1', "
+ "starttime = '%2' WHERE chanid = '%3' AND "
+ "starttime = '%4';").arg(viewed).arg(starts)
+
.arg(chanid).arg(starts);
+ QSqlQuery query = db->exec(querystr);
+ if (!query.isActive())
+ MythContext::DBError("Viewed status update", querystr);
+}
+
+
bool ProgramInfo::IsCommFlagged(QSqlDatabase *db)
{
MythContext::KickDatabase(db);
Index: ../libmythtv/programinfo.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/programinfo.h,v
retrieving revision 1.87
diff -u -r1.87 programinfo.h
--- ../libmythtv/programinfo.h 6 Sep 2004 19:44:00 -0000 1.87
+++ ../libmythtv/programinfo.h 5 Oct 2004 12:21:17 -0000
@@ -54,6 +54,7 @@
FL_AUTOEXP = 0x04,
FL_EDITING = 0x08,
FL_BOOKMARK = 0x10,
+ FL_VIEWED = 0x20,
};
enum RecStatusType {
@@ -149,6 +150,8 @@
long long GetBookmark(QSqlDatabase *db);
bool IsEditing(QSqlDatabase *db);
void SetEditing(bool edit, QSqlDatabase *db);
+ bool IsViewed(QSqlDatabase *db);
+ void SetViewed(bool viewed, QSqlDatabase *db);
bool IsCommFlagged(QSqlDatabase *db);
// 1 = flagged, 2 = processing
void SetCommFlagged(int flag, QSqlDatabase *db);
I don't know if you would like to finish this tweak off for me, but I
think it would be a useful addition to your patch (it's why I was adding
my bit in at all). I can think of lots of other uses for the "watched"
flag as well
I would also loose the option completely. Personally I think there are
far too many options already, and less is more. I would just make the
default be to keep the program if it's not watched yet, delete otherwise
Ed W
More information about the mythtv-dev
mailing list