pvr: Mark recordings 'watched' / 'unwatched' #508

wants to merge 4 commits into


None yet

2 participants


This is my first contribution to the pvr branch, so please be patient :-)
Great that we have the recording's watched state visible in the recordings view.

This PR basically adds 2 new features --> watched/unwatched in context menu and client api to sync watched state

2dbda19 Adds 'mark watched' / 'unwatched' to the recording's context menu that changes the watched state in the video database. Works for both, single files and complete folders. The code that is actually changing the values in the database has been taken from GUIWindowVideoBase::MarkWatched.

fc7452b Adds an client API function "MarkRecordingWatched". This allows to set the watched state on the client (if supported). For some clients like mythtv, this functionality is quite essential as it allows the backend to maintain the disk space better (watched recordings can be removed when running out of space). Another advantage is that you have a consistent view when using different frontend / webinterface with the backend.

a89437b Uses the new client API to set the watched state on the client in video database SetPlayCount. This syncs the state with the client for example after watching a recording.

Looking forward to your comments!

Updated this PR to also contain the API (cause that one depends on the context menu). Hope that is ok for you


looking good. 1 request: please change it into a watched counter instead of a boolean. if the backend only supports watched/unwatched, convert it in the add-on.

@opdenkamp opdenkamp was assigned Apr 18, 2012


@opdenkamp opdenkamp and 1 other commented on an outdated diff Apr 20, 2012
@@ -93,6 +93,19 @@ void CGUIWindowPVRRecordings::GetContextButtons(int itemNumber, CContextButtons
buttons.Add(CONTEXT_BUTTON_RESUME_ITEM, resumeString);
+ if (pItem->m_bIsFolder)
+ {
+ // Have both options for folders since we don't know whether all childs are watched/unwatched
+ buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); /* Mark as UnWatched */
+ buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); /* Mark as Watched */
+ }
+ else
+ {
+ if (pItem->GetOverlayImage().Equals("OverlayWatched.png"))
opdenkamp Apr 20, 2012 owner

without looking into the CFileItem code, I know there must be a better way to check the watched status than like this.

fetzerch Apr 21, 2012

Forget my comment below. I'll change it to the play count. For folders we should keep both buttons anyways...

Thanks for reviewing. I agree that this is a big ugly. But currently I don't see how this could be handled correctly:

  • CGUIListItem usues the enum GUIIconOverlay when you set the overlay. But there's no public function to get the overlay as enum.
  • I could change it to use the play count values of the VideoInfoTag (like it is done in GUIWindowMusicNav). But I'm already working on the watched overlay for the recording subfolders. As soon as that is finished I'd like to remove the 'if (pItem->m_bIsFolder)' and only use the '.Equls("OverlayWatched")'. Because we don't have VideoInfoTags for folders.
  • GUIWindowVideoNav btw uses also the '.Equls("OverlayWatched")' code so we're not using it more ugly that they do ;)



Added new commit to the PR. This enables the watched overlay also for the recording folders.

@opdenkamp opdenkamp and 1 other commented on an outdated diff Apr 24, 2012
@@ -140,6 +151,20 @@ void CPVRRecordings::GetSubDirectories(const CStdString &strBase, CFileItemList
pFileItem->m_dateTime = current->RecordingTimeAsLocalTime();
+ // Initialize folder overlay from play count (either directly from client or from video database)
+ CVideoDatabase db;
+ bool supportsPlayCount = g_PVRClients->GetAddonCapabilities(current->m_iClientId).bSupportsRecordingPlayCount;
+ if ((supportsPlayCount && current->m_iRecPlayCount > 0) ||
+ (!supportsPlayCount && db.Open() && db.GetPlayCount(*pFileItem) > 0))
+ {
+ pFileItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, true);
opdenkamp Apr 24, 2012 owner

looks like you got the wrong overlay here.

fetzerch Apr 25, 2012

The api is a bit strange 'unwatched' with 'true' will use the next enum value which is 'watched'.
However, I changed it to
pFileItem->SetOverlayImage(CGUIListItem::ICON_OVERLAY_WATCHED, false);


Rebased and fixed the overlay as commented above.


thanks. one last thing before this can be merged: please add the method to each client's "UNUSED API FUNCTIONS" list, in the bottom of the client.cpp file.

fetzerch added some commits Apr 19, 2012
@fetzerch fetzerch PVR mark as watched: added SetRecordingPlayCount (API) with client ca…
…pability and watched flag in PVRRecording(s).

Allow read/write play count from/to client using context menu.
Mapped watched overlay to client play count instead of using video database (if supported by client).
@fetzerch fetzerch PVR mark as watched: Write client play count on video database SetPla…

This marks a recording as watched on the client after recording has been played.
@fetzerch fetzerch Show watched overlay for recording subfolders. 3cb1d94

done in 5098d0d

@opdenkamp opdenkamp closed this in ac181de Jun 15, 2012

it needed a couple of little fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment