diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20334cb..f4ee728 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,8 @@ name: CI on: push: - branches: [ master ] + branches: + - '**' pull_request: branches: [ master ] @@ -17,12 +18,14 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest] + features: ["--all-features"] steps: - uses: actions/checkout@v2 - name: Install Rust toolchain uses: actions-rs/toolchain@v1 with: + profile: minimal toolchain: stable - name: Cache cargo directories @@ -39,12 +42,10 @@ jobs: path: target key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }} - name: Build - run: cargo build --release --verbose - # there are currently no automated tests - - name: Run tests - run: cargo test --release --verbose + run: cargo build --release ${{ matrix.features }} --verbose - name: Archive artifacts uses: actions/upload-artifact@v2 + if: matrix.features == '--all-features' with: name: Binaries path: | diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0613ae9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,196 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +## [Unreleased] + +## [0.3.1] - 2022-01-07 +### Fixed +- `--sync-url` can now be used to download the [course memberships](https://ilias.studium.kit.edu/ilias.php?cmdClass=ilmembershipoverviewgui&cmdNode=iy&baseClass=ilmembershipoverviewgui) + +## [0.3.0] - 2022-01-06 +### Fixed +- ILIAS 7 update ([#27]) + +## [0.2.24] - 2021-11-01 +### Added +- `--combine-videos` option to merge multiple video streams of the same lecture +- `--save-ilias-pages` option to also save the ILIAS overview pages of courses/folders +- Configuration file to change course names (PR [#19] by [@thelukasprobst]) + +### Fixed +- Downloading of lectures that consist of multiple streams + +## [0.2.23] - 2021-06-14 +### Added +- Logging output of saved forum post attachments + +### Changed +- ILIAS folder/course pages are now always saved + +### Fixed +- Links in saved ILIAS pages now work (see [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base)) +- ZIP of multiple forum post attachments is no longer downloaded + +## [0.2.22] - 2021-06-02 +### Added +- `--sync-url` can now download more "personal desktop" pages +- `--keep-session` flag to save and restore session cookies + +## [0.2.21] - 2021-05-18 +### Fixed +- Automatic output directory creation +- HTTP/2 [`NO_ERROR`](https://docs.rs/h2/0.3.3/h2/struct.Reason.html#associatedconstant.NO_ERROR) handling (issue [#15]) +- Correct logging output when the progress bar is displayed + +## [0.2.20] - 2021-05-13 +### Fixed +- Status display no longer prints every path when running in a small terminal + +## [0.2.19] - 2021-05-11 +### Fixed +- Status display on Windows (issue [#14]) + +## [0.2.18] - 2021-05-07 +### Added +- Request rate limiting (default 8 req. / 60 s, option `--rate`, issue [#13]) + +## [0.2.17] - 2021-05-04 +### Added +- Progress/status display: `[15/40+] ` +- Extraction of course/folder pages (in course.html / folder.html, currently not versioned) + +### Fixed +- Downloading of external images in forum posts +- Miscellaneous internal improvements + +## [0.2.16] - 2021-04-19 +### Added +- `--sync-url` option (to download only a single course/folder) +- `--user` and `--password` options (issue [#10]) +- `--keyring` option (to get/save the password using a system keyring service) +- Colored errors/warnings (PR [#11] by [@thelukasprobst]) + +## [0.2.15] - 2021-04-14 +### Added +- Downloading of attachments and embedded images in forum posts +- SOCKS5 proxy support (PR [#9] by [@Craeckie]) + +## [0.2.14] - 2021-02-16 +### Fixed +- Handling of long paths on Windows (issue [#6]) +- OpenCast downloading (issue [#7], PR [#8] by [@funnym0nk3y]) + +## [0.2.13] - 2021-01-05 +### Fixed +- Shibboleth login (issue [#5], PR [#4] by [@Ma27]) + +## [0.2.12] - 2020-12-10 +### Fixed +- Handling of invalid filenames on Windows (issue [#3]) + +## [0.2.11] - 2020-12-04 +### Fixed +- Waiting on spawned tasks (issue [#2]) + +## [0.2.10] - 2020-11-27 +### Added +- `.iliaslogin` file to provide login credentials + +### Fixed +- Handling of `/` and `\\` in lecture names + +## [0.2.9] - 2020-11-01 +### Fixed +- OpenCast downloading + +## [0.2.8] - 2020-07-16 +### Fixed +- OpenCast downloading + +## [0.2.7] - 2020-07-15 +### Added +- Automatic creation of output directory +- Optional re-check of OpenCast lectures (`--check-videos`) + +### Fixed +- OpenCast pagination (20 -> 800) + +## [0.2.6] - 2020-05-18 +### Added +- Downloading of exercise solutions and feedback + +### Fixed +- Video filenames no longer contain raw HTML + +## [0.2.5] - 2020-05-09 +(undocumented) + +## [0.2.4] - 2020-04-28 +(undocumented) + +## [0.2.3] - 2020-04-24 +(undocumented) + +## [0.2.2] - 2020-04-22 +(undocumented) + +## [0.2.1] - 2020-04-22 +(undocumented) + +## [0.2.0] - 2020-04-22 +(undocumented) + +## [0.1.0] - 2020-04-21 +(undocumented) + +[#27]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/27 +[#19]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/pull/19 +[#15]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/15 +[#14]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/14 +[#13]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/13 +[#11]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/pull/11 +[#10]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/10 +[#9]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/pull/9 +[#8]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/pull/8 +[#7]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/7 +[#6]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/6 +[#5]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/5 +[#4]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/pull/4 +[#3]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/3 +[#2]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/issues/2 +[@thelukasprobst]: https://github.com/thelukasprobst +[@Craeckie]: https://github.com/Craeckie +[@funnym0nk3y]: https://github.com/funnym0nk3y +[@Ma27]: https://github.com/Ma27 +[Unreleased]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.3.1...HEAD +[0.3.1]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.3.0...v0.3.1 +[0.3.0]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.24...v0.3.0 +[0.2.24]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.23...v0.2.24 +[0.2.23]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.23...v0.2.24 +[0.2.23]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.22...v0.2.23 +[0.2.22]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.21...v0.2.22 +[0.2.21]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.20...v0.2.21 +[0.2.20]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.19...v0.2.20 +[0.2.19]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.18...v0.2.19 +[0.2.18]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.17...v0.2.18 +[0.2.17]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.16...v0.2.17 +[0.2.16]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.15...v0.2.16 +[0.2.15]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.14...v0.2.15 +[0.2.14]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.13...v0.2.14 +[0.2.13]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.12...v0.2.13 +[0.2.12]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.11...v0.2.12 +[0.2.11]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.10...v0.2.11 +[0.2.10]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.9...v0.2.10 +[0.2.9]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.8...v0.2.9 +[0.2.8]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.7...v0.2.8 +[0.2.7]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.6...v0.2.7 +[0.2.6]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.5...v0.2.6 +[0.2.5]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.4...v0.2.5 +[0.2.4]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.3...v0.2.4 +[0.2.3]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.2...v0.2.3 +[0.2.2]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.1...v0.2.2 +[0.2.1]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.2.0...v0.2.1 +[0.2.0]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/v0.1.0...v0.2.0 +[0.1.0]: https://github.com/FliegendeWurst/KIT-ILIAS-downloader/compare/1529a678e0f4c78a24c8cc2cd236ce12ea8a78dc..v0.1.0 diff --git a/Cargo.lock b/Cargo.lock index 13724d3..f120662 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,63 +1,107 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "KIT-ILIAS-downloader" -version = "0.2.13" +version = "0.3.1" dependencies = [ "anyhow", + "atty", + "bytes", + "cfg-if 1.0.0", + "colored", + "cookie_store", + "ego-tree", "futures", "futures-channel", "futures-util", + "h2", "ignore", - "lazy_static", - "parking_lot", + "indicatif", + "keyring", + "once_cell", "regex", "reqwest", + "reqwest_cookie_store", "rpassword", "rprompt", "scraper", "serde_json", "structopt", + "tempfile", "tokio", "tokio-util", + "toml", "url", ] [[package]] name = "adler" -version = "0.2.3" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aes" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" +dependencies = [ + "aes-soft", + "aesni", + "cipher", +] + +[[package]] +name = "aes-soft" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" +dependencies = [ + "cipher", + "opaque-debug", +] + +[[package]] +name = "aesni" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" +dependencies = [ + "cipher", + "opaque-debug", +] [[package]] name = "aho-corasick" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] [[package]] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" dependencies = [ "winapi", ] [[package]] name = "anyhow" -version = "1.0.38" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" +checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" [[package]] name = "async-compression" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b72c1f1154e234325b50864a349b9c8e56939e266a4c307c0f159812df2f9537" +checksum = "5443ccbb270374a2b1055fc72da40e1f237809cd6bb0e97e66d264cd138473a6" dependencies = [ "flate2", "futures-core", @@ -66,6 +110,25 @@ dependencies = [ "tokio", ] +[[package]] +name = "async-io" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" +dependencies = [ + "concurrent-queue", + "futures-lite", + "libc", + "log", + "once_cell", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "winapi", +] + [[package]] name = "atty" version = "0.2.14" @@ -97,42 +160,73 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-modes" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" +dependencies = [ + "block-padding", + "cipher", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "bstr" -version = "0.2.14" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "473fc6b38233f9af7baa94fb5852dca389e3d95b8e21c8e3719301462c5d9faf" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "memchr", ] [[package]] name = "bumpalo" -version = "3.4.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" +checksum = "fe438c9d2f2b0fb88a112154ed81e30b0a491c29322afe1db3b6eec5811f5ba0" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + +[[package]] +name = "cache-padded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" [[package]] name = "cc" -version = "1.0.66" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" [[package]] name = "cfg-if" @@ -147,10 +241,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "clap" -version = "2.33.3" +name = "cipher" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +dependencies = [ + "generic-array", +] + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", @@ -162,16 +265,55 @@ dependencies = [ ] [[package]] -name = "const_fn" -version = "0.4.5" +name = "colored" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "concurrent-queue" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" +dependencies = [ + "cache-padded", +] + +[[package]] +name = "console" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "terminal_size", + "winapi", +] + +[[package]] +name = "const_fn" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cookie" -version = "0.14.3" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784ad0fbab4f3e9cef09f20e0aea6000ae08d2cb98ac4c0abc53df18803d702f" +checksum = "d5f1c7727e460397e56abc4bddc1d49e07a1ad78fc98eb2e1c8f032a58a2f80d" dependencies = [ "percent-encoding", "time", @@ -180,9 +322,9 @@ dependencies = [ [[package]] name = "cookie_store" -version = "0.12.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3818dfca4b0cb5211a659bbcbb94225b7127407b2b135e650d717bfb78ab10d3" +checksum = "b3f7034c0932dc36f5bd8ec37368d971346809435824f277cb3b8299fc56167c" dependencies = [ "cookie", "idna", @@ -195,25 +337,59 @@ dependencies = [ ] [[package]] -name = "crc32fast" -version = "1.2.1" +name = "core-foundation" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpufeatures" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "crossbeam-utils" -version = "0.8.1" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "autocfg", "cfg-if 1.0.0", "lazy_static", ] +[[package]] +name = "crypto-mac" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" +dependencies = [ + "generic-array", + "subtle", +] + [[package]] name = "cssparser" version = "0.27.2" @@ -222,7 +398,7 @@ checksum = "754b69d351cdc2d8ee09ae203db831e005560fc6030da058f86ad60c92a9cb0a" dependencies = [ "cssparser-macros", "dtoa-short", - "itoa", + "itoa 0.4.8", "matches", "phf", "proc-macro2", @@ -242,16 +418,38 @@ dependencies = [ ] [[package]] -name = "derive_more" -version = "0.99.11" +name = "derivative" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version 0.4.0", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "discard" version = "1.0.4" @@ -260,9 +458,9 @@ checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" [[package]] name = "dtoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d7ed2934d741c6b37e33e3832298e8850b53fd2d2bea03873375596c7cea4e" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" [[package]] name = "dtoa-short" @@ -280,28 +478,61 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a68a4904193147e0a8dec3314640e6db742afd5f6e634f428a6af230d9b3591" [[package]] -name = "encoding_rs" -version = "0.8.26" +name = "either" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "801bbab217d7f79c0062f4f7205b5d4427c6d1a7bd7aafdd1475f7c59d62b283" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "encoding_rs" +version = "0.8.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" dependencies = [ "cfg-if 1.0.0", ] [[package]] -name = "error-chain" -version = "0.12.4" +name = "enumflags2" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +checksum = "83c8d82922337cd23a15f88b70d8e4ef5f11da38dd7cdb55e84dd5de99695da0" dependencies = [ - "version_check", + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "fastrand" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "779d043b6a0b90cc4c0ed7ee380a6504394cee7efd7db050e3774eee387324b2" +dependencies = [ + "instant", ] [[package]] name = "flate2" -version = "1.0.19" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129" +checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" dependencies = [ "cfg-if 1.0.0", "crc32fast", @@ -317,9 +548,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ "matches", "percent-encoding", @@ -337,9 +568,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" +checksum = "28560757fe2bb34e79f907794bb6b22ae8b0e5c669b638a1132f2592b19035b4" dependencies = [ "futures-channel", "futures-core", @@ -352,9 +583,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" +checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" dependencies = [ "futures-core", "futures-sink", @@ -362,15 +593,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" +checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" [[package]] name = "futures-executor" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" +checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" dependencies = [ "futures-core", "futures-task", @@ -379,17 +610,31 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" +checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] [[package]] name = "futures-macro" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" +checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" dependencies = [ - "proc-macro-hack", "proc-macro2", "quote", "syn", @@ -397,24 +642,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" +checksum = "e3055baccb68d74ff6480350f8d6eb8fcfa3aa11bdc1a1ae3afdd0514617d508" [[package]] name = "futures-task" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" -dependencies = [ - "once_cell", -] +checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" [[package]] name = "futures-util" -version = "0.3.12" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" +checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" dependencies = [ "futures-channel", "futures-core", @@ -425,8 +667,6 @@ dependencies = [ "memchr", "pin-project-lite", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] @@ -439,6 +679,16 @@ dependencies = [ "byteorder", ] +[[package]] +name = "generic-array" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getopts" version = "0.2.21" @@ -456,14 +706,25 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", ] [[package]] name = "globset" -version = "0.4.6" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" +checksum = "10463d9ff00a2a068db14231982f5132edebad0d7660cd956a1c30292dbcbfbd" dependencies = [ "aho-corasick", "bstr", @@ -474,9 +735,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.0" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" +checksum = "8f072413d126e57991455e0a922b31e4c8ba7c2ffbebf6b78b4f8521397d65cd" dependencies = [ "bytes", "fnv", @@ -489,33 +750,52 @@ dependencies = [ "tokio", "tokio-util", "tracing", - "tracing-futures", ] [[package]] name = "hashbrown" -version = "0.9.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" [[package]] name = "heck" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] +[[package]] +name = "hkdf" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" +dependencies = [ + "digest", + "hmac", +] + +[[package]] +name = "hmac" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" +dependencies = [ + "crypto-mac", + "digest", +] + [[package]] name = "html5ever" version = "0.25.1" @@ -532,42 +812,43 @@ dependencies = [ [[package]] name = "http" -version = "0.2.3" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747" +checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" dependencies = [ "bytes", "fnv", - "itoa", + "itoa 1.0.1", ] [[package]] name = "http-body" -version = "0.4.0" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" +checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" dependencies = [ "bytes", "http", + "pin-project-lite", ] [[package]] name = "httparse" -version = "1.3.4" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" +checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" [[package]] name = "httpdate" -version = "0.3.2" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.2" +version = "0.14.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe" +checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" dependencies = [ "bytes", "futures-channel", @@ -578,8 +859,8 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa", - "pin-project 1.0.4", + "itoa 0.4.8", + "pin-project-lite", "socket2", "tokio", "tower-service", @@ -589,24 +870,22 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.22.1" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" +checksum = "d87c48c02e0dc5e3b849a2041db3029fd066650f8f717c07bf8ed78ccb895cac" dependencies = [ - "futures-util", + "http", "hyper", - "log", "rustls", "tokio", "tokio-rustls", - "webpki", ] [[package]] name = "idna" -version = "0.2.0" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" dependencies = [ "matches", "unicode-bidi", @@ -615,9 +894,9 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b287fb45c60bb826a0dc68ff08742b9d88a2fea13d6e0c286b3172065aaf878c" +checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d" dependencies = [ "crossbeam-utils", "globset", @@ -633,44 +912,74 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" dependencies = [ "autocfg", "hashbrown", ] [[package]] -name = "instant" -version = "0.1.9" +name = "indicatif" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +checksum = "2d207dc617c7a380ab07ff572a6e52fa202a2a8f355860ac9c38e23f8196be1b" +dependencies = [ + "console", + "lazy_static", + "number_prefix", + "regex", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if 1.0.0", ] [[package]] name = "ipnet" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47be2f14c678be2fdcab04ab1171db51b2762ce6f0a8ee87c8dd4a04ed216135" +checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" + +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "js-sys" -version = "0.3.46" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" dependencies = [ "wasm-bindgen", ] +[[package]] +name = "keyring" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dadaf714ce3f9d7e1c8c05aa8d070eb6e9ddd40cd7be3aca2f21fa372405104" +dependencies = [ + "byteorder", + "secret-service", + "security-framework", + "winapi", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -679,26 +988,26 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.82" +version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" [[package]] name = "lock_api" -version = "0.4.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" dependencies = [ "scopeguard", ] [[package]] name = "log" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf3805d4480bb5b86070dcfeb9e2cb2ebc148adb753c5cca5f884d1d65a42b2" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", ] [[package]] @@ -709,16 +1018,13 @@ checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" [[package]] name = "markup5ever" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aae38d669396ca9b707bfc3db254bc382ddb94f57cc5c235f34623a669a01dab" +checksum = "a24f40fb03852d1cdd84330cddcaf98e9ec08a7b7768e952fad3b4cf048ec8fd" dependencies = [ "log", "phf", "phf_codegen", - "serde", - "serde_derive", - "serde_json", "string_cache", "string_cache_codegen", "tendril", @@ -726,15 +1032,15 @@ dependencies = [ [[package]] name = "matches" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" +checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "mime" @@ -744,9 +1050,9 @@ checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] name = "miniz_oxide" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" dependencies = [ "adler", "autocfg", @@ -754,9 +1060,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.7.7" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7" +checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" dependencies = [ "libc", "log", @@ -767,20 +1073,42 @@ dependencies = [ [[package]] name = "miow" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" dependencies = [ - "socket2", "winapi", ] +[[package]] +name = "nb-connect" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1bb540dc6ef51cfe1916ec038ce7a620daf3a111e2502d745197cd53d6bca15" +dependencies = [ + "libc", + "socket2", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nix" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e4785f2c3b7589a0d0c1dd60285e1188adac4006e8abd6dd578e1567027363" +dependencies = [ + "bitflags", + "cc", + "cfg-if 0.1.10", + "libc", + "void", +] + [[package]] name = "nodrop" version = "0.1.14" @@ -797,26 +1125,120 @@ dependencies = [ ] [[package]] -name = "num_cpus" -version = "1.13.0" +name = "num" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "747d632c0c558b87dbabbe6a82f3b4ae03720d0646ac5b7b4dae89394be5f2c5" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", ] [[package]] -name = "once_cell" -version = "1.5.2" +name = "number_prefix" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + +[[package]] +name = "once_cell" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", @@ -825,9 +1247,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ "cfg-if 1.0.0", "instant", @@ -871,7 +1293,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17367f0cc86f2d25802b2c26ee58a7b23faeccf78a396094c13dced0d0182526" dependencies = [ "phf_shared", - "rand", + "rand 0.7.3", ] [[package]] @@ -897,51 +1319,11 @@ dependencies = [ "siphasher", ] -[[package]] -name = "pin-project" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" -dependencies = [ - "pin-project-internal 0.4.27", -] - -[[package]] -name = "pin-project" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b70b68509f17aa2857863b6fa00bf21fc93674c7a8893de2f469f6aa7ca2f2" -dependencies = [ - "pin-project-internal 1.0.4", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caa25a6393f22ce819b0f50e0be89287292fda8d425be38ee0ca14c4931d9e71" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "pin-project-lite" -version = "0.2.4" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" +checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" [[package]] name = "pin-utils" @@ -950,10 +1332,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "ppv-lite86" -version = "0.2.10" +name = "polling" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "log", + "wepoll-ffi", + "winapi", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "precomputed-hash" @@ -961,6 +1356,25 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-crate" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebace6889caf889b4d3f76becee12e90353f2b8c7d875534a71e5742f8f6f83" +dependencies = [ + "thiserror", + "toml", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -991,39 +1405,38 @@ version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] [[package]] -name = "publicsuffix" -version = "1.5.4" +name = "psl-types" +version = "2.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bbaa49075179162b49acac1c6aa45fb4dafb5f13cf6794276d77bc7fd95757b" +checksum = "e8eda7c62d9ecaafdf8b62374c006de0adf61666ae96a96ba74a37134aa4e470" + +[[package]] +name = "publicsuffix" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "292972edad6bbecc137ab84c5e36421a4a6c979ea31d3cc73540dd04315b33e1" dependencies = [ - "error-chain", + "byteorder", + "hashbrown", "idna", - "lazy_static", - "regex", - "url", + "psl-types", ] [[package]] name = "quote" -version = "1.0.8" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" dependencies = [ "proc-macro2", ] @@ -1034,14 +1447,26 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom", + "getrandom 0.1.16", "libc", - "rand_chacha", - "rand_core", - "rand_hc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", "rand_pcg", ] +[[package]] +name = "rand" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.3", + "rand_hc 0.3.1", +] + [[package]] name = "rand_chacha" version = "0.2.2" @@ -1049,7 +1474,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.3", ] [[package]] @@ -1058,7 +1493,16 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.3", ] [[package]] @@ -1067,7 +1511,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core 0.6.3", ] [[package]] @@ -1076,38 +1529,49 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" dependencies = [ - "rand_core", + "rand_core 0.5.1", ] [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] [[package]] name = "regex" -version = "1.4.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", ] [[package]] name = "regex-syntax" -version = "0.6.22" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] [[package]] name = "reqwest" -version = "0.11.0" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd281b1030aa675fb90aa994d07187645bb3c8fc756ca766e7c3070b439de9de" +checksum = "7c4e0a76dc12a116108933f6301b95e83634e0c47b0afbed6abbaa0601e99258" dependencies = [ "async-compression", "base64", @@ -1128,13 +1592,15 @@ dependencies = [ "mime", "percent-encoding", "pin-project-lite", + "proc-macro-hack", "rustls", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", - "time", "tokio", "tokio-rustls", + "tokio-socks", "tokio-util", "url", "wasm-bindgen", @@ -1145,10 +1611,23 @@ dependencies = [ ] [[package]] -name = "ring" -version = "0.16.19" +name = "reqwest_cookie_store" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "024a1e66fea74c66c66624ee5622a7ff0e4b73a13b4f5c326ddb50c708944226" +checksum = "48cbf3a2aeeeaa6d10a76db86068c3560320f6265c3a0e2642e0538e11c2d143" +dependencies = [ + "bytes", + "cookie", + "cookie_store", + "reqwest", + "url", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" dependencies = [ "cc", "libc", @@ -1181,16 +1660,24 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver", + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.4", ] [[package]] name = "rustls" -version = "0.19.0" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b" +checksum = "d37e5e2290f3e040b594b1a9e04377c2c671f1a1cfd9bfdef82106ac1c113f84" dependencies = [ - "base64", "log", "ring", "sct", @@ -1198,10 +1685,19 @@ dependencies = [ ] [[package]] -name = "ryu" -version = "1.0.5" +name = "rustls-pemfile" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "5eebeaeb360c87bfb72e84abdb3447159c0eaececf1bef2aecd65a8be949d1c9" +dependencies = [ + "base64", +] + +[[package]] +name = "ryu" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "same-file" @@ -1212,6 +1708,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + [[package]] name = "scopeguard" version = "1.1.0" @@ -1236,14 +1738,57 @@ dependencies = [ [[package]] name = "sct" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ "ring", "untrusted", ] +[[package]] +name = "secret-service" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2400fb1bf2a87b303ada204946294f932ade4929477e9e2bf66d7b49a66656ec" +dependencies = [ + "aes", + "block-modes", + "hkdf", + "lazy_static", + "num", + "rand 0.8.4", + "serde", + "sha2", + "zbus", + "zbus_macros", + "zvariant", + "zvariant_derive", +] + +[[package]] +name = "security-framework" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "selectors" version = "0.22.0" @@ -1273,6 +1818,12 @@ dependencies = [ "semver-parser", ] +[[package]] +name = "semver" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" + [[package]] name = "semver-parser" version = "0.7.0" @@ -1281,18 +1832,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.120" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "166b2349061381baf54a58e4b13c89369feb0ef2eaa57198899e2312aac30aab" +checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.120" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca2a8cb5805ce9e3b95435e3765b7b553cecc762d938d409434338386cb5775" +checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" dependencies = [ "proc-macro2", "quote", @@ -1301,15 +1852,26 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.61" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" +checksum = "ee2bb9cd061c5865d345bb02ca49fcef1391741b672b54a0bf7b679badec3142" dependencies = [ - "itoa", + "itoa 1.0.1", "ryu", "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "serde_urlencoded" version = "0.7.0" @@ -1317,7 +1879,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" dependencies = [ "form_urlencoded", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -1339,39 +1901,51 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" [[package]] -name = "signal-hook-registry" -version = "1.3.0" +name = "sha2" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" +dependencies = [ + "block-buffer", + "cfg-if 1.0.0", + "cpufeatures", + "digest", + "opaque-debug", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" dependencies = [ "libc", ] [[package]] name = "siphasher" -version = "0.3.3" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7" +checksum = "533494a8f9b724d33625ab53c6c4800f7cc445895924a8ef649222dcb76e938b" [[package]] name = "slab" -version = "0.4.2" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" [[package]] name = "smallvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" [[package]] name = "socket2" -version = "0.3.19" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" +checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" dependencies = [ - "cfg-if 1.0.0", "libc", "winapi", ] @@ -1390,13 +1964,19 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "standback" -version = "0.2.14" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c66a8cff4fa24853fdf6b51f75c6d7f8206d7c75cab4e467bcd7f25c2b1febe0" +checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" dependencies = [ "version_check", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "stdweb" version = "0.4.20" @@ -1404,7 +1984,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" dependencies = [ "discard", - "rustc_version", + "rustc_version 0.2.3", "stdweb-derive", "stdweb-internal-macros", "stdweb-internal-runtime", @@ -1448,12 +2028,13 @@ checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" [[package]] name = "string_cache" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ddb1139b5353f96e429e1a5e19fbaf663bddedaa06d1dbd49f82e352601209a" +checksum = "923f0f39b6267d37d23ce71ae7235602134b250ace715dd2c90421998ddac0c6" dependencies = [ "lazy_static", "new_debug_unreachable", + "parking_lot", "phf_shared", "precomputed-hash", "serde", @@ -1479,9 +2060,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" +checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" dependencies = [ "clap", "lazy_static", @@ -1490,9 +2071,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.14" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ "heck", "proc-macro-error", @@ -1502,16 +2083,36 @@ dependencies = [ ] [[package]] -name = "syn" -version = "1.0.58" +name = "subtle" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" dependencies = [ "proc-macro2", "quote", "unicode-xid", ] +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "rand 0.8.4", + "redox_syscall", + "remove_dir_all", + "winapi", +] + [[package]] name = "tendril" version = "0.4.2" @@ -1523,6 +2124,16 @@ dependencies = [ "utf-8", ] +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "textwrap" version = "0.11.0" @@ -1539,19 +2150,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c" [[package]] -name = "thread_local" -version = "1.1.0" +name = "thiserror" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb9bc092d0d51e76b2b19d9d85534ffc9ec2db959a2523cdae0697e2972cd447" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ - "lazy_static", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" +dependencies = [ + "once_cell", ] [[package]] name = "time" -version = "0.2.24" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "273d3ed44dca264b0d6b3665e8d48fb515042d42466fad93d2a45b90ec4058f7" +checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" dependencies = [ "const_fn", "libc", @@ -1574,9 +2205,9 @@ dependencies = [ [[package]] name = "time-macros-impl" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" +checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -1587,9 +2218,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.1.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" +checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" dependencies = [ "tinyvec_macros", ] @@ -1602,18 +2233,16 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.0.2" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca04cec6ff2474c638057b65798f60ac183e5e79d3448bb7163d36a39cff6ec" +checksum = "fbbf1c778ec206785635ce8ad57fe52b3009ae9e0c9f574a728f3049d3e55838" dependencies = [ - "autocfg", "bytes", "libc", "memchr", "mio", "num_cpus", "once_cell", - "parking_lot", "pin-project-lite", "signal-hook-registry", "tokio-macros", @@ -1622,9 +2251,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "1.0.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42517d2975ca3114b22a16192634e8241dc5cc1f130be194645970cc1c371494" +checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" dependencies = [ "proc-macro2", "quote", @@ -1633,9 +2262,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.22.0" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" dependencies = [ "rustls", "tokio", @@ -1643,21 +2272,22 @@ dependencies = [ ] [[package]] -name = "tokio-stream" -version = "0.1.2" +name = "tokio-socks" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76066865172052eb8796c686f0b441a93df8b08d40a950b062ffb9a426f00edd" +checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" dependencies = [ - "futures-core", - "pin-project-lite", + "either", + "futures-util", + "thiserror", "tokio", ] [[package]] name = "tokio-util" -version = "0.6.1" +version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ae4751faa60b9f96dd8344d74592e5a17c0c9a220413dbc6942d14139bbfcc" +checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" dependencies = [ "bytes", "futures-core", @@ -1665,20 +2295,28 @@ dependencies = [ "log", "pin-project-lite", "tokio", - "tokio-stream", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", ] [[package]] name = "tower-service" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.22" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" +checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", @@ -1687,23 +2325,13 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.17" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" +checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" dependencies = [ "lazy_static", ] -[[package]] -name = "tracing-futures" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" -dependencies = [ - "pin-project 0.4.27", - "tracing", -] - [[package]] name = "try-lock" version = "0.2.3" @@ -1711,40 +2339,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] -name = "unicode-bidi" -version = "0.3.4" +name = "typenum" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + +[[package]] +name = "unicode-bidi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" [[package]] name = "unicode-normalization" -version = "0.1.16" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" +checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "untrusted" @@ -1754,9 +2385,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.2.0" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" +checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ "form_urlencoded", "idna", @@ -1766,9 +2397,9 @@ dependencies = [ [[package]] name = "utf-8" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" [[package]] name = "vec_map" @@ -1778,15 +2409,27 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.1" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", "winapi", @@ -1810,22 +2453,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] -name = "wasm-bindgen" -version = "0.2.69" +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if 1.0.0", - "serde", - "serde_json", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.69" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" dependencies = [ "bumpalo", "lazy_static", @@ -1838,9 +2485,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.19" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fe9756085a84584ee9457a002b7cdfe0bfff169f45d2591d8be1345a6780e35" +checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -1850,9 +2497,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.69" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1860,9 +2507,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.69" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", "quote", @@ -1873,15 +2520,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.69" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "web-sys" -version = "0.3.46" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" dependencies = [ "js-sys", "wasm-bindgen", @@ -1889,9 +2536,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.21.4" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" dependencies = [ "ring", "untrusted", @@ -1899,13 +2546,22 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.21.0" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82015b7e0b8bad8185994674a13a93306bea76cf5a16c5a181382fd3a5ec2376" +checksum = "552ceb903e957524388c4d3475725ff2c8b7960922063af6ce53c9a43da07449" dependencies = [ "webpki", ] +[[package]] +name = "wepoll-ffi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1945,3 +2601,64 @@ checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ "winapi", ] + +[[package]] +name = "zbus" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2326acc379a3ac4e34b794089f5bdb17086bf29a5fdf619b7b4cc772dc2e9dad" +dependencies = [ + "async-io", + "byteorder", + "derivative", + "enumflags2", + "fastrand", + "futures", + "nb-connect", + "nix", + "once_cell", + "polling", + "scoped-tls", + "serde", + "serde_repr", + "zbus_macros", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a482c56029e48681b89b92b5db3c446db0915e8dd1052c0328a574eda38d5f93" +dependencies = [ + "proc-macro-crate 0.1.5", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zvariant" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a68c7b55f2074489b7e8e07d2d0a6ee6b4f233867a653c664d8020ba53692525" +dependencies = [ + "byteorder", + "enumflags2", + "libc", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ca5e22593eb4212382d60d26350065bf2a02c34b85bc850474a74b589a3de9" +dependencies = [ + "proc-macro-crate 1.1.0", + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index e1b79d9..b8d1c91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "KIT-ILIAS-downloader" -version = "0.2.13" -authors = ["FliegendeWurst <2012gdwu@web.de>"] -license = "GPL-2.0" +version = "0.3.1" +authors = ["FliegendeWurst <2012gdwu@posteo.de>"] +license = "GPL-3.0-or-later" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -reqwest = { version = "0.11.0", default-features = false, features = ["cookies", "gzip", "json", "rustls-tls", "stream"] } -tokio = { version = "1.0.2", features = ["full"] } +reqwest = { version = "0.11.0", default-features = false, features = ["cookies", "gzip", "json", "rustls-tls", "stream", "socks"] } +tokio = { version = "1.0.2", features = ["fs", "macros", "net", "rt-multi-thread", "process"] } tokio-util = { version = "0.6.1", features = ["io"] } serde_json = "1.0.51" scraper = "0.12.0" @@ -18,10 +18,21 @@ futures = "0.3.8" futures-util = "0.3.8" futures-channel = "0.3.8" regex = "1.3.7" -lazy_static = "1.4.0" -parking_lot = "0.11.0" structopt = "0.3.13" rpassword = "5.0.0" rprompt = "1.0.5" ignore = "0.4.14" anyhow = "1.0.28" +colored = "2.0.0" +keyring = "1.0.0" +cfg-if = "1.0.0" +indicatif = "0.16.0" +once_cell = "1.7.2" +atty = "0.2.14" +h2 = "0.3.3" +cookie_store = "0.15.1" +reqwest_cookie_store = "0.2.0" +bytes = "1.0.1" +toml = "0.5.8" +tempfile = "3.2.0" +ego-tree = "0.6.2" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md index 56d4c55..7bc4850 100644 --- a/README.md +++ b/README.md @@ -2,52 +2,73 @@ Download content from ILIAS. That includes: -* files (latest version) +* files +* exercise sheets and solutions * Opencast lectures +* forum posts ## Installation -Go to the [releases](../../releases) and get the executable for your operating system. Alternatively compile from source: (to get the latest updates) +**Windows/Linux users**: go to the [releases](../../releases) and download the executable for your operating system. +**macOS users**: [Install Rust](https://www.rust-lang.org/tools/install) and compile from source: ``` -$ git clone https://github.com/FliegendeWurst/KIT-ILIAS-downloader -... -$ cd KIT-ILIAS-downloader -$ cargo build --release -... -$ cp target/release/KIT-ILIAS-downloader [directory in $PATH] +$ cargo install --all-features --git 'https://github.com/FliegendeWurst/KIT-ILIAS-downloader' --branch stable ``` ## Usage -Use `-o ` to specify the download directory. Username and password have to be provided every time the program is run. +First, open a terminal. Navigate to the directory that contains the downloaded binary. -Only content on your [personal desktop](https://ilias.studium.kit.edu/ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToSelectedItems) will be downloaded. +Then execute the program (use `-o ` to specify the download directory): + +``` +$ KIT-ILIAS-downloader -o ./ILIAS +``` + +By default, only content on your [personal desktop](https://ilias.studium.kit.edu/ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToSelectedItems) will be downloaded. +Use the `--sync-url` option to download a specific page and its sub-pages: (the URL should be copied from an ILIAS link, not the browser URL bar) + +``` +$ KIT-ILIAS-downloader -o ./ILIAS/WS2021-HM1 --sync-url 'https://ilias.studium.kit.edu/ilias.php?ref_id=1276968&cmdClass=ilrepositorygui&cmdNode=uk&baseClass=ilRepositoryGUI' +``` + +### Options ``` $ KIT-ILIAS-downloader --help -KIT-ILIAS-downloader 0.2.5 +KIT-ILIAS-downloader 0.2.24 USAGE: KIT-ILIAS-downloader [FLAGS] [OPTIONS] --output FLAGS: - --content-tree Use content tree (slow but thorough) - -f Re-download already present files - -t, --forum Download forum content - -h, --help Prints help information - -n, --no-videos Do not download Opencast videos - -s, --skip-files Do not download files - -V, --version Prints version information - -v Verbose logging (print objects downloaded) + --check-videos Re-check OpenCast lectures (slow) + --combine-videos Combine videos if there is more than one stream (requires ffmpeg) + --content-tree Use content tree (experimental) + -f Re-download already present files + -t, --forum Download forum content + -h, --help Prints help information + --keep-session Attempt to re-use session cookies + --keyring Use the system keyring + -n, --no-videos Do not download Opencast videos + --save-ilias-pages Save overview pages of ILIAS courses and folders + -s, --skip-files Do not download files + -V, --version Prints version information + -v Verbose logging OPTIONS: - -j, --jobs Parallel download jobs [default: 1] - -o, --output Output directory + -j, --jobs Parallel download jobs [default: 1] + -o, --output Output directory + -P, --password KIT account password + -p, --proxy Proxy, e.g. socks5h://127.0.0.1:1080 + --rate Requests per minute [default: 8] + --sync-url ILIAS page to download + -U, --username KIT account username ``` ### .iliasignore -.gitignore syntax can be used in a `.iliasignore` file: (located in the download folder) +.gitignore syntax can be used in a `.iliasignore` file: (located in the output folder) ```ignore # example 1: only download a single course /*/ @@ -57,16 +78,29 @@ OPTIONS: !/Course/Tutorien/Tut* 3/ ``` -### .iliaslogin +### Credentials -If you don't want to enter your credentials every time you run the program, you can instead save your username and password in a file (`.iliaslogin`): +You can use the `--user` and `--keyring` options to get/store the password using the system password store. +If you use Linux, you'll have to compile from source to be able to use this option. +``` +$ KIT-ILIAS-downloader -U uabcd --keyring [...] +``` +You can also save your username and password in a `.iliaslogin` file: (located in the output folder) ``` username password ``` +### Renaming course names (0.2.24+) +If you'd like to avoid unwieldy course names (e.g. "24030 – Programmierparadigmen"), you can create a `course_names.toml` file in the output directory. It should contain the desired mapping of course names to folder names, e.g.: +``` +"24030 – Programmierparadigmen" = "ProPa" +"Numerische Mathematik für die Fachrichtungen Informatik und Ingenieurwesen" = "Numerik" +``` + ## Similar programs - https://github.com/brantsch/kit-ilias-fuse/ - https://github.com/Garmelon/PFERD/ +- https://github.com/DeOldSax/iliasDownloaderTool diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..8c4e3cb --- /dev/null +++ b/build.sh @@ -0,0 +1,8 @@ +#!/bin/sh +rustup target add x86_64-unknown-linux-musl +cargo build --locked --release --target x86_64-unknown-linux-musl + +rustup target add x86_64-pc-windows-gnu +# if on Debian or similar +sudo apt install mingw-w64 +cargo build --locked --release --all-features --target x86_64-pc-windows-gnu diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..350f6e3 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +hard_tabs = true +match_block_trailing_comma = true +max_width = 120 diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..0ef5a9c --- /dev/null +++ b/shell.nix @@ -0,0 +1,6 @@ +with (import {}); +mkShell { + buildInputs = [ + dbus + ]; +} diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..ed6e282 --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,177 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +use std::path::PathBuf; +use std::sync::atomic::{AtomicBool, AtomicUsize}; + +use anyhow::anyhow; +use anyhow::{Context, Result}; +use indicatif::ProgressBar; +use once_cell::sync::Lazy; +use structopt::StructOpt; + +#[derive(Debug, Clone, StructOpt)] +#[structopt(name = env!("CARGO_PKG_NAME"))] +pub struct Opt { + /// Do not download files + #[structopt(short, long)] + pub skip_files: bool, + + /// Do not download Opencast videos + #[structopt(short, long)] + pub no_videos: bool, + + /// Download forum content + #[structopt(short = "t", long)] + pub forum: bool, + + /// Re-download already present files + #[structopt(short)] + pub force: bool, + + /// Use content tree (experimental) + #[structopt(long)] + pub content_tree: bool, + + /// Re-check OpenCast lectures (slow) + #[structopt(long)] + pub check_videos: bool, + + /// Combine videos if there is more than one stream (requires ffmpeg) + #[structopt(long)] + pub combine_videos: bool, + + /// Save overview pages of ILIAS courses and folders + #[structopt(long)] + pub save_ilias_pages: bool, + + /// Verbose logging + #[structopt(short, multiple = true, parse(from_occurrences))] + pub verbose: usize, + + /// Output directory + #[structopt(short, long, parse(from_os_str))] + pub output: PathBuf, + + /// Parallel download jobs + #[structopt(short, long, default_value = "1")] + pub jobs: usize, + + /// Proxy, e.g. socks5h://127.0.0.1:1080 + #[structopt(short, long)] + pub proxy: Option, + + /// Use the system keyring + #[structopt(long)] + pub keyring: bool, + + /// KIT account username + #[structopt(short = "U", long)] + pub username: Option, + + /// KIT account password + #[structopt(short = "P", long)] + pub password: Option, + + /// ILIAS page to download + #[structopt(long)] + pub sync_url: Option, + + /// Requests per minute + #[structopt(long, default_value = "8")] + pub rate: usize, + + /// Attempt to re-use session cookies + #[structopt(long)] + pub keep_session: bool, +} + +pub static LOG_LEVEL: AtomicUsize = AtomicUsize::new(0); +pub static PROGRESS_BAR_ENABLED: AtomicBool = AtomicBool::new(false); +pub static PROGRESS_BAR: Lazy = Lazy::new(|| ProgressBar::new(0)); + +macro_rules! log { + ($lvl:expr, $($t:expr),+) => {{ + #[allow(unused_imports)] + use colored::Colorize as _; + #[allow(unused_comparisons)] // 0 <= 0 + if $lvl <= crate::cli::LOG_LEVEL.load(std::sync::atomic::Ordering::SeqCst) { + if crate::cli::PROGRESS_BAR_ENABLED.load(std::sync::atomic::Ordering::SeqCst) { + crate::cli::PROGRESS_BAR.println(format!($($t),+)); + } else { + println!($($t),+); + } + } + }} +} + +macro_rules! info { + ($t:tt) => { + log!(0, $t); + }; +} + +macro_rules! success { + ($t:tt) => { + log!(0, "{}", format!($t).bright_green()); + }; +} + +macro_rules! warning { + ($e:expr) => {{ + log!(0, "Warning: {}", format!("{:?}", $e).bright_yellow()); + }}; + ($msg:expr, $e:expr) => {{ + log!(0, "Warning: {}", format!("{} {:?}", $msg, $e).bright_yellow()); + }}; + ($msg1:expr, $msg2:expr, $e:expr) => {{ + log!(0, "Warning: {}", format!("{} {} {:?}", $msg1, $msg2, $e).bright_yellow()); + }}; + (format => $($e:expr),+) => {{ + log!(0, "Warning: {}", format!($($e),+).bright_yellow()); + }}; + ($lvl:expr; $($e:expr),+) => {{ + log!($lvl, "Warning: {}", format!($($e),+).bright_yellow()); + }}; +} + +macro_rules! error { + ($($prefix:expr),+; $e:expr) => { + log!(0, "{}: {}", format!($($prefix),+), format!("{:?}", $e).bright_red()); + }; + ($e:expr) => { + log!(0, "Error: {}", format!("{:?}", $e).bright_red()); + }; +} + +pub fn ask_user_pass(opt: &Opt) -> Result<(String, String)> { + let user = if let Some(username) = opt.username.as_ref() { + username.clone() + } else { + rprompt::prompt_reply_stdout("Username: ").context("username prompt")? + }; + let (pass, should_store); + let keyring = Lazy::new(|| keyring::Entry::new(env!("CARGO_PKG_NAME"), &user)); + if let Some(password) = opt.password.as_ref() { + pass = password.clone(); + should_store = true; + } else if opt.keyring { + match keyring.get_password() { + Ok(password) => { + pass = password; + should_store = false; + }, + Err(e) => { + error!(e); + pass = rpassword::read_password_from_tty(Some("Password: ")).context("password prompt")?; + should_store = true; + } + } + } else { + pass = rpassword::read_password_from_tty(Some("Password: ")).context("password prompt")?; + should_store = true; + } + if should_store && opt.keyring { + keyring.set_password(&pass).map_err(|x| anyhow!(x.to_string()))?; + } + Ok((user, pass)) +} diff --git a/src/ilias.rs b/src/ilias.rs new file mode 100644 index 0000000..049184c --- /dev/null +++ b/src/ilias.rs @@ -0,0 +1,552 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +use std::{collections::HashMap, error::Error as _, io::Write, sync::Arc}; + +use anyhow::{anyhow, Context, Result}; +use cookie_store::CookieStore; +use ignore::gitignore::Gitignore; +use once_cell::sync::Lazy; +use reqwest::{Client, IntoUrl, Proxy, Url}; +use reqwest_cookie_store::CookieStoreMutex; +use scraper::{ElementRef, Html, Selector}; +use serde_json::json; + +use crate::{cli::Opt, queue, util::wrap_html, ILIAS_URL}; + +pub mod course; +pub mod exercise; +pub mod file; +pub mod folder; +pub mod forum; +pub mod plugin_dispatch; +pub mod thread; +pub mod video; +pub mod weblink; + +static LINKS: Lazy = Lazy::new(|| Selector::parse("a").unwrap()); +static ALERT_DANGER: Lazy = Lazy::new(|| Selector::parse("div.alert-danger").unwrap()); +static IL_CONTENT_CONTAINER: Lazy = Lazy::new(|| Selector::parse("#il_center_col").unwrap()); +static BLOCK_FAVORITES: Lazy = Lazy::new(|| Selector::parse("#block_pditems_0").unwrap()); +static ITEM_PROP: Lazy = Lazy::new(|| Selector::parse("span.il_ItemProperty").unwrap()); +static CONTAINER_ITEMS: Lazy = Lazy::new(|| Selector::parse("div.il_ContainerListItem, .il-std-item").unwrap()); +static CONTAINER_ITEM_TITLE: Lazy = Lazy::new(|| Selector::parse("a.il_ContainerItemTitle, .il-item-title > a").unwrap()); + +pub struct ILIAS { + pub opt: Opt, + pub ignore: Gitignore, + client: Client, + cookies: Arc, + pub course_names: HashMap, +} + +/// Returns true if the error is caused by: +/// "http2 error: protocol error: not a result of an error" +fn error_is_http2(error: &reqwest::Error) -> bool { + error + .source() // hyper::Error + .map(|x| x.source()) // h2::Error + .flatten() + .map(|x| x.downcast_ref::()) + .flatten() + .map(|x| x.reason()) + .flatten() + .map(|x| x == h2::Reason::NO_ERROR) + .unwrap_or(false) +} + +impl ILIAS { + // TODO: de-duplicate the logic below + pub async fn with_session( + opt: Opt, + session: Arc, + ignore: Gitignore, + course_names: HashMap, + ) -> Result { + let mut builder = Client::builder() + .cookie_provider(Arc::clone(&session)) + .user_agent(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"))); + if let Some(proxy) = opt.proxy.as_ref() { + let proxy = Proxy::all(proxy)?; + builder = builder.proxy(proxy); + } + let client = builder + // timeout is infinite by default + .build()?; + info!("Re-using previous session cookies.."); + Ok(ILIAS { + opt, + ignore, + client, + cookies: session, + course_names, + }) + } + + pub async fn login( + opt: Opt, + user: &str, + pass: &str, + ignore: Gitignore, + course_names: HashMap, + ) -> Result { + let cookie_store = CookieStore::default(); + let cookie_store = reqwest_cookie_store::CookieStoreMutex::new(cookie_store); + let cookie_store = std::sync::Arc::new(cookie_store); + let mut builder = Client::builder() + .cookie_provider(Arc::clone(&cookie_store)) + .user_agent(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"))); + if let Some(proxy) = opt.proxy.as_ref() { + let proxy = Proxy::all(proxy)?; + builder = builder.proxy(proxy); + } + let client = builder + // timeout is infinite by default + .build()?; + let this = ILIAS { + opt, + ignore, + client, + cookies: cookie_store, + course_names, + }; + info!("Logging into ILIAS using KIT account.."); + let session_establishment = this + .client + .post("https://ilias.studium.kit.edu/Shibboleth.sso/Login") + .form(&json!({ + "sendLogin": "1", + "idp_selection": "https://idp.scc.kit.edu/idp/shibboleth", + "target": "/shib_login.php?target=", + "home_organization_selection": "Mit KIT-Account anmelden" + })) + .send() + .await?; + let url = session_establishment.url().clone(); + let text = session_establishment.text().await?; + let dom_sso = Html::parse_document(text.as_str()); + let csrf_token = dom_sso + .select(&Selector::parse(r#"input[name="csrf_token"]"#).unwrap()) + .next() + .context("no CSRF token found")? + .value() + .attr("value") + .context("no CSRF token value")?; + info!("Logging into Shibboleth.."); + let login_response = this + .client + .post(url) + .form(&json!({ + "j_username": user, + "j_password": pass, + "_eventId_proceed": "", + "csrf_token": csrf_token, + })) + .send() + .await? + .text() + .await?; + let dom = Html::parse_document(&login_response); + let saml = Selector::parse(r#"input[name="SAMLResponse"]"#).unwrap(); + let saml = dom + .select(&saml) + .next() + .context("no SAML response, incorrect password?")?; + let relay_state = Selector::parse(r#"input[name="RelayState"]"#).unwrap(); + let relay_state = dom.select(&relay_state).next().context("no relay state")?; + info!("Logging into ILIAS.."); + this.client + .post("https://ilias.studium.kit.edu/Shibboleth.sso/SAML2/POST") + .form(&json!({ + "SAMLResponse": saml.value().attr("value").context("no SAML value")?, + "RelayState": relay_state.value().attr("value").context("no RelayState value")? + })) + .send() + .await?; + success!("Logged in!"); + Ok(this) + } + + pub async fn save_session(&self) -> Result<()> { + let session_path = self.opt.output.join(".iliassession"); + let mut writer = std::fs::File::create(session_path) + .map(std::io::BufWriter::new) + .unwrap(); + let store = self.cookies.lock().map_err(|x| anyhow!("{}", x))?; + // save all cookies, including session cookies + for cookie in store.iter_unexpired().map(serde_json::to_string) { + writeln!(writer, "{}", cookie?)?; + } + writer.flush()?; + Ok(()) + } + + pub async fn download(&self, url: &str) -> Result { + queue::get_request_ticket().await; + log!(2, "Downloading {}", url); + let url = if url.starts_with("http://") || url.starts_with("https://") { + url.to_owned() + } else if url.starts_with("ilias.studium.kit.edu") { + format!("https://{}", url) + } else { + format!("{}{}", ILIAS_URL, url) + }; + for attempt in 1..10 { + let result = self.client.get(url.clone()).send().await; + match result { + Ok(x) => return Ok(x), + Err(e) if attempt <= 3 && error_is_http2(&e) => { + warning!(1; "encountered HTTP/2 NO_ERROR, retrying download.."); + continue; + }, + Err(e) => return Err(e.into()), + } + } + unreachable!() + } + + pub async fn head(&self, url: U) -> Result { + queue::get_request_ticket().await; + let url = url.into_url()?; + for attempt in 1..10 { + let result = self.client.head(url.clone()).send().await; + match result { + Ok(x) => return Ok(x), + Err(e) if attempt <= 3 && error_is_http2(&e) => { + warning!(1; "encountered HTTP/2 NO_ERROR, retrying HEAD request.."); + continue; + }, + Err(e) => return Err(e), + } + } + unreachable!() + } + + pub async fn get_html(&self, url: &str) -> Result { + let resp = self.download(url).await?; + if resp + .url() + .query() + .map(|x| x.contains("reloadpublic=1") || x.contains("cmd=force_login")) + .unwrap_or(false) + { + return Err(anyhow!("not logged in / session expired")); + } + let text = self.download(url).await?.text().await?; + let html = Html::parse_document(&text); + if html.select(&ALERT_DANGER).next().is_some() { + Err(anyhow!("ILIAS error")) + } else { + Ok(html) + } + } + + pub async fn get_html_fragment(&self, url: &str) -> Result { + let text = self.download(url).await?.text().await?; + let html = Html::parse_fragment(&text); + if html.select(&ALERT_DANGER).next().is_some() { + Err(anyhow!("ILIAS error")) + } else { + Ok(html) + } + } + + pub fn get_items(html: &Html) -> Vec> { + let html = if let Some(favorites) = html.select(&BLOCK_FAVORITES).next() { + favorites + } else { + html.root_element() + }; + html.select(&CONTAINER_ITEMS) + .flat_map(|item| { + item.select(&CONTAINER_ITEM_TITLE) + .next() + .map(|link| Object::from_link(item, link)) + // items without links are ignored + }) + .collect() + } + + /// Returns subfolders and the main text in a course/folder/personal desktop. + pub async fn get_course_content(&self, url: &URL) -> Result<(Vec>, Option)> { + let html = self.get_html(&url.url).await?; + + let main_text = if let Some(el) = html.select(&IL_CONTENT_CONTAINER).next() { + // if we are currently extracting the dashboard, only select the favorites + if let Some(el) = el.select(&BLOCK_FAVORITES).next() { + Some(wrap_html(&el.inner_html())) + } else { + Some(wrap_html(&el.inner_html())) + } + } else { + None + }; + Ok((ILIAS::get_items(&html), main_text)) + } + + pub async fn get_course_content_tree(&self, ref_id: &str, cmd_node: &str) -> Result> { + // TODO: this magically does not return sub-folders + // opening the same url in browser does show sub-folders?! + let url = format!( + "{}ilias.php?ref_id={}&cmdClass=ilobjcoursegui&cmd=showRepTree&cmdNode={}&baseClass=ilRepositoryGUI&cmdMode=asynch&exp_cmd=getNodeAsync&node_id=exp_node_rep_exp_{}&exp_cont=il_expl2_jstree_cont_rep_exp&searchterm=", + ILIAS_URL, ref_id, cmd_node, ref_id + ); + let html = self.get_html_fragment(&url).await?; + let mut items = Vec::new(); + for link in html.select(&LINKS) { + if link.value().attr("href").is_some() { + items.push(Object::from_link(link, link)?); + } // else: disabled course + } + Ok(items) + } +} + +trait IliasObject { + fn download(ilias: Arc) -> Result<()>; +} + +#[derive(Debug)] +pub enum Object { + Course { name: String, url: URL }, + Folder { name: String, url: URL }, + Dashboard { url: URL }, + File { name: String, url: URL }, + Forum { name: String, url: URL }, + Thread { url: URL }, + Wiki { name: String, url: URL }, + ExerciseHandler { name: String, url: URL }, + Weblink { name: String, url: URL }, + Survey { name: String, url: URL }, + Presentation { name: String, url: URL }, + PluginDispatch { name: String, url: URL }, + Video { url: URL }, + Generic { name: String, url: URL }, +} + +use Object::*; + +impl Object { + pub fn name(&self) -> &str { + match self { + Course { name, .. } + | Folder { name, .. } + | File { name, .. } + | Forum { name, .. } + | Wiki { name, .. } + | Weblink { name, .. } + | Survey { name, .. } + | Presentation { name, .. } + | ExerciseHandler { name, .. } + | PluginDispatch { name, .. } + | Generic { name, .. } => &name, + Thread { url } => &url.thr_pk.as_ref().unwrap(), + Video { url } => &url.url, + Dashboard { url } => &url.url + } + } + + pub fn url(&self) -> &URL { + match self { + Course { url, .. } + | Folder { url, .. } + | Dashboard { url } + | File { url, .. } + | Forum { url, .. } + | Thread { url } + | Wiki { url, .. } + | Weblink { url, .. } + | Survey { url, .. } + | Presentation { url, .. } + | ExerciseHandler { url, .. } + | PluginDispatch { url, .. } + | Video { url } + | Generic { url, .. } => &url, + } + } + + pub fn kind(&self) -> &str { + match self { + Course { .. } => "course", + Folder { .. } => "folder", + Dashboard { .. } => "dashboard", + File { .. } => "file", + Forum { .. } => "forum", + Thread { .. } => "thread", + Wiki { .. } => "wiki", + Weblink { .. } => "weblink", + Survey { .. } => "survey", + Presentation { .. } => "presentation", + ExerciseHandler { .. } => "exercise handler", + PluginDispatch { .. } => "plugin dispatch", + Video { .. } => "video", + Generic { .. } => "generic", + } + } + + pub fn is_dir(&self) -> bool { + matches!( + self, + Course { .. } + | Folder { .. } | Dashboard { .. } + | Forum { .. } | Thread { .. } + | Wiki { .. } | ExerciseHandler { .. } + | PluginDispatch { .. } + ) + } + + pub fn from_link(item: ElementRef, link: ElementRef) -> Result { + let name = link.text().collect::().replace('/', "-").trim().to_owned(); + let url = URL::from_href(link.value().attr("href").context("link missing href")?)?; + Object::from_url(url, name, Some(item)) + } + + pub fn from_url(mut url: URL, mut name: String, item: Option) -> Result { + if url.thr_pk.is_some() { + return Ok(Thread { url }); + } + + if url.url.starts_with("https://ilias.studium.kit.edu/goto.php") { + let target = url.target.as_deref().unwrap_or("NONE"); + if target.starts_with("wiki_") { + return Ok(Wiki { + name, + url, // TODO: insert ref_id here + }); + } + if target.starts_with("root_") { + // magazine link + return Ok(Generic { name, url }); + } + if target.starts_with("crs_") { + let ref_id = url.target.as_ref().unwrap().split('_').nth(1).unwrap(); + url.ref_id = ref_id.to_owned(); + return Ok(Course { name, url }); + } + if target.starts_with("frm_") { + // TODO: extract post link? (this codepath should only be hit when parsing the content tree) + let ref_id = url.target.as_ref().unwrap().split('_').nth(1).unwrap(); + url.ref_id = ref_id.to_owned(); + return Ok(Forum { name, url }); + } + if target.starts_with("lm_") { + // fancy interactive task + return Ok(Presentation { name, url }); + } + if target.starts_with("fold_") { + let ref_id = url.target.as_ref().unwrap().split('_').nth(1).unwrap(); + url.ref_id = ref_id.to_owned(); + return Ok(Folder { name, url }); + } + if target.starts_with("file_") { + if !target.ends_with("download") { + // download page containing metadata + return Ok(Generic { name, url }); + } else { + let mut item_props = item + .context("can't construct file object without HTML object")? + .select(&ITEM_PROP); + let ext = item_props.next().context("cannot find file extension")?; + let version = item_props + .nth(1) + .context("cannot find 3rd file metadata")? + .text() + .collect::(); + let version = version.trim(); + if let Some(v) = version.strip_prefix("Version: ") { + name += "_v"; + name += v; + } + return Ok(File { + name: format!("{}.{}", name, ext.text().collect::().trim()), + url, + }); + } + } + return Ok(Generic { name, url }); + } + + if url.cmd.as_deref() == Some("showThreads") { + return Ok(Forum { name, url }); + } + + // class name is *sometimes* in CamelCase + Ok(match &*url.baseClass.to_ascii_lowercase() { + "ilexercisehandlergui" => ExerciseHandler { name, url }, + "ililwikihandlergui" => Wiki { name, url }, + "illinkresourcehandlergui" => Weblink { name, url }, + "ilobjsurveygui" => Survey { name, url }, + "illmpresentationgui" => Presentation { name, url }, + "ilrepositorygui" => match url.cmd.as_deref() { + Some("view") | Some("render") => Folder { name, url }, + Some(_) => Generic { name, url }, + None => Course { name, url }, + }, + "ilobjplugindispatchgui" => PluginDispatch { name, url }, + // both the dashboard and the membership overview page work the same + "ildashboardgui" | "ilmembershipoverviewgui" => Dashboard { url }, + _ => Generic { name, url }, + }) + } + + pub(crate) fn is_ignored_by_option(&self, opt: &Opt) -> bool { + (matches!(self, Object::Forum { .. }) && !opt.forum) + || (matches!(self, Object::Video { .. }) && opt.no_videos) + || (matches!(self, Object::File { .. }) && opt.skip_files) + } +} + +#[allow(non_snake_case)] +#[derive(Debug)] +pub struct URL { + pub url: String, + baseClass: String, + pub cmd: Option, + pub thr_pk: Option, + pub ref_id: String, + target: Option, +} + +#[allow(non_snake_case)] +impl URL { + pub fn raw(url: String) -> Self { + URL { + url, + baseClass: String::new(), + cmd: None, + thr_pk: None, + ref_id: String::new(), + target: None, + } + } + + pub fn from_href(href: &str) -> Result { + let url = if !href.starts_with(ILIAS_URL) { + Url::parse(&format!("{}{}", ILIAS_URL, href))? + } else { + Url::parse(href)? + }; + let mut baseClass = String::new(); + let mut cmd = None; + let mut thr_pk = None; + let mut ref_id = String::new(); + let mut target = None; + for (k, v) in url.query_pairs() { + match &*k { + "baseClass" => baseClass = v.into_owned(), + "cmd" => cmd = Some(v.into_owned()), + "thr_pk" => thr_pk = Some(v.into_owned()), + "ref_id" => ref_id = v.into_owned(), + "target" => target = Some(v.into_owned()), + _ => {}, + } + } + Ok(URL { + url: url.into(), + baseClass, + cmd, + thr_pk, + ref_id, + target, + }) + } +} diff --git a/src/ilias/course.rs b/src/ilias/course.rs new file mode 100644 index 0000000..03d2298 --- /dev/null +++ b/src/ilias/course.rs @@ -0,0 +1,52 @@ +use std::{path::PathBuf, sync::Arc}; + +use anyhow::{Context, Result}; +use once_cell::sync::Lazy; +use regex::Regex; + +use crate::{ + process_gracefully, + queue::spawn, + util::{file_escape, write_file_data}, +}; + +use super::{ILIAS, URL}; + +static CMD_NODE_REGEX: Lazy = Lazy::new(|| Regex::new(r#"cmdNode=uf:\w\w"#).unwrap()); + +pub async fn download(path: PathBuf, ilias: Arc, url: &URL, name: &str) -> Result<()> { + let content = if ilias.opt.content_tree { + let html = ilias.download(&url.url).await?.text().await?; + let cmd_node = CMD_NODE_REGEX.find(&html).context("can't find cmdNode")?.as_str()[8..].to_owned(); + let content_tree = ilias.get_course_content_tree(&url.ref_id, &cmd_node).await; + match content_tree { + Ok(tree) => (tree.into_iter().map(Result::Ok).collect(), None), + Err(e) => { + // some folders are hidden on the course page and can only be found via the RSS feed / recent activity / content tree sidebar + // TODO: this is probably never the case for folders? + if html.contains(r#"input[name="cmd[join]""#) { + return Ok(()); // ignore groups we are not in + } + warning!(name, "falling back to incomplete course content extractor!", e); + ilias.get_course_content(&url).await? // TODO: perhaps don't download almost the same content 3x + }, + } + } else { + ilias.get_course_content(&url).await? + }; + if ilias.opt.save_ilias_pages { + if let Some(s) = content.1.as_ref() { + let path = path.join("course.html"); + write_file_data(&path, &mut s.as_bytes()) + .await + .context("failed to write course page html")?; + } + } + for item in content.0 { + let item = item?; + let path = path.join(file_escape(item.name())); + let ilias = Arc::clone(&ilias); + spawn(process_gracefully(ilias, path, item)); + } + Ok(()) +} diff --git a/src/ilias/exercise.rs b/src/ilias/exercise.rs new file mode 100644 index 0000000..b2f48c2 --- /dev/null +++ b/src/ilias/exercise.rs @@ -0,0 +1,66 @@ +use std::{collections::HashSet, path::Path, sync::Arc}; + +use anyhow::{Context, Result}; +use once_cell::sync::Lazy; +use scraper::Selector; + +use crate::{process_gracefully, queue::spawn, util::file_escape}; + +use super::{Object, ILIAS, URL}; + +static LINKS: Lazy = Lazy::new(|| Selector::parse("a").unwrap()); +static FORM_GROUP: Lazy = Lazy::new(|| Selector::parse(".form-group").unwrap()); +static FORM_NAME: Lazy = Lazy::new(|| Selector::parse(".il_InfoScreenProperty").unwrap()); + +pub async fn download(path: &Path, ilias: Arc, url: &URL) -> Result<()> { + let html = ilias.get_html(&url.url).await?; + let mut filenames = HashSet::new(); + for row in html.select(&FORM_GROUP) { + let link = row.select(&LINKS).next(); + if link.is_none() { + continue; + } + let link = link.unwrap(); + let href = link.value().attr("href"); + if href.is_none() { + continue; + } + let href = href.unwrap(); + let url = URL::from_href(href)?; + let cmd = url.cmd.as_deref().unwrap_or(""); + if cmd != "downloadFile" && cmd != "downloadGlobalFeedbackFile" && cmd != "downloadFeedbackFile" { + continue; + } + // link is definitely just a download link to the exercise or the solution + let name = row + .select(&FORM_NAME) + .next() + .context("link without file name")? + .text() + .collect::() + .trim() + .to_owned(); + let item = Object::File { url, name }; + let mut path = path.to_owned(); + // handle files with the same name + let filename = file_escape(item.name()); + let mut parts = filename.rsplitn(2, '.'); + let extension = parts.next().unwrap_or(&filename); + let name = parts.next().unwrap_or(""); + let mut unique_filename = filename.clone(); + let mut i = 1; + while filenames.contains(&unique_filename) { + i += 1; + if name.is_empty() { + unique_filename = format!("{}{}", extension, i); + } else { + unique_filename = format!("{}{}.{}", name, i, extension); + } + } + filenames.insert(unique_filename.clone()); + path.push(unique_filename); + let ilias = Arc::clone(&ilias); + spawn(process_gracefully(ilias, path, item)); + } + Ok(()) +} diff --git a/src/ilias/file.rs b/src/ilias/file.rs new file mode 100644 index 0000000..1df7b2a --- /dev/null +++ b/src/ilias/file.rs @@ -0,0 +1,22 @@ +use std::{path::Path, sync::Arc}; + +use anyhow::Result; +use tokio::fs; + +use crate::util::write_stream_to_file; + +use super::{ILIAS, URL}; + +pub async fn download(path: &Path, relative_path: &Path, ilias: Arc, url: &URL) -> Result<()> { + if ilias.opt.skip_files { + return Ok(()); + } + if !ilias.opt.force && fs::metadata(&path).await.is_ok() { + log!(2, "Skipping download, file exists already"); + return Ok(()); + } + let data = ilias.download(&url.url).await?; + log!(0, "Writing {}", relative_path.to_string_lossy()); + write_stream_to_file(&path, data.bytes_stream()).await?; + Ok(()) +} diff --git a/src/ilias/folder.rs b/src/ilias/folder.rs new file mode 100644 index 0000000..962192a --- /dev/null +++ b/src/ilias/folder.rs @@ -0,0 +1,32 @@ +use std::{path::Path, sync::Arc}; + +use anyhow::{Context, Result}; + +use crate::{ + process_gracefully, + queue::spawn, + util::{file_escape, write_file_data}, +}; + +use super::{ILIAS, URL}; + +pub async fn download(path: &Path, ilias: Arc, url: &URL) -> Result<()> { + let content = ilias.get_course_content(&url).await?; + if ilias.opt.save_ilias_pages { + if let Some(s) = content.1.as_ref() { + let path = path.join("folder.html"); + write_file_data(&path, &mut s.as_bytes()) + .await + .context("failed to write folder page html")?; + } + } + for item in content.0 { + let item = item?; + let path = path.join(file_escape( + ilias.course_names.get(item.name()).map(|x| &**x).unwrap_or(item.name()), + )); + let ilias = Arc::clone(&ilias); + spawn(process_gracefully(ilias, path, item)); + } + Ok(()) +} diff --git a/src/ilias/forum.rs b/src/ilias/forum.rs new file mode 100644 index 0000000..0e141bc --- /dev/null +++ b/src/ilias/forum.rs @@ -0,0 +1,100 @@ +use std::{path::Path, sync::Arc}; + +use anyhow::{Context, Result}; +use once_cell::sync::Lazy; +use scraper::{Html, Selector}; + +use crate::{ilias::Object, process_gracefully, queue::spawn, util::file_escape}; + +use super::{ILIAS, URL}; + +static LINKS: Lazy = Lazy::new(|| Selector::parse("a").unwrap()); +static TABLE_HEADER: Lazy = Lazy::new(|| Selector::parse("th").unwrap()); +static TABLE_ROW: Lazy = Lazy::new(|| Selector::parse("tr").unwrap()); +static TABLE_CELLS: Lazy = Lazy::new(|| Selector::parse("td").unwrap()); + +static FORUM_PAGES: Lazy = + Lazy::new(|| Selector::parse("div.ilTableNav > table > tbody > tr > td > a").unwrap()); + +const NO_ENTRIES: &str = "Keine Einträge"; + +pub async fn download(path: &Path, ilias: Arc, url: &URL) -> Result<()> { + if !ilias.opt.forum { + return Ok(()); + } + let url = &url.url; + let html = { + let data = ilias.download(url); + let html_text = data.await?.text().await?; + let url = { + let html = Html::parse_document(&html_text); + let thread_count_selector = html + .select(&LINKS) + .flat_map(|x| x.value().attr("href")) + .find(|x| x.contains("trows=800")); + if thread_count_selector.is_none() { + if let Some(cell) = html.select(&TABLE_CELLS).next() { + if cell.text().any(|x| x == NO_ENTRIES) { + return Ok(()); // empty forum + } + } + } + thread_count_selector + .context("can't find forum thread count selector (empty forum?)")? + .to_owned() + }; + let data = ilias.download(&url); + let html = data.await?.text().await?; + Html::parse_document(&html) + }; + for row in html.select(&TABLE_ROW) { + if row.value().attr("class") == Some("hidden-print") { + continue; // thread count + } + if row.select(&TABLE_HEADER).next().is_some() { + continue; + } + let cells = row.select(&TABLE_CELLS).collect::>(); + if cells.len() != 6 { + warning!(format => + "Warning: {}{} {} {}", + "unusual table row (", cells.len(), "cells) in", url.to_string() + ); + continue; + } + let link = cells[1].select(&LINKS).next().context("thread link not found")?; + let object = Object::from_link(link, link)?; + let mut path = path.to_owned(); + let name = format!( + "{}_{}", + object.url().thr_pk.as_ref().context("thr_pk not found for thread")?, + link.text().collect::().trim() + ); + path.push(file_escape(&name)); + // FIXME: this heuristic no longer works after downloading attachments + // TODO: set modification date? + let saved_posts = { + match std::fs::read_dir(&path) { + // TODO: make this async + Ok(stream) => stream.count(), + Err(_) => 0, + } + }; + let available_posts = cells[3] + .text() + .next() + .unwrap_or_default() + .trim() + .parse::() + .context("parsing post count failed")?; + if available_posts <= saved_posts && !ilias.opt.force { + continue; + } + let ilias = Arc::clone(&ilias); + spawn(process_gracefully(ilias, path, object)); + } + if html.select(&FORUM_PAGES).count() > 0 { + log!(0, "Ignoring older threads in {:?}..", path); + } + Ok(()) +} diff --git a/src/ilias/plugin_dispatch.rs b/src/ilias/plugin_dispatch.rs new file mode 100644 index 0000000..23fc45e --- /dev/null +++ b/src/ilias/plugin_dispatch.rs @@ -0,0 +1,92 @@ +use std::{path::Path, sync::Arc}; + +use anyhow::{Context, Result}; +use once_cell::sync::Lazy; +use regex::Regex; +use reqwest::Url; +use scraper::{Html, Selector}; + +use crate::{ilias::Object, process_gracefully, queue::spawn, util::file_escape, ILIAS_URL}; + +use super::{ILIAS, URL}; + +static LINKS: Lazy = Lazy::new(|| Selector::parse("a").unwrap()); +static A_TARGET_BLANK: Lazy = Lazy::new(|| Selector::parse(r#"a[target="_blank"]"#).unwrap()); +static VIDEO_ROWS: Lazy = Lazy::new(|| Selector::parse(".ilTableOuter > div > table > tbody > tr").unwrap()); +static TABLE_CELLS: Lazy = Lazy::new(|| Selector::parse("td").unwrap()); +static LIST_URL: Lazy = Lazy::new(|| Regex::new("ilias\\.php\\?ref_id=\\d+&cmdClass=xocteventgui&cmdNode=.{8}q&baseClass=ilObjPluginDispatchGUI&lang=.{2}&limit=20&cmd=asyncGetTableGUI&cmdMode=asynch").unwrap()); + +const NO_ENTRIES: &str = "Keine Einträge"; + +pub async fn download(path: &Path, ilias: Arc, url: &URL) -> Result<()> { + if ilias.opt.no_videos { + return Ok(()); + } + let full_url = { + let html = ilias.download(&url.url).await?.text().await?; + let list_url = LIST_URL.find(&html).context("failed to find xoct event link")?.as_str(); + let full_list_url = format!("{}{}", ILIAS_URL, list_url); + + // first find the link to full video list + log!(1, "Loading {}", full_list_url); + let data = ilias.download(&full_list_url).await?; + let html = data.text().await?; + let html = Html::parse_fragment(&html); + html.select(&LINKS) + .filter_map(|link| link.value().attr("href")) + .filter(|href| href.contains("trows=800")) + .map(|x| x.to_string()) + .next() + .context("video list link not found")? + }; + log!(1, "Rewriting {}", full_url); + let mut full_url = Url::parse(&format!("{}{}", ILIAS_URL, full_url))?; + let mut query_parameters = full_url + .query_pairs() + .map(|(x, y)| (x.into_owned(), y.into_owned())) + .collect::>(); + for (key, value) in &mut query_parameters { + match key.as_ref() { + "cmd" => *value = "asyncGetTableGUI".into(), + "cmdClass" => *value = "xocteventgui".into(), + _ => {}, + } + } + query_parameters.push(("cmdMode".into(), "asynch".into())); + full_url + .query_pairs_mut() + .clear() + .extend_pairs(&query_parameters) + .finish(); + log!(1, "Loading {}", full_url); + let data = ilias.download(full_url.as_str()).await?; + let html = data.text().await?; + let html = Html::parse_fragment(&html); + for row in html.select(&VIDEO_ROWS) { + let link = row.select(&A_TARGET_BLANK).next(); + if link.is_none() { + if !row.text().any(|x| x == NO_ENTRIES) { + warning!(format => "table row without link in {}", url.url); + } + continue; + } + let link = link.unwrap(); + let mut cells = row.select(&TABLE_CELLS); + if let Some(title) = cells.nth(2) { + let title = title.text().collect::(); + let title = title.trim(); + if title.starts_with(" = Lazy::new(|| Selector::parse("a").unwrap()); +static IMAGES: Lazy = Lazy::new(|| Selector::parse("img").unwrap()); +static TABLES: Lazy = Lazy::new(|| Selector::parse("table").unwrap()); +static LINK_IN_TABLE: Lazy = Lazy::new(|| Selector::parse("tbody tr td a").unwrap()); +static POST_ROW: Lazy = Lazy::new(|| Selector::parse(".ilFrmPostRow").unwrap()); +static POST_TITLE: Lazy = Lazy::new(|| Selector::parse(".ilFrmPostTitle").unwrap()); +static POST_CONTAINER: Lazy = Lazy::new(|| Selector::parse(".ilFrmPostContentContainer").unwrap()); +static POST_ATTACHMENTS: Lazy = Lazy::new(|| Selector::parse(".ilFrmPostAttachmentsContainer").unwrap()); +static SPAN_SMALL: Lazy = Lazy::new(|| Selector::parse("span.small").unwrap()); +static IMAGE_SRC_REGEX: Lazy = Lazy::new(|| Regex::new(r#"\./data/produktiv/mobs/mm_(\d+)/([^?]+).+"#).unwrap()); + +pub async fn download(path: &Path, relative_path: &Path, ilias: Arc, url: &URL) -> Result<()> { + if !ilias.opt.forum { + return Ok(()); + } + let mut all_images = Vec::new(); + let mut attachments = Vec::new(); + { + let html = ilias.get_html(&url.url).await?; + for post in html.select(&POST_ROW) { + let title = post + .select(&POST_TITLE) + .next() + .context("post title not found")? + .text() + .collect::(); + let author = post.select(&SPAN_SMALL).next().context("post author not found")?; + let author = author.text().collect::(); + let author = author.trim().split('|').collect::>(); + let author = if author.len() == 2 { + author[0] // pseudonymous forum + } else if author.len() == 3 { + if author[1] != "Pseudonym" { + author[1] + } else { + author[0] + } + } else { + return Err(anyhow!("author data in unknown format")); + } + .trim(); + let container = post + .select(&POST_CONTAINER) + .next() + .context("post container not found")?; + let link = container.select(&LINKS).next().context("post link not found")?; + let id = link.value().attr("id").context("no id in thread link")?.to_owned(); + let name = format!("{}_{}_{}.html", id, author, title.trim()); + let data = wrap_html(&container.inner_html()); + let path = path.join(file_escape(&name)); + let relative_path = relative_path.join(file_escape(&name)); + spawn(handle_gracefully(async move { + log!(0, "Writing {}", relative_path.display()); + write_file_data(&path, &mut data.as_bytes()) + .await + .context("failed to write forum post") + })); + let images = container + .select(&IMAGES) + .map(|x| x.value().attr("src").map(|x| x.to_owned())); + for image in images { + let image = image.context("no src on image")?; + all_images.push((id.clone(), image)); + } + if let Some(container) = container.select(&POST_ATTACHMENTS).next() { + for attachment in container.select(&LINKS) { + let href = attachment + .value() + .attr("href") + .map(|x| x.to_owned()) + .context("attachment link without href")?; + if href.contains("cmd=deliverZipFile") { + continue; // skip downloading all attachments as zip + } + attachments.push((id.clone(), attachment.text().collect::(), href)); + } + } + } + // pagination + if let Some(pages) = html.select(&TABLES).next() { + if let Some(last) = pages.select(&LINK_IN_TABLE).last() { + let text = last.text().collect::(); + if text.trim() == ">>" { + // not last page yet + let ilias = Arc::clone(&ilias); + let next_page = Object::Thread { + url: URL::from_href(last.value().attr("href").context("page link not found")?)?, + }; + spawn(process_gracefully(ilias, path.to_owned(), next_page)); + } + } else { + log!( + 0, + "Warning: {} {}", + "unable to find pagination links in".bright_yellow(), + url.url.to_string().bright_yellow() + ); + } + } + } + for (id, image) in all_images { + let src = URL::from_href(&image)?; + let dl = ilias.download(&src.url).await?; + let mut path = path.to_owned(); + let file_name = if let Some(m) = IMAGE_SRC_REGEX.captures(&image) { + // image uploaded to ILIAS + let (media_id, filename) = (m.get(1).unwrap().as_str(), m.get(2).unwrap().as_str()); + file_escape(&format!("{}_{}_{}", id, media_id, filename)) + } else { + // external image + file_escape(&format!("{}_{}", id, image)) + }; + path.push(&file_name); + let relative_path = relative_path.join(file_name); + spawn(handle_gracefully(async move { + let bytes = dl.bytes().await?; + log!(0, "Writing {}", relative_path.display()); + write_file_data(&path, &mut &*bytes) + .await + .context("failed to write forum post image attachment") + })); + } + for (id, name, url) in attachments { + let src = URL::from_href(&url)?; + let dl = ilias.download(&src.url).await?; + let mut path = path.to_owned(); + let file_name = file_escape(&format!("{}_{}", id, name)); + path.push(&file_name); + let relative_path = relative_path.join(file_name); + spawn(handle_gracefully(async move { + let bytes = dl.bytes().await?; + log!(0, "Writing {}", relative_path.display()); + write_file_data(&path, &mut &*bytes) + .await + .context("failed to write forum post file attachment") + })); + } + Ok(()) +} diff --git a/src/ilias/video.rs b/src/ilias/video.rs new file mode 100644 index 0000000..2437ddc --- /dev/null +++ b/src/ilias/video.rs @@ -0,0 +1,134 @@ +use std::{ + path::{Path, PathBuf}, + process::Stdio, + sync::Arc, +}; + +use anyhow::{Context, Result}; +use once_cell::sync::Lazy; +use regex::Regex; +use tempfile::tempdir; +use tokio::{fs, process::Command}; + +use crate::{util::write_stream_to_file, ILIAS_URL}; + +use super::{ILIAS, URL}; + +static XOCT_REGEX: Lazy = + Lazy::new(|| Regex::new(r#"(?m)"#).unwrap()); + +pub async fn download(path: &Path, relative_path: &Path, ilias: Arc, url: &URL) -> Result<()> { + if ilias.opt.no_videos { + return Ok(()); + } + if fs::metadata(&path).await.is_ok() && !(ilias.opt.force || ilias.opt.check_videos) { + log!(2, "Skipping download, file exists already"); + return Ok(()); + } + let url = format!("{}{}", ILIAS_URL, url.url); + let data = ilias.download(&url); + let html = data.await?.text().await?; + log!(2, "{}", html); + let json: serde_json::Value = { + let mut json_capture = XOCT_REGEX.captures_iter(&html); + let json = &json_capture.next().context("xoct player json not found")?[1]; + log!(2, "{}", json); + let json = json.split(",\n").next().context("invalid xoct player json")?; + serde_json::from_str(&json.trim())? + }; + log!(2, "{}", json); + let streams = json + .get("streams") + .context("video streams not found")? + .as_array() + .context("video streams not an array")?; + if streams.len() == 1 { + let url = streams[0] + .pointer("/sources/mp4/0/src") + .context("video src not found")? + .as_str() + .context("video src not string")?; + download_to_path(&ilias, path, relative_path, url).await?; + } else { + if !ilias.opt.combine_videos { + fs::create_dir(path).await.context("failed to create video directory")?; + download_all(path, streams, ilias, relative_path).await?; + } else { + let dir = tempdir()?; + // construct ffmpeg command to combine all files + let mut arguments = vec![]; + for file in download_all(dir.path(), streams, ilias, relative_path).await? { + arguments.push("-i".to_owned()); + arguments.push(file.to_str().context("invalid UTF8")?.into()); + } + arguments.push("-c".into()); + arguments.push("copy".into()); + for i in 0..(arguments.len() / 2) - 1 { + arguments.push("-map".into()); + arguments.push(format!("{}", i)); + } + arguments.push(path.to_str().context("invalid UTF8 in path")?.into()); + let status = Command::new("ffmpeg") + .args(&arguments) + .stderr(Stdio::null()) + .stdout(Stdio::null()) + .spawn() + .context("failed to start ffmpeg")? + .wait() + .await + .context("failed to wait for ffmpeg")?; + if !status.success() { + error!(format!("ffmpeg failed to merge video files into {}", path.display())); + error!(format!("check this directory: {}", dir.into_path().display())); + error!(format!("ffmpeg command: {}", arguments.join(" "))); + } + }; + } + Ok(()) +} + +async fn download_all( + path: &Path, + streams: &Vec, + ilias: Arc, + relative_path: &Path, +) -> Result> { + let mut paths = Vec::new(); + for (i, stream) in streams.into_iter().enumerate() { + let url = stream + .pointer("/sources/mp4/0/src") + .context("video src not found")? + .as_str() + .context("video src not string")?; + let new_path = path.join(format!("Stream{}.mp4", i + 1)); + download_to_path( + &ilias, + &new_path, + &relative_path.join(format!("Stream{}.mp4", i + 1)), + url, + ) + .await?; + paths.push(new_path); + } + Ok(paths) +} + +async fn download_to_path(ilias: &ILIAS, path: &Path, relative_path: &Path, url: &str) -> Result<()> { + let meta = fs::metadata(&path).await; + if !ilias.opt.force && meta.is_ok() && ilias.opt.check_videos { + let head = ilias.head(url).await.context("HEAD request failed")?; + if let Some(len) = head.headers().get("content-length") { + if meta?.len() != len.to_str()?.parse::()? { + warning!( + relative_path.to_string_lossy(), + "was updated, consider moving the outdated file" + ); + } + } + } else { + let resp = ilias.download(&url).await?; + log!(0, "Writing {}", relative_path.to_string_lossy()); + write_stream_to_file(&path, resp.bytes_stream()).await?; + } + Ok(()) +} diff --git a/src/ilias/weblink.rs b/src/ilias/weblink.rs new file mode 100644 index 0000000..72e7763 --- /dev/null +++ b/src/ilias/weblink.rs @@ -0,0 +1,70 @@ +use std::{path::Path, sync::Arc}; + +use anyhow::{Context, Result}; +use once_cell::sync::Lazy; +use scraper::Selector; +use tokio::fs; + +use crate::{ + util::{create_dir, file_escape, write_file_data}, + ILIAS_URL, +}; + +use super::{ILIAS, URL}; + +static LINKS: Lazy = Lazy::new(|| Selector::parse("a").unwrap()); + +pub async fn download(path: &Path, relative_path: &Path, ilias: Arc, url: &URL) -> Result<()> { + if !ilias.opt.force && fs::metadata(&path).await.is_ok() { + log!(2, "Skipping download, link exists already"); + return Ok(()); + } + let head_req_result = ilias.head(&url.url).await; + let url = match &head_req_result { + Err(e) => e.url().context("HEAD request failed")?.as_str(), + Ok(head) => head.url().as_str(), + }; + if url.starts_with(ILIAS_URL) { + // is a link list + if fs::metadata(&path).await.is_err() { + create_dir(&path).await?; + log!(0, "Writing {}", relative_path.to_string_lossy()); + } + + let urls = { + let html = ilias.get_html(url).await?; + html.select(&LINKS) + .filter_map(|x| x.value().attr("href").map(|y| (y, x.text().collect::()))) + .map(|(x, y)| { + URL::from_href(x) + .map(|z| (z, y.trim().to_owned())) + .context("parsing weblink") + }) + .collect::>>() + }?; + + for (url, name) in urls { + if url.cmd.as_deref().unwrap_or("") != "callLink" { + continue; + } + + let head = ilias + .head(url.url.as_str()) + .await + .context("HEAD request to web link failed"); + if let Some(err) = head.as_ref().err() { + warning!(err); + continue; + } + let head = head.unwrap(); + let url = head.url().as_str(); + write_file_data(path.join(file_escape(&name)), &mut url.as_bytes()).await?; + } + } else { + log!(0, "Writing {}", relative_path.to_string_lossy()); + write_file_data(&path, &mut url.as_bytes()) + .await + .context("failed to save weblink URL")?; + } + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 6dc0b99..3ebc493 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,560 +1,273 @@ -use anyhow::{Context, Result, anyhow}; +// SPDX-License-Identifier: GPL-3.0-or-later + +use anyhow::{anyhow, Context, Result}; use futures::future::{self, Either}; -use futures_channel::mpsc::UnboundedSender; -use futures_util::{StreamExt, stream::TryStreamExt}; +use futures::StreamExt; use ignore::gitignore::Gitignore; -use lazy_static::lazy_static; -use parking_lot::Mutex; -use regex::Regex; -use reqwest::Client; -use scraper::{ElementRef, Html, Selector}; -use serde_json::json; +use indicatif::{ProgressDrawTarget, ProgressStyle}; use structopt::StructOpt; use tokio::fs; -use tokio::task::{self, JoinHandle}; -use tokio_util::io::StreamReader; -use url::Url; -use std::{collections::HashSet, default::Default}; +use std::collections::HashMap; use std::future::Future; -use std::io; -use std::panic; +use std::io::BufReader; use std::path::PathBuf; +use std::sync::atomic::Ordering; use std::sync::Arc; -use std::time::Duration; +use std::time::SystemTime; +static ILIAS_URL: &str = "https://ilias.studium.kit.edu/"; +/// main personal desktop +static DEFAULT_SYNC_URL: &str = + "https://ilias.studium.kit.edu/ilias.php?baseClass=ilDashboardGUI&cmd=jumpToMemberships"; + +#[macro_use] +mod cli; +use cli::*; +mod ilias; +use ilias::*; +use Object::*; +mod queue; mod util; use util::*; -const ILIAS_URL: &str = "https://ilias.studium.kit.edu/"; - #[tokio::main] async fn main() { - let mut opt = Opt::from_args(); - opt.output = fs::canonicalize(opt.output).await.expect("failed to canonicalize directory"); // use long paths on Windows - create_dir(&opt.output).await.expect("failed to create output directory"); - // need this because task scheduling is WIP - // (would wait forever on paniced task) - *PANIC_HOOK.lock() = panic::take_hook(); - panic::set_hook(Box::new(|info| { - *TASKS_RUNNING.lock() -= 1; - PANIC_HOOK.lock()(info); - })); - - // load .iliasignore file - opt.output.push(".iliasignore"); - let (ignore, error) = Gitignore::new(&opt.output); - if let Some(err) = error { - println!("Warning: .iliasignore error: {}", err); + let opt = Opt::from_args(); + if let Err(e) = real_main(opt).await { + error!(e); } - opt.output.pop(); - // loac .iliaslogin file - opt.output.push(".iliaslogin"); - let login = std::fs::read_to_string(&opt.output); +} + +async fn try_to_load_session(opt: Opt, ignore: Gitignore, course_names: HashMap) -> Result { + let session_path = opt.output.join(".iliassession"); + let meta = tokio::fs::metadata(&session_path).await?; + let modified = meta.modified()?; + let now = SystemTime::now(); + // the previous session is only useful if it isn't older than ~1 hour + let duration = now.duration_since(modified)?; + if duration.as_secs() <= 60 * 60 { + let file = std::fs::File::open(session_path)?; + let cookies = cookie_store::CookieStore::load_json(BufReader::new(file)) + .map_err(|err| anyhow!(err)) + .context("failed to load session cookies")?; + let cookie_store = reqwest_cookie_store::CookieStoreMutex::new(cookies); + let cookie_store = std::sync::Arc::new(cookie_store); + Ok(ILIAS::with_session(opt, cookie_store, ignore, course_names).await?) + } else { + Err(anyhow!("session data too old")) + } +} + +async fn login(opt: Opt, ignore: Gitignore, course_names: HashMap) -> Result { + // load .iliassession file + if opt.keep_session { + match try_to_load_session(opt.clone(), ignore.clone(), course_names.clone()) + .await + .context("failed to load previous session") + { + Ok(ilias) => { + info!("Checking session validity.."); + // TODO: this probably isn't the best solution.. + if let Err(e) = ilias.get_html(DEFAULT_SYNC_URL).await { + error!(e); + } else { + success!("Session still active!"); + return Ok(ilias); + } + }, + Err(e) => warning!(e), + } + } + + // load .iliaslogin file + let iliaslogin = opt.output.join(".iliaslogin"); + let login = std::fs::read_to_string(&iliaslogin); let (user, pass) = if let Ok(login) = login { let mut lines = login.split('\n'); - let user = lines.next(); - let pass = lines.next(); - if user.is_some() && pass.is_some() { - let user = user.unwrap().trim(); - let pass = pass.unwrap().trim(); - (user.to_owned(), pass.to_owned()) - } else { - println!("Warning: .iliaslogin incomplete"); - ask_user_pass() - } + let user = lines.next().context("missing user in .iliaslogin")?; + let pass = lines.next().context("missing password in .iliaslogin")?; + let user = user.trim(); + let pass = pass.trim(); + (user.to_owned(), pass.to_owned()) } else { - ask_user_pass() + ask_user_pass(&opt).context("credentials input failed")? }; - opt.output.pop(); - let ilias = match ILIAS::login(opt, user, pass, ignore).await { + let ilias = match ILIAS::login(opt, &user, &pass, ignore, course_names).await { Ok(ilias) => ilias, Err(e) => { - print!("{:?}", e); + error!(e); std::process::exit(77); - } + }, }; + Ok(ilias) +} + +async fn real_main(mut opt: Opt) -> Result<()> { + LOG_LEVEL.store(opt.verbose, Ordering::SeqCst); + #[cfg(windows)] + let _ = colored::control::set_virtual_terminal(true); + + create_dir(&opt.output) + .await + .context("failed to create output directory")?; + // use UNC paths on Windows (to avoid the default max. path length of 255) + opt.output = fs::canonicalize(opt.output) + .await + .context("failed to canonicalize output directory")?; + + // load .iliasignore file + let (ignore, error) = Gitignore::new(opt.output.join(".iliasignore")); + + // Load course_names.toml file + let course_names_path = opt.output.join("course_names.toml"); + let course_names = if fs::metadata(&course_names_path).await.is_ok() { + // file exists, try to read it + toml::from_str( + &fs::read_to_string(course_names_path) + .await + .context("accessing course_names.toml")?, + ) + .context("processing course_names.toml")? + } else { + // If file doesn't exist, initialise course_names with empty HashMap + HashMap::new() + }; + + if let Some(err) = error { + warning!(err); + } + + queue::set_download_rate(opt.rate); + + let ilias = login(opt, ignore, course_names).await?; + if ilias.opt.content_tree { - // need this to get the content tree - if let Err(e) = ilias.client.get("https://ilias.studium.kit.edu/ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&set_mode=tree&ref_id=1").send().await { - println!("Warning: could not enable content tree: {:?}", e); + if let Err(e) = ilias + .download("ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&set_mode=tree&ref_id=1") + .await + { + warning!("could not enable content tree:", e); } } let ilias = Arc::new(ilias); - let desktop = ilias.personal_desktop().await.context("Failed to load personal desktop"); - let (tx, mut rx) = futures_channel::mpsc::unbounded::>(); - *TASKS.lock() = Some(tx.clone()); - match desktop { - Ok(desktop) => { - for item in desktop.items { - let mut path = ilias.opt.output.clone(); - path.push(file_escape(item.name())); - let ilias = Arc::clone(&ilias); - let _ = tx.unbounded_send(task::spawn(process_gracefully(ilias, path, item))); - } - }, - Err(e) => println!("{:?}", e) + let mut rx = queue::set_parallel_jobs(ilias.opt.jobs); + PROGRESS_BAR_ENABLED.store(atty::is(atty::Stream::Stdout), Ordering::SeqCst); + if PROGRESS_BAR_ENABLED.load(Ordering::SeqCst) { + PROGRESS_BAR.set_draw_target(ProgressDrawTarget::stderr_nohz()); + PROGRESS_BAR.set_style(ProgressStyle::default_bar().template("[{pos}/{len}+] {wide_msg}")); + PROGRESS_BAR.set_message("initializing.."); } - loop { - match future::select(rx.next(), future::ready(())).await { - // if the channel is empty, all tasks are completed - Either::Left((task, _)) => if let Some(task) = task { let _ = task.await; } else { break }, - Either::Right(_) => break + + let sync_url = ilias.opt.sync_url.as_deref().unwrap_or(DEFAULT_SYNC_URL); + let obj = Object::from_url( + URL::from_href(sync_url).context("invalid sync URL")?, + String::new(), + None, + ) + .context("invalid sync object")?; + queue::spawn(process_gracefully(ilias.clone(), ilias.opt.output.clone(), obj)); + + while let Either::Left((task, _)) = future::select(rx.next(), future::ready(())).await { + if let Some(task) = task { + if let Err(e) = task.await { + error!(e); + } + } else { + break; // channel is empty => all tasks are completed } } if ilias.opt.content_tree { - // restore fast page loading times - if let Err(e) = ilias.client.get("https://ilias.studium.kit.edu/ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&set_mode=flat&ref_id=1").send().await { - println!("Warning: could not disable content tree: {:?}", e); + if let Err(e) = ilias + .download("ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&set_mode=flat&ref_id=1") + .await + { + warning!("could not disable content tree:", e); } } -} - -lazy_static!{ - static ref TASKS: Mutex>>> = Mutex::default(); - static ref TASKS_RUNNING: Mutex = Mutex::default(); - - static ref PANIC_HOOK: Mutex> = Mutex::new(Box::new(|_| {})); -} - -macro_rules! spawn { - ($e:expr) => { - let _ = TASKS.lock().as_ref().unwrap().unbounded_send(task::spawn($e)); - } -} - -fn ask_user_pass() -> (String, String) { - let user = rprompt::prompt_reply_stdout("Username: ").expect("username prompt"); - let pass = rpassword::read_password_from_tty(Some("Password: ")).expect("password prompt"); - (user, pass) -} - -fn process_gracefully(ilias: Arc, path: PathBuf, obj: Object) -> impl Future + Send { async move { - loop { - { // limit scope of lock - let mut running = TASKS_RUNNING.lock(); - if *running < ilias.opt.jobs { - *running += 1; - break; - } + if ilias.opt.keep_session { + if let Err(e) = ilias.save_session().await.context("failed to save session cookies") { + warning!(e) } - tokio::time::sleep(Duration::from_millis(50)).await; } - let path_text = path.to_string_lossy().into_owned(); - if let Err(e) = process(ilias, path, obj).await.context("failed to process URL") { - println!("Syncing {}: {:?}", path_text, e); + if PROGRESS_BAR_ENABLED.load(Ordering::SeqCst) { + PROGRESS_BAR.set_style(ProgressStyle::default_bar().template("[{pos}/{len}] {wide_msg}")); + PROGRESS_BAR.finish_with_message("done"); } - *TASKS_RUNNING.lock() -= 1; -}} + Ok(()) +} + +// https://github.com/rust-lang/rust/issues/53690#issuecomment-418911229 +#[allow(clippy::manual_async_fn)] +fn process_gracefully(ilias: Arc, path: PathBuf, obj: Object) -> impl Future + Send { + if PROGRESS_BAR_ENABLED.load(Ordering::SeqCst) { + PROGRESS_BAR.inc_length(1); + } + async move { + let permit = queue::get_ticket().await; + let path_text = path.to_string_lossy().into_owned(); + if let Err(e) = process(ilias, path, obj).await.context("failed to process URL") { + error!("Syncing {}", path_text; e); + } + drop(permit); + } +} async fn handle_gracefully(fut: impl Future>) { if let Err(e) = fut.await { - println!("Error: {:?}", e); + error!(e); } } -#[allow(non_upper_case_globals)] -mod selectors { - use lazy_static::lazy_static; - use regex::Regex; - use scraper::Selector; - // construct CSS selectors once - lazy_static!{ - pub static ref a: Selector = Selector::parse("a").unwrap(); - pub static ref a_target_blank: Selector = Selector::parse(r#"a[target="_blank"]"#).unwrap(); - pub static ref table: Selector = Selector::parse("table").unwrap(); - pub static ref video_tr: Selector = Selector::parse(".ilTableOuter > div > table > tbody > tr").unwrap(); - pub static ref links_in_table: Selector = Selector::parse("tbody tr td a").unwrap(); - pub static ref td: Selector = Selector::parse("td").unwrap(); - pub static ref tr: Selector = Selector::parse("tr").unwrap(); - pub static ref post_row: Selector = Selector::parse(".ilFrmPostRow").unwrap(); - pub static ref post_title: Selector = Selector::parse(".ilFrmPostTitle").unwrap(); - pub static ref post_container: Selector = Selector::parse(".ilFrmPostContentContainer").unwrap(); - pub static ref post_content: Selector = Selector::parse(".ilFrmPostContent").unwrap(); - pub static ref span_small: Selector = Selector::parse("span.small").unwrap(); - pub static ref forum_pages: Selector = Selector::parse("div.ilTableNav > table > tbody > tr > td > a").unwrap(); - pub static ref alert_danger: Selector = Selector::parse("div.alert-danger").unwrap(); - pub static ref tree_highlighted: Selector = Selector::parse("span.ilHighlighted").unwrap(); - pub static ref form_group: Selector = Selector::parse(".form-group").unwrap(); - pub static ref form_name: Selector = Selector::parse(".il_InfoScreenProperty").unwrap(); - - pub static ref cmd_node_regex: Regex = Regex::new(r#"cmdNode=uf:\w\w"#).unwrap(); - } -} -use crate::selectors::*; - -// see https://github.com/rust-lang/rust/issues/53690#issuecomment-418911229 -//async fn process(ilias: Arc, path: PathBuf, obj: Object) { -fn process(ilias: Arc, mut path: PathBuf, obj: Object) -> impl Future> + Send { async move { - let log_level = ilias.opt.verbose; - macro_rules! log { - ($lvl:expr, $($arg:expr),*) => { - #[allow(unused_comparisons)] // 0 >= 0 - if log_level >= $lvl { - println!($($arg),*); - } +async fn process(ilias: Arc, path: PathBuf, obj: Object) -> Result<()> { + let relative_path = path.strip_prefix(&ilias.opt.output).unwrap(); + if PROGRESS_BAR_ENABLED.load(Ordering::SeqCst) { + let path = relative_path.display().to_string(); + if !path.is_empty() { + PROGRESS_BAR.set_message(path); } } - - let relative_path = path.strip_prefix(&ilias.opt.output).unwrap(); - if ilias.ignore.matched(relative_path, obj.is_dir()).is_ignore() { + // root path should not be matched + if relative_path.parent().is_some() && ilias.ignore.matched(relative_path, obj.is_dir()).is_ignore() { log!(1, "Ignored {}", relative_path.to_string_lossy()); return Ok(()); } log!(1, "Syncing {} {}", obj.kind(), relative_path.to_string_lossy()); log!(2, " URL: {}", obj.url().url); + if obj.is_ignored_by_option(&ilias.opt) { + return Ok(()); + } + if obj.is_dir() { + create_dir(&path).await?; + } match &obj { Course { url, name } => { - create_dir(&path).await?; - let content = if ilias.opt.content_tree { - let html = ilias.download(&url.url).await?.text().await?; - let cmd_node = cmd_node_regex.find(&html).context("can't find cmdNode")?.as_str()[8..].to_owned(); - let content_tree = ilias.get_course_content_tree(&url.ref_id, &cmd_node).await; - match content_tree { - Ok(tree) => tree, - Err(e) => { - // some folders are hidden on the course page and can only be found via the RSS feed / recent activity / content tree sidebar - // TODO: this is probably never the case for folders? - if html.contains(r#"input[name="cmd[join]""#) { - return Ok(()); // ignore groups we are not in - } - log!(0, "Warning: {:?} falling back to incomplete course content extractor! {:?}", name, e); - ilias.get_course_content(&url).await?.into_iter().flat_map(Result::ok).collect() // TODO: perhaps don't download almost the same content 3x - } - } - } else { - ilias.get_course_content(&url).await?.into_iter().flat_map(Result::ok).collect() - }; - for item in content { - let mut path = path.clone(); - path.push(file_escape(item.name())); - let ilias = Arc::clone(&ilias); - spawn!(process_gracefully(ilias, path, item)); - } + ilias::course::download(path, ilias, url, name).await?; }, - Folder { url, .. } => { - create_dir(&path).await?; - let content = ilias.get_course_content(&url).await?; - for item in content { - if item.is_err() { - log!(1, "Ignoring: {:?}", item.err().unwrap()); - continue; - } - let item = item.unwrap(); - let mut path = path.clone(); - path.push(file_escape(item.name())); - let ilias = Arc::clone(&ilias); - spawn!(process_gracefully(ilias, path, item)); - } + Folder { url, .. } | Dashboard { url } => { + ilias::folder::download(&path, ilias, url).await?; }, File { url, .. } => { - if ilias.opt.skip_files { - return Ok(()); - } - if !ilias.opt.force && fs::metadata(&path).await.is_ok() { - log!(2, "Skipping download, file exists already"); - return Ok(()); - } - let data = ilias.download(&url.url).await?; - let mut reader = StreamReader::new(data.bytes_stream().map_err(|x| { - io::Error::new(io::ErrorKind::Other, x) - })); - log!(0, "Writing {}", relative_path.to_string_lossy()); - write_file_data(&path, &mut reader).await.context("failed to save file")?; + ilias::file::download(&path, relative_path, ilias, url).await?; }, PluginDispatch { url, .. } => { - if ilias.opt.no_videos { - return Ok(()); - } - create_dir(&path).await?; - let full_url = { - // first find the link to full video list - let list_url = format!("{}ilias.php?ref_id={}&cmdClass=xocteventgui&cmdNode=nc:n4:14u&baseClass=ilObjPluginDispatchGUI&lang=de&limit=20&cmd=asyncGetTableGUI&cmdMode=asynch", ILIAS_URL, url.ref_id); - log!(1, "Loading {}", list_url); - let data = ilias.download(&list_url).await?; - let html = data.text().await?; - let html = Html::parse_fragment(&html); - html.select(&a) - .filter_map(|link| link.value().attr("href")) - .filter(|href| href.contains("trows=800")) - .map(|x| x.to_string()).next().ok_or(anyhow!("video list link not found"))? - }; - log!(1, "Rewriting {}", full_url); - let mut full_url = Url::parse(&format!("{}{}", ILIAS_URL, full_url))?; - let mut query_parameters = full_url.query_pairs().map(|(x,y)| (x.into_owned(), y.into_owned())).collect::>(); - for (key, value) in &mut query_parameters { - match key.as_ref() { - "cmd" => *value = "asyncGetTableGUI".into(), - "cmdClass" => *value = "xocteventgui".into(), - _ => {} - } - } - query_parameters.push(("cmdMode".into(), "asynch".into())); - full_url.query_pairs_mut().clear().extend_pairs(&query_parameters).finish(); - log!(1, "Loading {}", full_url); - let data = ilias.download(&full_url.into_string()).await?; - let html = data.text().await?; - let html = Html::parse_fragment(&html); - for row in html.select(&video_tr) { - let link = row.select(&a_target_blank).next(); - if link.is_none() { - log!(0, "Warning: table row without link in {}", url.url); - continue; - } - let link = link.unwrap(); - let mut cells = row.select(&td); - if let Some(title) = cells.nth(2) { - let title = title.text().collect::(); - let title = title.trim(); - if title.starts_with(" { - lazy_static!{ - static ref XOCT_REGEX: Regex = Regex::new(r#"(?m)"#).unwrap(); - } - if ilias.opt.no_videos { - return Ok(()); - } - if fs::metadata(&path).await.is_ok() && !(ilias.opt.force || ilias.opt.check_videos) { - log!(2, "Skipping download, file exists already"); - return Ok(()); - } - let url = format!("{}{}", ILIAS_URL, url.url); - let data = ilias.download(&url); - let html = data.await?.text().await?; - log!(2, "{}", html); - let json: serde_json::Value = { - let mut json_capture = XOCT_REGEX.captures_iter(&html); - let json = &json_capture.next().context("xoct player json not found")?[1]; - log!(2, "{}", json); - let json = json.split(",\n").next().context("invalid xoct player json")?; - serde_json::from_str(&json.trim())? - }; - log!(2, "{}", json); - let url = json - .pointer("/streams/0/sources/mp4/0/src") - .map(|x| x.as_str()) - .ok_or(anyhow!("video src not found"))? - .ok_or(anyhow!("video src not string"))?; - let meta = fs::metadata(&path).await; - if !ilias.opt.force && meta.is_ok() && ilias.opt.check_videos { - let head = ilias.client.head(url).send().await.context("HEAD request failed")?; - if let Some(len) = head.headers().get("content-length") { - if meta.unwrap().len() != len.to_str()?.parse::()? { - log!(0, "Warning: {} was updated, consider moving the outdated file", relative_path.to_string_lossy()); - } - } - } else { - let resp = ilias.download(&url).await?; - let mut reader = StreamReader::new(resp.bytes_stream().map_err(|x| { - io::Error::new(io::ErrorKind::Other, x) - })); - log!(0, "Writing {}", relative_path.to_string_lossy()); - write_file_data(&path, &mut reader).await.context("failed to save video")?; - } + ilias::video::download(&path, relative_path, ilias, url).await?; }, Forum { url, .. } => { - if !ilias.opt.forum { - return Ok(()); - } - create_dir(&path).await?; - let url = format!("{}ilias.php?ref_id={}&cmd=showThreads&cmdClass=ilrepositorygui&cmdNode=uf&baseClass=ilrepositorygui", ILIAS_URL, url.ref_id); - let html = { - let data = ilias.download(&url); - let html_text = data.await?.text().await?; - let url = { - let html = Html::parse_document(&html_text); - //https://ilias.studium.kit.edu/ilias.php?ref_id=122&cmdClass=ilobjforumgui&frm_tt_e39_122_trows=800&cmd=showThreads&cmdNode=uf:lg&baseClass=ilrepositorygui - html - .select(&a) - .flat_map(|x| x.value().attr("href")) - .find(|x| x.contains("trows=800")) - .context("can't find forum thread count selector (empty forum?)")?.to_owned() - }; - let data = ilias.download(&url); - let html = data.await?.text().await?; - Html::parse_document(&html) - }; - for row in html.select(&tr) { - let cells = row.select(&td).collect::>(); - if cells.len() != 6 { - log!(0, "Warning: unusual table row ({} cells) in {}", cells.len(), url); - continue; - } - let link = cells[1].select(&a).next().context("thread link not found")?; - let object = Object::from_link(link, link)?; - let mut path = path.clone(); - let name = format!("{}_{}", - object.url().thr_pk.as_ref().context("thr_pk not found for thread")?, - link.text().collect::().trim() - ); - path.push(file_escape(&name)); - // TODO: set modification date? - let saved_posts = { - match std::fs::read_dir(&path) { // TODO: make this async - Ok(stream) => stream.count(), - Err(_) => 0 - } - }; - let available_posts = cells[3].text().next().unwrap_or_default().trim().parse::().context("parsing post count failed")?; - if available_posts <= saved_posts && !ilias.opt.force { - continue; - } - log!(0, "New posts in {:?}..", path); - let ilias = Arc::clone(&ilias); - spawn!(process_gracefully(ilias, path, object)); - } - if html.select(&forum_pages).count() > 0 { - log!(0, "Ignoring older threads in {:?}..", path); - } + ilias::forum::download(&path, ilias, url).await?; }, Thread { url } => { - if !ilias.opt.forum { - return Ok(()); - } - create_dir(&path).await?; - let html = ilias.get_html(&url.url).await?; - for post in html.select(&post_row) { - let title = post.select(&post_title).next().ok_or(anyhow!("post title not found"))?.text().collect::().replace('/', "-"); - let author = post.select(&span_small).next().ok_or(anyhow!("post author not found"))?; - let author = author.text().collect::(); - let author = author.trim().split('|').nth(1).ok_or(anyhow!("author data in unknown format"))?.trim(); - let container = post.select(&post_container).next().ok_or(anyhow!("post container not found"))?; - let link = container.select(&a).next().ok_or(anyhow!("post link not found"))?; - let name = format!("{}_{}_{}.html", link.value().attr("name").ok_or(anyhow!("post name in link not found"))?, author, title.trim()); - let data = post.select(&post_content).next().ok_or(anyhow!("post content not found"))?; - let data = data.inner_html(); - let mut path = path.clone(); - path.push(file_escape(&name)); - spawn!(handle_gracefully(async move { - write_file_data(&path, &mut data.as_bytes()).await - .context("failed to write forum post") - })); - } - // pagination - if let Some(pages) = html.select(&table).next() { - if let Some(last) = pages.select(&links_in_table).last() { - let text = last.text().collect::(); - if text.trim() == ">>" { - // not last page yet - let ilias = Arc::clone(&ilias); - let next_page = Thread { - url: URL::from_href(last.value().attr("href").ok_or(anyhow!("page link not found"))?)? - }; - spawn!(process_gracefully(ilias, path, next_page)); - } - } else { - log!(0, "Warning: unable to find pagination links in {}", url.url); - } - } + ilias::thread::download(&path, relative_path, ilias, url).await?; }, ExerciseHandler { url, .. } => { - create_dir(&path).await?; - let html = ilias.get_html(&url.url).await?; - let mut filenames = HashSet::new(); - for row in html.select(&form_group) { - let link = row.select(&a).next(); - if link.is_none() { - continue; - } - let link = link.unwrap(); - let href = link.value().attr("href"); - if href.is_none() { - continue; - } - let href = href.unwrap(); - let url = URL::from_href(href)?; - let cmd = url.cmd.as_deref().unwrap_or(""); - if cmd != "downloadFile" && cmd != "downloadGlobalFeedbackFile" && cmd != "downloadFeedbackFile" { - continue; - } - // link is definitely just a download link to the exercise or the solution - let name = row.select(&form_name).next().context("link without file name")?.text().collect::().trim().to_owned(); - let item = File { url, name }; - let mut path = path.clone(); - // handle files with the same name - let filename = file_escape(item.name()); - let mut parts = filename.rsplitn(2, '.'); - let extension = parts.next().unwrap_or(&filename); - let name = parts.next().unwrap_or(""); - let mut unique_filename = filename.clone(); - let mut i = 1; - while filenames.contains(&unique_filename) { - i += 1; - if name != "" { - unique_filename = format!("{}{}.{}", name, i, extension); - } else { - unique_filename = format!("{}{}", extension, i); - } - } - filenames.insert(unique_filename.clone()); - path.push(unique_filename); - let ilias = Arc::clone(&ilias); - spawn!(process_gracefully(ilias, path, item)); - } + ilias::exercise::download(&path, ilias, url).await?; }, Weblink { url, .. } => { - if !ilias.opt.force && fs::metadata(&path).await.is_ok() { - log!(2, "Skipping download, link exists already"); - return Ok(()); - } - let head_req_result = ilias.client.head(&url.url).send().await; - let url = match &head_req_result { - Err(e) => { - e.url().context("HEAD request failed")?.as_str() - }, - Ok(head) => head.url().as_str() - }; - if url.starts_with(ILIAS_URL) { - // is a link list - if fs::metadata(&path).await.is_err() { - create_dir(&path).await?; - log!(0, "Writing {}", relative_path.to_string_lossy()); - } - - let urls = { - let html = ilias.get_html(url).await?; - html.select(&a) - .filter_map(|x| x.value().attr("href").map(|y| (y, x.text().collect::()))) - .map(|(x, y)| URL::from_href(x).map(|z| (z, y.trim().to_owned())).context("parsing weblink")) - .collect::>>() - }?; - - for (url, name) in urls { - if url.cmd.as_deref().unwrap_or("") != "callLink" { - continue; - } - - let head = ilias.client.head(url.url.as_str()).send().await.context("HEAD request to web link failed"); - if head.is_err() { - println!("Warning: {:?}", head.err().unwrap()); - continue; - } - let head = head.unwrap(); - let url = head.url().as_str(); - path.push(file_escape(&name)); - write_file_data(&path, &mut url.as_bytes()).await?; - path.pop(); - } - } else { - log!(0, "Writing {}", relative_path.to_string_lossy()); - write_file_data(&path, &mut url.as_bytes()).await.context("failed to save weblink")?; - } + ilias::weblink::download(&path, relative_path, ilias, url).await?; }, Wiki { .. } => { log!(1, "Ignored wiki!"); @@ -563,526 +276,17 @@ fn process(ilias: Arc, mut path: PathBuf, obj: Object) -> impl Future { - log!(1, "Ignored interactive presentation! (visit it yourself, it's probably interesting)"); + log!( + 1, + "Ignored interactive presentation! (visit it yourself, it's probably interesting)" + ); }, Generic { .. } => { log!(1, "Ignored generic {:?}", obj) - } + }, + } + if PROGRESS_BAR_ENABLED.load(Ordering::SeqCst) { + PROGRESS_BAR.inc(1); } Ok(()) -}} - -#[derive(Debug, StructOpt)] -#[structopt(name = env!("CARGO_PKG_NAME"))] -struct Opt { - /// Do not download files - #[structopt(short, long)] - skip_files: bool, - - /// Do not download Opencast videos - #[structopt(short, long)] - no_videos: bool, - - /// Download forum content - #[structopt(short = "t", long)] - forum: bool, - - /// Re-download already present files - #[structopt(short)] - force: bool, - - /// Use content tree (slow but thorough) - #[structopt(long)] - content_tree: bool, - - /// Re-check OpenCast lectures (slow) - #[structopt(long)] - check_videos: bool, - - /// Verbose logging (print objects downloaded) - #[structopt(short, multiple = true, parse(from_occurrences))] - verbose: usize, - - /// Output directory - #[structopt(short, long, parse(from_os_str))] - output: PathBuf, - - /// Parallel download jobs - #[structopt(short, long, default_value = "1")] - jobs: usize, -} - -struct ILIAS { - opt: Opt, - ignore: Gitignore, - // TODO: use these for re-authentication in case of session timeout/invalidation - user: String, - pass: String, - client: Client -} - -impl ILIAS { - async fn login, S2: Into>(opt: Opt, user: S1, pass: S2, ignore: Gitignore) -> Result { - let user = user.into(); - let pass = pass.into(); - let client = Client::builder() - .cookie_store(true) - .user_agent(concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"))) - // timeout is infinite by default - .build()?; - let this = ILIAS { - opt, client, user, pass, ignore - }; - println!("Logging into ILIAS using KIT account.."); - let session_establishment = this.client - .post("https://ilias.studium.kit.edu/Shibboleth.sso/Login") - .form(&json!({ - "sendLogin": "1", - "idp_selection": "https://idp.scc.kit.edu/idp/shibboleth", - "target": "/shib_login.php?target=", - "home_organization_selection": "Mit KIT-Account anmelden" - })) - .send().await?; - let url = session_establishment.url().clone(); - let text = session_establishment.text().await?; - let dom_sso = Html::parse_document(text.as_str()); - let csrf_token = dom_sso.select(&Selector::parse(r#"input[name="csrf_token"]"#).unwrap()).next().context("no csrf token")?; - println!("Logging into Shibboleth.."); - let login_response = this.client - .post(url) - .form(&json!({ - "j_username": &this.user, - "j_password": &this.pass, - "_eventId_proceed": "", - "csrf_token": csrf_token.value().attr("value").ok_or(anyhow!("no csrf token"))?, - })) - .send().await?.text().await?; - let dom = Html::parse_document(&login_response); - /* TODO: OTP - login_soup = BeautifulSoup(login_response.text, 'lxml') - otp_inp = login_soup.find("input", attrs={"name": "j_tokenNumber"}) - if otp_inp: - print("OTP Detected.") - otp = input("OTP token: ") - otp_url = otp_inp.parent.parent.parent['action'] - otp_response = self.post('https://idp.scc.kit.edu'+otp_url, data={'j_tokenNumber':otp, "_eventId_proceed": ""}) - login_soup = BeautifulSoup(otp_response.text, 'lxml') - */ - let saml = Selector::parse(r#"input[name="SAMLResponse"]"#).unwrap(); - let saml = dom.select(&saml).next().context("no SAML response, incorrect password?")?; - let relay_state = Selector::parse(r#"input[name="RelayState"]"#).unwrap(); - let relay_state = dom.select(&relay_state).next().context("no relay state")?; - println!("Logging into ILIAS.."); - this.client - .post("https://ilias.studium.kit.edu/Shibboleth.sso/SAML2/POST") - .form(&json!({ - "SAMLResponse": saml.value().attr("value").ok_or(anyhow!("no SAML value"))?, - "RelayState": relay_state.value().attr("value").ok_or(anyhow!("no RelayState value"))? - })) - .send().await?; - println!("Logged in!"); - Ok(this) - } - - async fn download(&self, url: &str) -> Result { - if self.opt.verbose > 1 { - println!("Downloading {}", url); - } - if url.starts_with("http") || url.starts_with("ilias.studium.kit.edu") { - Ok(self.client.get(url).send().await?) - } else { - Ok(self.client.get(&format!("{}{}", ILIAS_URL, url)).send().await?) - } - } - - async fn get_html(&self, url: &str) -> Result { - let text = self.download(url).await?.text().await?; - let html = Html::parse_document(&text); - if html.select(&alert_danger).next().is_some() { - Err(anyhow!("ILIAS error")) - } else { - Ok(html) - } - } - - async fn get_html_fragment(&self, url: &str) -> Result { - let text = self.download(url).await?.text().await?; - let html = Html::parse_fragment(&text); - if html.select(&alert_danger).next().is_some() { - Err(anyhow!("ILIAS error")) - } else { - Ok(html) - } - } - - fn get_items(html: &Html) -> Vec> { - let container_items = Selector::parse("div.il_ContainerListItem").unwrap(); - let container_item_title = Selector::parse("a.il_ContainerItemTitle").unwrap(); - html.select(&container_items).map(|item| { - item - .select(&container_item_title) - .next() - .map(|link| Object::from_link(item, link)) - .unwrap_or_else(|| Err(anyhow!("can't find link"))) - }).collect() - } - - async fn get_course_content(&self, url: &URL) -> Result>> { - let html = self.get_html(&url.url).await?; - Ok(ILIAS::get_items(&html)) - } - - async fn personal_desktop(&self) -> Result { - let html = self.get_html("https://ilias.studium.kit.edu/ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToSelectedItems").await?; - let items = ILIAS::get_items(&html).into_iter().flat_map(Result::ok).collect(); - Ok(Dashboard { - items - }) - } - - async fn get_course_content_tree(&self, ref_id: &str, cmd_node: &str) -> Result> { - // TODO: this magically does not return sub-folders - // opening the same url in browser does show sub-folders?! - let url = format!( - "{}ilias.php?ref_id={}&cmdClass=ilobjcoursegui&cmd=showRepTree&cmdNode={}&baseClass=ilRepositoryGUI&cmdMode=asynch&exp_cmd=getNodeAsync&node_id=exp_node_rep_exp_{}&exp_cont=il_expl2_jstree_cont_rep_exp&searchterm=", - ILIAS_URL, ref_id, cmd_node, ref_id - ); - let html = self.get_html_fragment(&url).await?; - let mut items = Vec::new(); - for link in html.select(&a) { - let href = link.value().attr("href").unwrap_or(""); - if href == "" { - // disabled course - continue; - } - items.push(Object::from_link(link, link)?); - } - Ok(items) - } -} - -#[derive(Debug)] -struct Dashboard { - items: Vec -} - -#[derive(Debug)] -enum Object { - Course { - name: String, - url: URL - }, - Folder { - name: String, - url: URL - }, - File { - name: String, - url: URL - }, - Forum { - name: String, - url: URL - }, - Thread { - url: URL - }, - Wiki { - name: String, - url: URL - }, - ExerciseHandler { - name: String, - url: URL - }, - Weblink { - name: String, - url: URL - }, - Survey { - name: String, - url: URL - }, - Presentation { - name: String, - url: URL - }, - PluginDispatch { - name: String, - url: URL - }, - Video { - url: URL, - }, - Generic { - name: String, - url: URL - }, -} - -use Object::*; - -impl Object { - fn name(&self) -> &str { - match self { - Course { name, .. } | - Folder { name, .. } | - File { name, .. } | - Forum { name, .. } | - Wiki { name, .. } | - Weblink { name, ..} | - Survey { name, .. } | - Presentation { name, .. } | - ExerciseHandler { name, .. } | - PluginDispatch { name, .. } | - Generic { name, .. } => &name, - Thread { url } => &url.thr_pk.as_ref().unwrap(), - Video { url } => &url.url, - } - } - - fn url(&self) -> &URL { - match self { - Course { url, .. } | - Folder { url, .. } | - File { url, .. } | - Forum { url, .. } | - Thread { url } | - Wiki { url, .. } | - Weblink { url, .. } | - Survey { url, .. } | - Presentation { url, .. } | - ExerciseHandler { url, .. } | - PluginDispatch { url, .. } | - Video { url } | - Generic { url, .. } => &url, - } - } - - fn kind(&self) -> &str { - match self { - Course { .. } => "course", - Folder { .. } => "folder", - File { .. } => "file", - Forum { .. } => "forum", - Thread { .. } => "thread", - Wiki { .. } => "wiki", - Weblink { .. } => "weblink", - Survey { .. } => "survey", - Presentation { .. } => "presentation", - ExerciseHandler { .. } => "exercise handler", - PluginDispatch { .. } => "plugin dispatch", - Video { .. } => "video", - Generic { .. } => "generic", - } - } - - fn is_dir(&self) -> bool { - match self { - Course { .. } | - Folder { .. } | - Forum { .. } | - Thread { .. } | - Wiki { .. } | - ExerciseHandler { .. } | - Presentation { .. } | - PluginDispatch { .. } => true, - File { .. } | - Video { .. } | - Weblink { .. } | - Survey { .. } | - Generic { .. } => false - } - } - - fn from_link(item: ElementRef, link: ElementRef) -> Result { - let mut name = link.text().collect::().replace('/', "-").trim().to_owned(); - let mut url = URL::from_href(link.value().attr("href").context("link missing href")?)?; - - if url.thr_pk.is_some() { - return Ok(Thread { - url - }); - } - - if url.url.starts_with("https://ilias.studium.kit.edu/goto.php") { - let target = url.target.as_deref().unwrap_or("NONE"); - if target.starts_with("wiki_") { - return Ok(Wiki { - name, - url // TODO: insert ref_id here - }); - } - if target.starts_with("root_") { - // magazine link - return Ok(Generic { - name, - url - }); - } - if target.starts_with("crs_") { - let ref_id = url.target.as_ref().unwrap().split('_').nth(1).unwrap(); - url.ref_id = ref_id.to_owned(); - return Ok(Course { - name, - url - }); - } - if target.starts_with("frm_") { - // TODO: extract post link? (this codepath should only be hit when parsing the content tree) - let ref_id = url.target.as_ref().unwrap().split('_').nth(1).unwrap(); - url.ref_id = ref_id.to_owned(); - return Ok(Forum { - name, - url - }); - } - if target.starts_with("lm_") { - // fancy interactive task - return Ok(Presentation { - name, - url - }); - } - if target.starts_with("fold_") { - let ref_id = url.target.as_ref().unwrap().split('_').nth(1).unwrap(); - url.ref_id = ref_id.to_owned(); - return Ok(Folder { - name, - url - }); - } - if target.starts_with("file_") { - if !target.ends_with("download") { - // download page containing metadata - return Ok(Generic { - name, - url - }); - } else { - let item_prop = Selector::parse("span.il_ItemProperty").unwrap(); - let mut item_props = item.select(&item_prop); - let ext = item_props.next().ok_or(anyhow!("cannot find file extension"))?; - let version = item_props.nth(1).ok_or(anyhow!("cannot find 3rd file metadata"))?.text().collect::(); - let version = version.trim(); - if version.starts_with("Version: ") { - name.push_str("_v"); - name.push_str(&version[9..]); - } - return Ok(File { name: format!("{}.{}", name, ext.text().collect::().trim()), url }); - } - } - return Ok(Generic { name, url }); - } - - if url.cmd.as_deref() == Some("showThreads") { - return Ok(Forum { name, url }); - } - - // class name is *sometimes* in CamelCase - Ok(match &*url.baseClass.to_ascii_lowercase() { - "ilexercisehandlergui" => ExerciseHandler { name, url }, - "ililwikihandlergui" => Wiki { name, url }, - "illinkresourcehandlergui" => Weblink { name, url }, - "ilobjsurveygui" => Survey { name, url }, - "illmpresentationgui" => Presentation { name, url }, - "ilrepositorygui" => match url.cmd.as_deref() { - Some("view") | Some("render") => Folder { name, url }, - Some(_) => Generic { name, url }, - None => Course { name, url }, - }, - "ilobjplugindispatchgui" => PluginDispatch { name, url }, - _ => Generic { name, url } - }) - } -} - -#[allow(non_snake_case)] -#[derive(Debug)] -struct URL { - url: String, - baseClass: String, - cmdClass: Option, - cmdNode: Option, - cmd: Option, - forwardCmd: Option, - thr_pk: Option, - pos_pk: Option, - ref_id: String, - target: Option, - file: Option, -} - -#[allow(non_snake_case)] -impl URL { - fn raw(url: String) -> Self { - URL { - url, - baseClass: String::new(), - cmdClass: None, - cmdNode: None, - cmd: None, - forwardCmd: None, - thr_pk: None, - pos_pk: None, - ref_id: String::new(), - target: None, - file: None, - } - } - - fn from_href(href: &str) -> Result { - let url = if !href.starts_with(ILIAS_URL) { - Url::parse(&format!("{}{}", ILIAS_URL, href))? - } else { - Url::parse(href)? - }; - let mut baseClass = String::new(); - let mut cmdClass = None; - let mut cmdNode = None; - let mut cmd = None; - let mut forwardCmd = None; - let mut thr_pk = None; - let mut pos_pk = None; - let mut ref_id = String::new(); - let mut target = None; - let mut file = None; - for (k, v) in url.query_pairs() { - match &*k { - "baseClass" => baseClass = v.into_owned(), - "cmdClass" => cmdClass = Some(v.into_owned()), - "cmdNode" => cmdNode = Some(v.into_owned()), - "cmd" => cmd = Some(v.into_owned()), - "forwardCmd" => forwardCmd = Some(v.into_owned()), - "thr_pk" => thr_pk = Some(v.into_owned()), - "pos_pk" => pos_pk = Some(v.into_owned()), - "ref_id" => ref_id = v.into_owned(), - "target" => target = Some(v.into_owned()), - "file" => file = Some(v.into_owned()), - _ => {} - } - } - Ok(URL { - url: url.into_string(), - baseClass, - cmdClass, - cmdNode, - cmd, - forwardCmd, - thr_pk, - pos_pk, - ref_id, - target, - file, - }) - } -} - -#[cfg(not(target_os = "windows"))] -const INVALID: &'static [char] = &['/', '\\']; -#[cfg(target_os = "windows")] -const INVALID: &'static [char] = &['/', '\\', ':', '<', '>', '"', '|', '?', '*']; - -fn file_escape(s: &str) -> String { - s.replace(INVALID, "-") } diff --git a/src/queue.rs b/src/queue.rs new file mode 100644 index 0000000..de9619a --- /dev/null +++ b/src/queue.rs @@ -0,0 +1,42 @@ +use futures::Future; +use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender}; +use once_cell::sync::{Lazy, OnceCell}; +use tokio::{ + sync::{Semaphore, SemaphorePermit}, + task::{self, JoinHandle}, + time, +}; + +/// Global job queue +static TASKS: OnceCell>> = OnceCell::new(); +static TASKS_RUNNING: Lazy = Lazy::new(|| Semaphore::new(0)); +static REQUEST_TICKETS: Lazy = Lazy::new(|| Semaphore::new(0)); + +pub async fn get_request_ticket() { + REQUEST_TICKETS.acquire().await.unwrap().forget(); +} + +pub async fn get_ticket() -> SemaphorePermit<'static> { + TASKS_RUNNING.acquire().await.unwrap() +} + +pub fn spawn(e: impl Future + Send + 'static) { + TASKS.get().unwrap().unbounded_send(task::spawn(e)).unwrap(); +} + +pub fn set_download_rate(rate: usize) { + task::spawn(async move { + let mut interval = time::interval(time::Duration::from_secs_f64(60.0 / rate as f64)); + loop { + interval.tick().await; + REQUEST_TICKETS.add_permits(1); + } + }); +} + +pub fn set_parallel_jobs(jobs: usize) -> UnboundedReceiver> { + let (tx, rx) = futures_channel::mpsc::unbounded::>(); + TASKS.get_or_init(|| tx.clone()); + TASKS_RUNNING.add_permits(jobs); + rx +} diff --git a/src/util.rs b/src/util.rs index c9c5a00..57a06f4 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,16 +1,43 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + use anyhow::Context; +use bytes::Bytes; +use futures::TryStreamExt; use tokio::fs::File as AsyncFile; use tokio::io::{AsyncRead, BufWriter}; +use tokio_util::io::StreamReader; +use std::io; use std::path::Path; -use super::Result; +use crate::{Result, ILIAS_URL}; -pub async fn write_file_data(path: &Path, data: &mut R) -> Result<()> -where R: AsyncRead + Unpin { - let file = AsyncFile::create(&path).await.context("failed to create file")?; +/// Prepends a doctype and a base URL to the HTML fragment. +pub fn wrap_html(html_fragment: &str) -> String { + format!("\n{}", ILIAS_URL, html_fragment) +} + +pub async fn write_stream_to_file( + path: &Path, + stream: impl futures::Stream> + Unpin, +) -> Result<()> { + let mut reader = StreamReader::new(stream.map_err(|x| io::Error::new(io::ErrorKind::Other, x))); + write_file_data(&path, &mut reader).await?; + Ok(()) +} + +/// Write all data to the specified path. Will overwrite previous file data. +pub async fn write_file_data(path: impl AsRef, data: &mut R) -> Result<()> +where + R: AsyncRead + Unpin, +{ + let file = AsyncFile::create(path.as_ref()) + .await + .context("failed to create file")?; let mut file = BufWriter::new(file); - tokio::io::copy(data, &mut file).await.context("failed to write to file")?; + tokio::io::copy(data, &mut file) + .await + .context("failed to write to file")?; Ok(()) } @@ -23,3 +50,12 @@ pub async fn create_dir(path: &Path) -> Result<()> { } Ok(()) } + +#[cfg(not(target_os = "windows"))] +const INVALID: &[char] = &['/', '\\']; +#[cfg(target_os = "windows")] +const INVALID: &[char] = &['/', '\\', ':', '<', '>', '"', '|', '?', '*']; + +pub fn file_escape(s: &str) -> String { + s.replace(INVALID, "-") +}