Skip to content

Commit

Permalink
Include scanned count in status report message to indicate progress o…
Browse files Browse the repository at this point in the history
…n both original queue and lookahead ids
  • Loading branch information
trickerer01 committed Oct 16, 2024
1 parent 359975d commit 3d3c445
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ async def _state_reporter(self) -> None:
await sleep(base_sleep_time if len(self._seq) + self._queue.qsize() > 0 or self.waiting_for_scanner() else 1.0)
queue_size = len(self._seq) + self.get_scanner_workload_size()
ready_size = self._queue.qsize()
scan_count = self.get_scanned_count()
extra_count = max(0, scan_count - self._orig_count)
download_count = len(self._downloads_active)
write_count = len(self._writes_active)
queue_last = self._total_queue_size_last
Expand All @@ -134,8 +136,9 @@ async def _state_reporter(self) -> None:
elapsed_seconds = get_elapsed_time_i()
force_check = elapsed_seconds >= force_check_seconds and elapsed_seconds - last_check_seconds >= force_check_seconds
if queue_last != queue_size or downloading_last != download_count or write_last != write_count or force_check:
scanner_msg = f' (prescanned: {self._scn.get_prescanned_count():d})' if self._scn else ''
Log.info(f'[{get_elapsed_time_s()}] queue: {queue_size:d}{scanner_msg}, ready: {ready_size:d}, '
scan_msg = f'scanned: {f"{min(scan_count, self._orig_count)}+{extra_count:d}" if Config.lookahead else str(scan_count)}'
prescan_msg = f' (prescanned: {self._scn.get_prescanned_count():d})' if self._scn else ''
Log.info(f'[{get_elapsed_time_s()}] {scan_msg}, queue: {queue_size:d}{prescan_msg}, ready: {ready_size:d}, '
f'active: {download_count:d} (writing: {write_count:d})')
last_check_seconds = elapsed_seconds
self._total_queue_size_last = queue_size
Expand Down Expand Up @@ -249,6 +252,9 @@ def remove_from_writes(self, vi: VideoInfo) -> None:
def waiting_for_scanner(self) -> bool:
return self._scn and not self._scn.done()

def get_scanned_count(self) -> int:
return self._scn.get_done_count()

def get_scanner_workload_size(self) -> int:
return self._scn.get_workload_size() if self.waiting_for_scanner() else 0

Expand Down
5 changes: 5 additions & 0 deletions src/dscanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, sequence: list[VideoInfo], func: Callable[[VideoInfo], Corout
self._seq = deque(sequence)

self._orig_count = len(self._seq)
self._scan_count = 0
self._404_counter = 0
self._extra_ids: list[int] = list()
self._scanned_items = deque[VideoInfo]()
Expand All @@ -63,6 +64,7 @@ def _extend_with_extra(self) -> None:
self._extra_ids.extend(extra_idseq)

async def _at_scan_finish(self, vi: VideoInfo, result: DownloadResult) -> None:
self._scan_count += 1
if result in (DownloadResult.FAIL_NOT_FOUND, DownloadResult.FAIL_RETRIES,
DownloadResult.FAIL_DELETED, DownloadResult.FAIL_FILTERED_OUTER, DownloadResult.FAIL_SKIPPED):
founditems = list(filter(None, [file_already_exists_arr(vi.id, q) for q in QUALITIES]))
Expand Down Expand Up @@ -108,6 +110,9 @@ async def run(self) -> None:
def done(self) -> bool:
return self.get_workload_size() == 0

def get_done_count(self) -> int:
return self._scan_count

def get_workload_size(self) -> int:
return len(self._seq) + len(self._scanned_items)

Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
APP_NAME = 'NM'
APP_VER_MAJOR = '1'
APP_VER_SUB = '8'
APP_REVISION = '460'
APP_REVISION = '461'
APP_VERSION = f'{APP_VER_MAJOR}.{APP_VER_SUB}.{APP_REVISION}'

#
Expand Down

0 comments on commit 3d3c445

Please sign in to comment.