autotako

Service to monitor moombox for completed livestream downloads to upload for distribution
git clone https://code.alwayswait.ing/autotako
Log | Files | Refs | README

commit 587238e7c535e734c93d539edf4c3bceee11e567
parent bb79743ca6618279023037bfd358f612b77a93b6
Author: archiveanon <>
Date:   Sun, 22 Mar 2026 15:30:15 +0000

Configure filtering stale tasks in page view

Diffstat:
Mconfig.example.toml | 4++++
Msrc/autotako/app.py | 10+++++++++-
Msrc/autotako/config.py | 2++
Msrc/autotako/job_render.py | 10++++++++++
4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/config.example.toml b/config.example.toml @@ -2,6 +2,10 @@ # autotako polls the status endpoint for updates moombox_url = "http://127.0.0.1:5000/" +# hide jobs older than this duration, specified in ISO8601 format +# because the perf of rendering 1000+ items is not good +max_visible_task_age = "P30D" + [autoupload] # whether or not automatic uploads are actually enabled # this is set to false for testing purposes (will print on streams that meet the criteria) diff --git a/src/autotako/app.py b/src/autotako/app.py @@ -60,10 +60,18 @@ def create_app(): async with httpx.AsyncClient() as client: result = await client.get(f"{config.moombox_url}/status") + now = datetime.datetime.now(tz=datetime.UTC) + jobs = [] for serialized_job in result.json(): try: - jobs.append(msgspec.convert(serialized_job, type=MoomboxJobInfo)) + job = msgspec.convert(serialized_job, type=MoomboxJobInfo) + if ( + config.max_visible_task_age is not None + and now - job.last_activity_datetime > config.max_visible_task_age + ): + continue + jobs.append(job) except msgspec.ValidationError: pass diff --git a/src/autotako/config.py b/src/autotako/config.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 +import datetime from contextvars import ContextVar import msgspec @@ -43,6 +44,7 @@ class AppConfig(msgspec.Struct): channels: list[ChannelConfig] = msgspec.field(name="channel", default_factory=list) webdav: WebDavConfig | None = None qbittorrent: QBittorrentConfig | None = None + max_visible_task_age: datetime.timedelta | None = None def get_channel_config_by_id(self, channel_id: str | None) -> ChannelConfig | None: if not channel_id: diff --git a/src/autotako/job_render.py b/src/autotako/job_render.py @@ -68,6 +68,7 @@ class MoomboxJobInfo(msgspec.Struct, kw_only=True, frozen=True): status: MoomboxDownloadStatus = MoomboxDownloadStatus.UNKNOWN output_paths: set[str] | None = msgspec.field(default_factory=set) scheduled_start_datetime: datetime.datetime | None = None + download_finish_datetime: datetime.datetime | None = None @property def uploadability_state(self) -> JobUploadCriteria | None: @@ -98,6 +99,15 @@ class MoomboxJobInfo(msgspec.Struct, kw_only=True, frozen=True): def output_pathobjs(self) -> set[pathlib.Path]: return set(map(pathlib.Path, self.output_paths or [])) + @property + def last_activity_datetime(self) -> datetime.datetime: + # this does not need to be very accurate + return ( + self.download_finish_datetime + or self.scheduled_start_datetime + or datetime.datetime.fromtimestamp(0, tz=datetime.UTC) + ) + def _extract_name_from_stream_title(title: str) -> str | None: """