Skip to content

Commit

Permalink
too lazy to build another converter
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmicoppai committed Jul 27, 2024
1 parent f3741e4 commit 3aab7cf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion backend/LiSA.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_ports():
if __name__ == "__main__":
freeze_support()
try:
logging.basicConfig(stream=stdout, level=logging.INFO)
logging.basicConfig(stream=stdout, level=logging.ERROR)
DB.migrate() # migrate the database
DB() # initialize the highest id

Expand Down
2 changes: 0 additions & 2 deletions backend/ebook/conversion/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ def get_plugin(file_format: str | None) -> Callable[[list[str] | list[Path], str
match file_format:
case "pdf":
return img_to_pdf
case "epub":
...
case _:
return None
Empty file.
7 changes: 4 additions & 3 deletions backend/video/downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def __init__(
max_workers: int = 50,
hooks: dict = None,
headers: dict = get_headers(),
post_processor: Callable[[list[str] | list[Path], str], None] = None
post_processor: Callable[[list[str] | list[Path], str | Path], None] = None
) -> None:

self.img_urls = img_urls
Expand Down Expand Up @@ -302,18 +302,19 @@ async def _run(self):
await client.close() # CLose the http session.

# convert the image if necessary
pdf_file_path = Path(self.OUTPUT_LOC).joinpath(f"{self.file_data['file_name']}.pdf")
if self.post_processor:
imgs = []
for r, _, f in walk(self.OUTPUT_LOC):
for fname in f:
imgs.append(Path(r).joinpath(fname))

self.post_processor(imgs, Path(self.OUTPUT_LOC).joinpath(f"{self.file_data['file_name']}.pdf"))
self.post_processor(imgs, pdf_file_path)

for img in imgs:
Path.unlink(img)

await self.update_db_record("downloaded", self.num_of_segments, self.total_size)
await self.update_db_record("downloaded", self.num_of_segments, self.total_size, pdf_file_path.__str__())

remove_folder(self.SEGMENT_DIR) # remove segments

Expand Down

0 comments on commit 3aab7cf

Please sign in to comment.