Skip to content

Commit

Permalink
fix zero bytes for alt
Browse files Browse the repository at this point in the history
also iterate over processes
  • Loading branch information
datawhores committed Dec 19, 2023
1 parent f886b0a commit 471cde1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
12 changes: 12 additions & 0 deletions ofscraper/download/alt_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,20 @@ async def alt_download(c, ele, path, username, model_id, progress):

audio = await alt_download_downloader(audio, c, ele, path, path_to_file, progress)
video = await alt_download_downloader(video, c, ele, path, path_to_file, progress)

for m in [audio, video]:
m["total"] = get_item_total(m)

if audio["total"] + video["total"] == 0:
await operations.update_media_table(
ele,
filename=None,
model_id=model_id,
username=username,
downloaded=True,
)
return ele.mediatype, video["total"] + audio["total"]
for m in [audio, video]:
if not isinstance(m, dict):
return m
check1 = await size_checker(m["path"], ele, m["total"])
Expand Down
12 changes: 12 additions & 0 deletions ofscraper/download/alt_downloadbatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ async def alt_download(c, ele, path, username, model_id):

for m in [audio, video]:
m["total"] = get_item_total(m)

if audio["total"] + video["total"] == 0:
await operations.update_media_table(
ele,
filename=None,
model_id=model_id,
username=username,
downloaded=True,
)
return ele.mediatype, video["total"] + audio["total"]

for m in [audio, video]:
if not isinstance(m, dict):
return m
check1 = await size_checker(m["path"], ele, m["total"])
Expand Down
7 changes: 7 additions & 0 deletions ofscraper/download/main_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ async def main_download(c, ele, path, username, model_id, progress):
result = await main_download_downloader(c, ele, path, username, model_id, progress)
# special case for zero byte files
if len(result) == 2 and result[-1] == 0:
await operations.update_media_table(
ele,
filename=None,
model_id=model_id,
username=username,
downloaded=True,
)
return result
total, temp, path_to_file = result

Expand Down
17 changes: 8 additions & 9 deletions ofscraper/utils/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,14 @@ def set_eventloop():

def get_dupe_ofscraper():
log = logging.getLogger("shared")

found = list(
filter(
lambda x: x.name() == "OF-Scraper"
and x.status() == "running"
and x.pid != os.getpid(),
list(psutil.process_iter()),
)
)
found = []
for proc in psutil.process_iter():
if (
proc.name() == "OF-Scraper"
and proc.status() == "running"
and proc.pid != os.getpid()
):
found.append(proc)
log.debug(f"Duplicated Processes {found}")
return found

Expand Down

0 comments on commit 471cde1

Please sign in to comment.