from pathlib import Path
from threading import Thread
from queue import Queue
+from sqlite3 import Cursor
# non-included libs
import googleapiclient.discovery # type: ignore
from mpv import MPV # type: ignore
self._renew_last_update()
else:
self.last_update = last_update
+ self._hash_on_last_update = hash(self)
+
+ def __hash__(self) -> int:
+ return hash(f'{self.digest.b64}|{self.rel_path}|{self.flags}|'
+ f'{self.yt_id}|{self.last_update}|{self.tags_str}')
def _renew_last_update(self):
+ print("DEBUG calling_renew_last_update", self.rel_path)
self.last_update = DatetimeStr(datetime.now().strftime(TIMESTAMP_FMT))
+ self._hash_on_last_update = hash(self)
+
+ def save(self, conn: BaseDbConn) -> Cursor:
+ """Extend super().save by new .last_update if sufficient changes."""
+ if hash(self) != self._hash_on_last_update:
+ self._renew_last_update()
+ return super().save(conn)
@classmethod
def get_by_yt_id(cls, conn: BaseDbConn, yt_id: YoutubeId) -> Self:
self.flags = FlagsInt(0)
for flag in flags:
self.flags = FlagsInt(self.flags | flag)
- self._renew_last_update()
def is_flag_set(self, flag_name: FlagName) -> bool:
"""Return if flag of flag_name is set in flags field."""