Skip to content

Commit 7ba2ae1

Browse files
committed
media_printer
1 parent fc5cb56 commit 7ba2ae1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

xklb/media/media_printer.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def media_printer(args, data, units=None, media_len=None) -> None:
105105
if "f" not in print_args and "limit" in getattr(args, "defaults", []):
106106
media.reverse()
107107

108+
tables = args.db.table_names()
109+
108110
duration = sum(m.get("duration") or 0 for m in media)
109111
if "a" in print_args and ("Aggregate" not in media[0].get("path") or ""):
110112
if "count" in media[0]:
@@ -119,7 +121,7 @@ def media_printer(args, data, units=None, media_len=None) -> None:
119121
D["duration"] = duration
120122
D["avg_duration"] = duration / len(media)
121123

122-
if hasattr(args, "action"):
124+
if hasattr(args, "action") and 'history' in tables:
123125
if action in (SC.download, SC.download_status) and "time_downloaded" in m_columns:
124126
D["download_duration"] = cadence_adjusted_items(args, D["count"], time_column="time_downloaded")
125127
else:
@@ -151,7 +153,7 @@ def media_printer(args, data, units=None, media_len=None) -> None:
151153
marked = history.add(args, [d["path"] for d in media])
152154
log.warning(f"Marked {marked} metadata records as watched")
153155

154-
if "a" not in print_args and action == SC.download_status and "time_downloaded" in m_columns:
156+
if "a" not in print_args and 'history' in tables and action == SC.download_status and "time_downloaded" in m_columns:
155157
for m in media:
156158
m["download_duration"] = cadence_adjusted_items(
157159
args, m["never_downloaded"] + m["retry_queued"], time_column="time_downloaded"

0 commit comments

Comments
 (0)