+
+ def last_update_for(self,
+ conn: DbConn,
+ yt_id: YoutubeId
+ ) -> dict[str, str]:
+ """Retrieve ._last_updates[yt_id] but reset to 'absent' if needed."""
+ if yt_id in self._last_updates:
+ if self._last_updates[yt_id]['status'] != 'present':
+ return self._last_updates[yt_id]
+ try:
+ file = VideoFile.get_by_yt_id(conn, yt_id)
+ if not file.present:
+ self._update_status(yt_id, 'absent')
+ except NotFoundException:
+ self._update_status(yt_id, 'absent')
+ else:
+ self._update_status(yt_id, 'absent')
+ return self._last_updates[yt_id]
+
+ def _update_status(self,
+ yt_id: YoutubeId,
+ status: str,
+ path: str = '',
+ digest: str = ''
+ ) -> None:
+ self._last_updates[yt_id] = {'status': status, 'time': _now_string()}
+ for k, v in [('path', path), ('digest', digest)]:
+ if k:
+ self._last_updates[yt_id] |= {k: v}