Skip to content

Commit

Permalink
optimize pdf size
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbull committed Apr 25, 2024
1 parent 45eddb7 commit a21bda2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 216 deletions.
31 changes: 14 additions & 17 deletions .github/workflows/scheduled_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- name: setup python
uses: actions/setup-python@v4
with:
with:
python-version: '3.11'
architecture: 'x64'
- name: install python dependencies
Expand All @@ -23,19 +23,19 @@ jobs:
pip install -r requirements.txt
- name: build pdf
run: python main_async.py
# - name: optimize pdf size
# run: |
# mkdir pdfsizeopt
# cd pdfsizeopt
# wget -O pdfsizeopt_libexec_linux.tar.gz https://github.com/pts/pdfsizeopt/releases/download/2023-04-18/pdfsizeopt_libexec_linux-v9.tar.gz
# tar xzvf pdfsizeopt_libexec_linux.tar.gz
# rm -f pdfsizeopt_libexec_linux.tar.gz
# wget -O pdfsizeopt.single https://raw.githubusercontent.com/pts/pdfsizeopt/master/pdfsizeopt.single
# chmod +x pdfsizeopt.single
# ln -s pdfsizeopt.single pdfsizeopt
# cd ..
# mv out/guide.pdf .
# ./pdfsizeopt/pdfsizeopt guide.pdf out/guide.pdf
- name: optimize pdf size
run: |
mkdir pdfsizeopt
cd pdfsizeopt
wget -O pdfsizeopt_libexec_linux.tar.gz https://github.com/pts/pdfsizeopt/releases/download/2023-04-18/pdfsizeopt_libexec_linux-v9.tar.gz
tar xzvf pdfsizeopt_libexec_linux.tar.gz
rm -f pdfsizeopt_libexec_linux.tar.gz
wget -O pdfsizeopt.single https://raw.githubusercontent.com/pts/pdfsizeopt/master/pdfsizeopt.single
chmod +x pdfsizeopt.single
ln -s pdfsizeopt.single pdfsizeopt
cd ..
mv out/guide.pdf .
./pdfsizeopt/pdfsizeopt guide.pdf out/guide.pdf
- name: build redirect page
run: cp resources/index.html out/index.html
- name: upload
Expand All @@ -58,6 +58,3 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4



196 changes: 0 additions & 196 deletions main.py

This file was deleted.

6 changes: 3 additions & 3 deletions main_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ async def wait_task(client: lark.Client, node: Node, ticket: str) -> ExportTask:

running = True
while running:
req = GetExportTaskRequestBuilder().token(
node.node_token).ticket(ticket).build()
req = GetExportTaskRequestBuilder().token(node.node_token).ticket(ticket).build()
resp = client.drive.v1.export_task.get(req)
if not resp.success():
logging.error(
Expand All @@ -168,7 +167,7 @@ async def wait_task(client: lark.Client, node: Node, ticket: str) -> ExportTask:
if status == 0:
return resp.data.result
elif status != 1 and status != 2:
logging.error(f'job failed: {status} {msg}')
logging.error(f'job failed: {node.title}: {status} {msg}')
raise LarkOpenApiError(status, msg)


Expand All @@ -184,6 +183,7 @@ async def download_exported_pdf(client: lark.Client, task: ExportTask, path: str
f.write(resp.raw.content)
return path


async def main():
logging.basicConfig(level=logging.INFO)
client = lark.Client.builder().app_id(
Expand Down

0 comments on commit a21bda2

Please sign in to comment.