fix: count only absolute path lines in _count_downloaded_files
This commit is contained in:
@@ -542,19 +542,15 @@ class GalleryDLService:
|
|||||||
def _count_downloaded_files(self, stdout: str) -> int:
|
def _count_downloaded_files(self, stdout: str) -> int:
|
||||||
"""Count the number of files downloaded from stdout.
|
"""Count the number of files downloaded from stdout.
|
||||||
|
|
||||||
Gallery-dl outputs one line per downloaded file.
|
Gallery-dl writes each downloaded file path to stdout as an absolute path
|
||||||
Lines starting with '#' or containing 'skip' are not downloads.
|
(starting with '/'). Log lines contain '[' prefixes; verbose HTTP lines
|
||||||
|
go to stderr. Counting only lines starting with '/' avoids over-counting
|
||||||
|
log and progress output.
|
||||||
"""
|
"""
|
||||||
if not stdout:
|
if not stdout:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
count = 0
|
return sum(1 for line in stdout.splitlines() if line.strip().startswith("/"))
|
||||||
for line in stdout.strip().split("\n"):
|
|
||||||
line = line.strip()
|
|
||||||
if line and not line.startswith("#") and "skip" not in line.lower():
|
|
||||||
count += 1
|
|
||||||
|
|
||||||
return count
|
|
||||||
|
|
||||||
async def download(
|
async def download(
|
||||||
self,
|
self,
|
||||||
|
|||||||
Reference in New Issue
Block a user