diff --git a/.gitignore b/.gitignore index 7603550..5ab84f8 100644 --- a/.gitignore +++ b/.gitignore @@ -176,3 +176,6 @@ # End of https://www.toptal.com/developers/gitignore/api/python *.gif +*.png +assets +frames diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c2799f..4250e27 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,7 +45,7 @@ # - id: sort-simple-yaml - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v16.0.4" + rev: "v16.0.6" hooks: - id: clang-format types_or: @@ -84,7 +84,7 @@ - --profile - black - repo: https://github.com/commitizen-tools/commitizen - rev: "3.2.2" + rev: "3.5.2" hooks: - id: commitizen # - id: commitizen-branch @@ -94,7 +94,7 @@ - id: cmake-format - id: cmake-lint - repo: https://github.com/python-jsonschema/check-jsonschema - rev: "0.23.1" + rev: "0.23.2" hooks: # - id: check-jsonschema # - id: check-metaschema @@ -117,7 +117,7 @@ - id: forbid-bidi-controls - id: macro-expand - repo: https://github.com/scop/pre-commit-shfmt - rev: "v3.6.0-2" + rev: "v3.7.0-1" hooks: - id: shfmt files: (.sh|.zsh|.zsh-theme|envrc|zshrc)(.tmpl)?$ @@ -132,7 +132,7 @@ - --space-redirects # - id: shfmt-docker - repo: https://github.com/cmhughes/latexindent.pl - rev: "V3.22" + rev: "V3.22.1" hooks: - id: latexindent files: .(tex|sty|cls|bib)$ diff --git a/Makefile b/Makefile index b5f3487..d7f182d 100644 --- a/Makefile +++ b/Makefile @@ -20,15 +20,15 @@ all: -clean: +include make/*.mk + +clean: demo-clean $(RM) --recursive $(CURDIR)/build $(RM) --recursive $(DIST) $(RM) $(CURDIR)/*.spec -demo: $(CURDIR)/demo.gif - docs: $(CURDIR)/main.py - typer $< utils docs --name $(NAME) + typer $< utils docs --name=$(NAME) dist: $(TARGET) @@ -36,16 +36,16 @@ pretty: black prettier -################################################################ -# Auxiliary Targets # -################################################################ +##################### +# Auxiliary Targets # +##################### black: isort --profile black $(CURDIR) black $(CURDIR) prettier: $(CURDIR)/.gitignore - prettier --write --ignore-path $< $(CURDIR) + prettier --write --ignore-path=$< $(CURDIR) $(TARGET_INSTALL): $(TARGET) @ install -D --mode="u=rwx,go=rx" --no-target-directory --verbose $< $@ @@ -54,7 +54,7 @@ ifeq ($(BW_SESSION),) $(error Bitwarden Locked) else - vhs --output $@ $< + vhs --output=$@ $< endif $(TARGET): $(CURDIR)/main.py diff --git a/README.md b/README.md index 5845ea3..08248d4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# thu-learn-downloader +# THU Web Learning Downloader Download everything from Web Learning of Tsinghua University ## Demo -![Demo](https://cdn.liblaf.me/image/2023/06/06/2023-06-06-23-25-02.gif) +![Demo](https://github.com/liblaf/thu-learn-downloader/raw/assets/demo.png) The resulting file structure looks like: diff --git a/demo.tape b/demo.tape index 9e13690..54d36fa 100644 --- a/demo.tape +++ b/demo.tape @@ -8,4 +8,4 @@ Type 'tld --password "$(bw get password id.tsinghua.edu.cn)"' Sleep 500ms Enter -Sleep 10s +Sleep 5s diff --git a/make/demo.mk b/make/demo.mk new file mode 100644 index 0000000..e472434 --- /dev/null +++ b/make/demo.mk @@ -0,0 +1,26 @@ +ASSETS := $(CURDIR)/assets +FRAMES := $(CURDIR)/frames +TEMPLATE := $(CURDIR)/template + +demo: $(ASSETS)/demo.png $(TEMPLATE)/scripts/deploy-gh-pages.sh + bash $(TEMPLATE)/scripts/deploy-gh-pages.sh $(dir $<) assets + +demo-clean: + $(RM) --recursive $(ASSETS) + $(RM) --recursive $(FRAMES) + +$(ASSETS) $(FRAMES): + @ mkdir --parents --verbose $@ + +$(ASSETS)/demo.png: $(FRAMES)/frame-100.png | $(ASSETS) + @ install -D --mode="u=rw,go=r" --no-target-directory --verbose $< $@ + +$(FRAMES)/demo.gif: $(CURDIR)/demo.tape | $(FRAMES) +ifeq ($(BW_SESSION),) + $(error Bitwarden Locked) +else + vhs --output=$@ $< +endif + +$(FRAMES)/frame-%.png: $(FRAMES)/demo.gif + magick convert -coalesce $< $(@D)/frame-%03d.png diff --git a/poetry.lock b/poetry.lock index 9a0a465..989f79c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.5.0 and should not be changed by hand. [[package]] name = "altgraph" @@ -316,13 +316,13 @@ [[package]] name = "markdown-it-py" -version = "2.2.0" +version = "3.0.0" description = "Python port of markdown-it. Markdown parsing, done right!" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "markdown-it-py-2.2.0.tar.gz", hash = "sha256:7c9a5e412688bc771c67432cbfebcdd686c93ce6484913dccf06cb5a0bea35a1"}, - {file = "markdown_it_py-2.2.0-py3-none-any.whl", hash = "sha256:5a35f8d1870171d9acc47b99612dc146129b631baf04970128b568f190d0cc30"}, + {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, + {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"}, ] [package.dependencies] @@ -335,7 +335,7 @@ linkify = ["linkify-it-py (>=1,<3)"] plugins = ["mdit-py-plugins"] profiling = ["gprof2dot"] -rtd = ["attrs", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] +rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] [[package]] @@ -362,12 +362,12 @@ [[package]] name = "nuitka" -version = "1.6.1" +version = "1.6.6" description = "Python compiler with full language support and CPython compatibility" optional = false python-versions = "*" files = [ - {file = "Nuitka-1.6.1.tar.gz", hash = "sha256:cfbfed720544de7a503e338ac663bcc65d281c44e73e449431e710b38319b568"}, + {file = "Nuitka-1.6.6.tar.gz", hash = "sha256:e2c7ddd5d09cfd867dfba913c3601de4ab448e946eb1aa1df85cc90d8296b3e6"}, ] [package.dependencies] @@ -423,18 +423,18 @@ [[package]] name = "platformdirs" -version = "3.5.1" +version = "3.8.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." optional = false python-versions = ">=3.7" files = [ - {file = "platformdirs-3.5.1-py3-none-any.whl", hash = "sha256:e2378146f1964972c03c085bb5662ae80b2b8c06226c54b2ff4aa9483e8a13a5"}, - {file = "platformdirs-3.5.1.tar.gz", hash = "sha256:412dae91f52a6f84830f39a8078cecd0e866cb72294a5c66808e74d5e88d251f"}, + {file = "platformdirs-3.8.0-py3-none-any.whl", hash = "sha256:ca9ed98ce73076ba72e092b23d3c93ea6c4e186b3f1c3dad6edd98ff6ffcca2e"}, + {file = "platformdirs-3.8.0.tar.gz", hash = "sha256:b0cabcb11063d21a0b261d557acb0a9d2126350e63b70cdf7db6347baea456dc"}, ] [package.extras] -docs = ["furo (>=2023.3.27)", "proselint (>=0.13)", "sphinx (>=6.2.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] +docs = ["furo (>=2023.5.20)", "proselint (>=0.13)", "sphinx (>=7.0.1)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)"] [[package]] name = "pycparser" @@ -463,23 +463,23 @@ [[package]] name = "pyinstaller" -version = "5.11.0" +version = "5.13.0" description = "PyInstaller bundles a Python application and all its dependencies into a single package." optional = false -python-versions = "<3.12,>=3.7" +python-versions = "<3.13,>=3.7" files = [ - {file = "pyinstaller-5.11.0-py3-none-macosx_10_13_universal2.whl", hash = "sha256:8454bac8f3cb2219a3ce2227fd039bdaf943dcba60e8c55732958ea3a6d81263"}, - {file = "pyinstaller-5.11.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:b3c6299fd7526c6ca87ea5f9017fb1928d47046df0b9f983d6bbd893801010dc"}, - {file = "pyinstaller-5.11.0-py3-none-manylinux2014_i686.whl", hash = "sha256:e359571327bbef434fc61324891399f9117efbb685b5065234eebb01713650a8"}, - {file = "pyinstaller-5.11.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:a445a91b85c9a1ea3985268643a674900dd86f244cc4be4ff4ec4c6367ff99a9"}, - {file = "pyinstaller-5.11.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:2a1fe6d0da22f207cfa4b3221fe365503cba071c77aac19f76a75503f67d9ff9"}, - {file = "pyinstaller-5.11.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:b4cac0e7b0d63c6a869843113008f59fd5b38b2959ffa6059e7fac4bb05de92b"}, - {file = "pyinstaller-5.11.0-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:0af9d11a09ce217d32f95c79c984054457b310671387ff32bae1496876308556"}, - {file = "pyinstaller-5.11.0-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:b8a4f6834e5c85150948e22c74dd3ab8b98aa4ccdf964d880ac14d2f78d9c1a4"}, - {file = "pyinstaller-5.11.0-py3-none-win32.whl", hash = "sha256:049cdc3524aefb5ca015a63d2c81b6bf1567cc818ac066859fbfde702c6165d3"}, - {file = "pyinstaller-5.11.0-py3-none-win_amd64.whl", hash = "sha256:42fdea67e4c2217cedd54d17d1d402736df3ba718db2b497df65df5a68ae4f93"}, - {file = "pyinstaller-5.11.0-py3-none-win_arm64.whl", hash = "sha256:036a062a228af41f6bb6370a4e87cef34858cc839200a07ace7f8738ef64ad86"}, - {file = "pyinstaller-5.11.0.tar.gz", hash = "sha256:cb87cee0b3c81ccd74d4bf3f4faf03b5e1e39bb91f1a894b2ce4cd22363bf779"}, + {file = "pyinstaller-5.13.0-py3-none-macosx_10_13_universal2.whl", hash = "sha256:7fdd319828de679f9c5e381eff998ee9b4164bf4457e7fca56946701cf002c3f"}, + {file = "pyinstaller-5.13.0-py3-none-manylinux2014_aarch64.whl", hash = "sha256:0df43697c4914285ecd333be968d2cd042ab9b2670124879ee87931d2344eaf5"}, + {file = "pyinstaller-5.13.0-py3-none-manylinux2014_i686.whl", hash = "sha256:28d9742c37e9fb518444b12f8c8ab3cb4ba212d752693c34475c08009aa21ccf"}, + {file = "pyinstaller-5.13.0-py3-none-manylinux2014_ppc64le.whl", hash = "sha256:e5fb17de6c325d3b2b4ceaeb55130ad7100a79096490e4c5b890224406fa42f4"}, + {file = "pyinstaller-5.13.0-py3-none-manylinux2014_s390x.whl", hash = "sha256:78975043edeb628e23a73fb3ef0a273cda50e765f1716f75212ea3e91b09dede"}, + {file = "pyinstaller-5.13.0-py3-none-manylinux2014_x86_64.whl", hash = "sha256:cd7d5c06f2847195a23d72ede17c60857d6f495d6f0727dc6c9bc1235f2eb79c"}, + {file = "pyinstaller-5.13.0-py3-none-musllinux_1_1_aarch64.whl", hash = "sha256:24009eba63cfdbcde6d2634e9c87f545eb67249ddf3b514e0cd3b2cdaa595828"}, + {file = "pyinstaller-5.13.0-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:1fde4381155f21d6354dc450dcaa338cd8a40aaacf6bd22b987b0f3e1f96f3ee"}, + {file = "pyinstaller-5.13.0-py3-none-win32.whl", hash = "sha256:2d03419904d1c25c8968b0ad21da0e0f33d8d65716e29481b5bd83f7f342b0c5"}, + {file = "pyinstaller-5.13.0-py3-none-win_amd64.whl", hash = "sha256:9fc27c5a853b14a90d39c252707673c7a0efec921cd817169aff3af0fca8c127"}, + {file = "pyinstaller-5.13.0-py3-none-win_arm64.whl", hash = "sha256:3a331951f9744bc2379ea5d65d36f3c828eaefe2785f15039592cdc08560b262"}, + {file = "pyinstaller-5.13.0.tar.gz", hash = "sha256:5e446df41255e815017d96318e39f65a3eb807e74a796c7e7ff7f13b6366a2e9"}, ] [package.dependencies] @@ -487,7 +487,7 @@ macholib = {version = ">=1.8", markers = "sys_platform == \"darwin\""} pefile = {version = ">=2022.5.30", markers = "sys_platform == \"win32\""} pyinstaller-hooks-contrib = ">=2021.4" -pywin32-ctypes = {version = ">=0.2.0", markers = "sys_platform == \"win32\""} +pywin32-ctypes = {version = ">=0.2.1", markers = "sys_platform == \"win32\""} setuptools = ">=42.0.0" [package.extras] @@ -496,24 +496,24 @@ [[package]] name = "pyinstaller-hooks-contrib" -version = "2023.3" +version = "2023.4" description = "Community maintained hooks for PyInstaller" optional = false python-versions = ">=3.7" files = [ - {file = "pyinstaller-hooks-contrib-2023.3.tar.gz", hash = "sha256:bb39e1038e3e0972420455e0b39cd9dce73f3d80acaf4bf2b3615fea766ff370"}, - {file = "pyinstaller_hooks_contrib-2023.3-py2.py3-none-any.whl", hash = "sha256:062ad7a1746e1cfc24d3a8c4be4e606fced3b123bda7d419f14fcf7507804b07"}, + {file = "pyinstaller-hooks-contrib-2023.4.tar.gz", hash = "sha256:9c11197653de9605a81975325a60b9369e9cdc37c009b6aeb0221a57211f9388"}, + {file = "pyinstaller_hooks_contrib-2023.4-py2.py3-none-any.whl", hash = "sha256:fc9892e46fa19d05725205413fb21a764f2f6ff1e70ba95322fb02420a665a45"}, ] [[package]] name = "pywin32-ctypes" -version = "0.2.0" -description = "" +version = "0.2.2" +description = "A (partial) reimplementation of pywin32 using ctypes/cffi" optional = false -python-versions = "*" +python-versions = ">=3.6" files = [ - {file = "pywin32-ctypes-0.2.0.tar.gz", hash = "sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942"}, - {file = "pywin32_ctypes-0.2.0-py2.py3-none-any.whl", hash = "sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98"}, + {file = "pywin32-ctypes-0.2.2.tar.gz", hash = "sha256:3426e063bdd5fd4df74a14fa3cf80a0b42845a87e1d1e81f6549f9daec593a60"}, + {file = "pywin32_ctypes-0.2.2-py3-none-any.whl", hash = "sha256:bf490a1a709baf35d688fe0ecf980ed4de11d2b3e37b51e5442587a75d9957e7"}, ] [[package]] @@ -539,17 +539,17 @@ [[package]] name = "rich" -version = "13.4.1" +version = "13.4.2" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false python-versions = ">=3.7.0" files = [ - {file = "rich-13.4.1-py3-none-any.whl", hash = "sha256:d204aadb50b936bf6b1a695385429d192bc1fdaf3e8b907e8e26f4c4e4b5bf75"}, - {file = "rich-13.4.1.tar.gz", hash = "sha256:76f6b65ea7e5c5d924ba80e322231d7cb5b5981aa60bfc1e694f1bc097fe6fe1"}, + {file = "rich-13.4.2-py3-none-any.whl", hash = "sha256:8f87bc7ee54675732fa66a05ebfe489e27264caeeff3728c945d25971b6485ec"}, + {file = "rich-13.4.2.tar.gz", hash = "sha256:d653d6bccede5844304c605d5aac802c7cf9621efd700b46c7ec2b51ea914898"}, ] [package.dependencies] -markdown-it-py = ">=2.2.0,<3.0.0" +markdown-it-py = ">=2.2.0" pygments = ">=2.13.0,<3.0.0" [package.extras] @@ -557,13 +557,13 @@ [[package]] name = "setuptools" -version = "67.8.0" +version = "68.0.0" description = "Easily download, build, install, upgrade, and uninstall Python packages" optional = false python-versions = ">=3.7" files = [ - {file = "setuptools-67.8.0-py3-none-any.whl", hash = "sha256:5df61bf30bb10c6f756eb19e7c9f3b473051f48db77fddbe06ff2ca307df9a6f"}, - {file = "setuptools-67.8.0.tar.gz", hash = "sha256:62642358adc77ffa87233bc4d2354c4b2682d214048f500964dbe760ccedf102"}, + {file = "setuptools-68.0.0-py3-none-any.whl", hash = "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f"}, + {file = "setuptools-68.0.0.tar.gz", hash = "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235"}, ] [package.extras] @@ -631,13 +631,13 @@ [[package]] name = "urllib3" -version = "2.0.2" +version = "2.0.3" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.7" files = [ - {file = "urllib3-2.0.2-py3-none-any.whl", hash = "sha256:d055c2f9d38dc53c808f6fdc8eab7360b6fdbbde02340ed25cfbcd817c62469e"}, - {file = "urllib3-2.0.2.tar.gz", hash = "sha256:61717a1095d7e155cdb737ac7bb2f4324a858a1e2e6466f6d03ff630ca68d3cc"}, + {file = "urllib3-2.0.3-py3-none-any.whl", hash = "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1"}, + {file = "urllib3-2.0.3.tar.gz", hash = "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825"}, ] [package.extras] diff --git a/requirements.txt b/requirements.txt index beb20f2..18218a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,11 +4,11 @@ click==8.1.3 ; python_version >= "3.11" and python_version < "3.12" colorama==0.4.6 ; python_version >= "3.11" and python_version < "3.12" and platform_system == "Windows" idna==3.4 ; python_version >= "3.11" and python_version < "3.12" -markdown-it-py==2.2.0 ; python_version >= "3.11" and python_version < "3.12" +markdown-it-py==3.0.0 ; python_version >= "3.11" and python_version < "3.12" mdurl==0.1.2 ; python_version >= "3.11" and python_version < "3.12" pygments==2.15.1 ; python_version >= "3.11" and python_version < "3.12" requests==2.31.0 ; python_version >= "3.11" and python_version < "3.12" -rich==13.4.1 ; python_version >= "3.11" and python_version < "3.12" +rich==13.4.2 ; python_version >= "3.11" and python_version < "3.12" soupsieve==2.4.1 ; python_version >= "3.11" and python_version < "3.12" typer==0.7.0 ; python_version >= "3.11" and python_version < "3.12" -urllib3==2.0.2 ; python_version >= "3.11" and python_version < "3.12" +urllib3==2.0.3 ; python_version >= "3.11" and python_version < "3.12" diff --git a/template b/template index d5e4fcd..9484e0a 160000 --- a/template +++ b/template @@ -1 +1 @@ -Subproject commit d5e4fcd7a71b420c2e2bb744de855f3ecd40ac21 +Subproject commit 9484e0a30396afe5e2d2788675100304d54e088e