diff options
-rwxr-xr-x | later | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -64,6 +64,7 @@ class TitleMap: self.update = update self.commit_to_disk = update self.ytdl = None + self.seen = set() try: with open(path) as handle: @@ -77,6 +78,8 @@ class TitleMap: sys.exit(f"later: cannot read title cache: {err}") def get(self, key): + self.seen.add(key) + if key in self.map: return self.map[key] @@ -119,9 +122,13 @@ class TitleMap: os.makedirs(later_cache_dir, exist_ok=True) + seen_entries = { + key: value for key, value in self.map.items() if key in self.seen + } + try: with open(self.path, "w") as handle: - json.dump(self.map, handle) + json.dump(seen_entries, handle) except OSError as err: sys.exit(f"later: cannot write title cache: {err}") |