From 353ed7fb27044e945387eafbe3250536ead0722d Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Fri, 13 Jan 2023 23:11:55 +0100 Subject: [PATCH] Fix async --- poetry.lock | 131 +++++++++++++++++++++++-------- pynyaata/bridge/animeultime.py | 25 +++--- pynyaata/bridge/nyaa.py | 6 +- pynyaata/bridge/yggtorrent.py | 6 +- pynyaata/cache/__init__.py | 4 +- pynyaata/filters.py | 4 +- pynyaata/types.py | 22 +++--- pyproject.toml | 55 ++++++------- tests/bridge/test_animeultime.py | 28 +++++-- tests/bridge/test_nyaa.py | 8 +- 10 files changed, 186 insertions(+), 103 deletions(-) diff --git a/poetry.lock b/poetry.lock index 9e2f39b..7971d94 100644 --- a/poetry.lock +++ b/poetry.lock @@ -157,19 +157,102 @@ files = [ [[package]] name = "charset-normalizer" -version = "2.1.1" +version = "3.0.1" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." category = "main" optional = false -python-versions = ">=3.6.0" +python-versions = "*" files = [ - {file = "charset-normalizer-2.1.1.tar.gz", hash = "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845"}, - {file = "charset_normalizer-2.1.1-py3-none-any.whl", hash = "sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"}, + {file = "charset-normalizer-3.0.1.tar.gz", hash = "sha256:ebea339af930f8ca5d7a699b921106c6e29c617fe9606fa7baa043c1cdae326f"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:88600c72ef7587fe1708fd242b385b6ed4b8904976d5da0893e31df8b3480cb6"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c75ffc45f25324e68ab238cb4b5c0a38cd1c3d7f1fb1f72b5541de469e2247db"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:db72b07027db150f468fbada4d85b3b2729a3db39178abf5c543b784c1254539"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:62595ab75873d50d57323a91dd03e6966eb79c41fa834b7a1661ed043b2d404d"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ff6f3db31555657f3163b15a6b7c6938d08df7adbfc9dd13d9d19edad678f1e8"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:772b87914ff1152b92a197ef4ea40efe27a378606c39446ded52c8f80f79702e"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:70990b9c51340e4044cfc394a81f614f3f90d41397104d226f21e66de668730d"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:292d5e8ba896bbfd6334b096e34bffb56161c81408d6d036a7dfa6929cff8783"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:2edb64ee7bf1ed524a1da60cdcd2e1f6e2b4f66ef7c077680739f1641f62f555"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:31a9ddf4718d10ae04d9b18801bd776693487cbb57d74cc3458a7673f6f34639"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:44ba614de5361b3e5278e1241fda3dc1838deed864b50a10d7ce92983797fa76"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:12db3b2c533c23ab812c2b25934f60383361f8a376ae272665f8e48b88e8e1c6"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:c512accbd6ff0270939b9ac214b84fb5ada5f0409c44298361b2f5e13f9aed9e"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-win32.whl", hash = "sha256:502218f52498a36d6bf5ea77081844017bf7982cdbe521ad85e64cabee1b608b"}, + {file = "charset_normalizer-3.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:601f36512f9e28f029d9481bdaf8e89e5148ac5d89cffd3b05cd533eeb423b59"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:0298eafff88c99982a4cf66ba2efa1128e4ddaca0b05eec4c456bbc7db691d8d"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a8d0fc946c784ff7f7c3742310cc8a57c5c6dc31631269876a88b809dbeff3d3"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:87701167f2a5c930b403e9756fab1d31d4d4da52856143b609e30a1ce7160f3c"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:14e76c0f23218b8f46c4d87018ca2e441535aed3632ca134b10239dfb6dadd6b"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0c0a590235ccd933d9892c627dec5bc7511ce6ad6c1011fdf5b11363022746c1"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8c7fe7afa480e3e82eed58e0ca89f751cd14d767638e2550c77a92a9e749c317"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:79909e27e8e4fcc9db4addea88aa63f6423ebb171db091fb4373e3312cb6d603"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8ac7b6a045b814cf0c47f3623d21ebd88b3e8cf216a14790b455ea7ff0135d18"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:72966d1b297c741541ca8cf1223ff262a6febe52481af742036a0b296e35fa5a"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:f9d0c5c045a3ca9bedfc35dca8526798eb91a07aa7a2c0fee134c6c6f321cbd7"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:5995f0164fa7df59db4746112fec3f49c461dd6b31b841873443bdb077c13cfc"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4a8fcf28c05c1f6d7e177a9a46a1c52798bfe2ad80681d275b10dcf317deaf0b"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:761e8904c07ad053d285670f36dd94e1b6ab7f16ce62b9805c475b7aa1cffde6"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-win32.whl", hash = "sha256:71140351489970dfe5e60fc621ada3e0f41104a5eddaca47a7acb3c1b851d6d3"}, + {file = "charset_normalizer-3.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:9ab77acb98eba3fd2a85cd160851816bfce6871d944d885febf012713f06659c"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:84c3990934bae40ea69a82034912ffe5a62c60bbf6ec5bc9691419641d7d5c9a"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:74292fc76c905c0ef095fe11e188a32ebd03bc38f3f3e9bcb85e4e6db177b7ea"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c95a03c79bbe30eec3ec2b7f076074f4281526724c8685a42872974ef4d36b72"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f4c39b0e3eac288fedc2b43055cfc2ca7a60362d0e5e87a637beac5d801ef478"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:df2c707231459e8a4028eabcd3cfc827befd635b3ef72eada84ab13b52e1574d"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:93ad6d87ac18e2a90b0fe89df7c65263b9a99a0eb98f0a3d2e079f12a0735837"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:59e5686dd847347e55dffcc191a96622f016bc0ad89105e24c14e0d6305acbc6"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:cd6056167405314a4dc3c173943f11249fa0f1b204f8b51ed4bde1a9cd1834dc"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:083c8d17153ecb403e5e1eb76a7ef4babfc2c48d58899c98fcaa04833e7a2f9a"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:f5057856d21e7586765171eac8b9fc3f7d44ef39425f85dbcccb13b3ebea806c"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:7eb33a30d75562222b64f569c642ff3dc6689e09adda43a082208397f016c39a"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-win32.whl", hash = "sha256:95dea361dd73757c6f1c0a1480ac499952c16ac83f7f5f4f84f0658a01b8ef41"}, + {file = "charset_normalizer-3.0.1-cp36-cp36m-win_amd64.whl", hash = "sha256:eaa379fcd227ca235d04152ca6704c7cb55564116f8bc52545ff357628e10602"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:3e45867f1f2ab0711d60c6c71746ac53537f1684baa699f4f668d4c6f6ce8e14"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cadaeaba78750d58d3cc6ac4d1fd867da6fc73c88156b7a3212a3cd4819d679d"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:911d8a40b2bef5b8bbae2e36a0b103f142ac53557ab421dc16ac4aafee6f53dc"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:503e65837c71b875ecdd733877d852adbc465bd82c768a067badd953bf1bc5a3"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a60332922359f920193b1d4826953c507a877b523b2395ad7bc716ddd386d866"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:16a8663d6e281208d78806dbe14ee9903715361cf81f6d4309944e4d1e59ac5b"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:a16418ecf1329f71df119e8a65f3aa68004a3f9383821edcb20f0702934d8087"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:9d9153257a3f70d5f69edf2325357251ed20f772b12e593f3b3377b5f78e7ef8"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:02a51034802cbf38db3f89c66fb5d2ec57e6fe7ef2f4a44d070a593c3688667b"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:2e396d70bc4ef5325b72b593a72c8979999aa52fb8bcf03f701c1b03e1166918"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:11b53acf2411c3b09e6af37e4b9005cba376c872503c8f28218c7243582df45d"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-win32.whl", hash = "sha256:0bf2dae5291758b6f84cf923bfaa285632816007db0330002fa1de38bfcb7154"}, + {file = "charset_normalizer-3.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:2c03cc56021a4bd59be889c2b9257dae13bf55041a3372d3295416f86b295fb5"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:024e606be3ed92216e2b6952ed859d86b4cfa52cd5bc5f050e7dc28f9b43ec42"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:4b0d02d7102dd0f997580b51edc4cebcf2ab6397a7edf89f1c73b586c614272c"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:358a7c4cb8ba9b46c453b1dd8d9e431452d5249072e4f56cfda3149f6ab1405e"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:81d6741ab457d14fdedc215516665050f3822d3e56508921cc7239f8c8e66a58"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8b8af03d2e37866d023ad0ddea594edefc31e827fee64f8de5611a1dbc373174"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9cf4e8ad252f7c38dd1f676b46514f92dc0ebeb0db5552f5f403509705e24753"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e696f0dd336161fca9adbb846875d40752e6eba585843c768935ba5c9960722b"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c22d3fe05ce11d3671297dc8973267daa0f938b93ec716e12e0f6dee81591dc1"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:109487860ef6a328f3eec66f2bf78b0b72400280d8f8ea05f69c51644ba6521a"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:37f8febc8ec50c14f3ec9637505f28e58d4f66752207ea177c1d67df25da5aed"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:f97e83fa6c25693c7a35de154681fcc257c1c41b38beb0304b9c4d2d9e164479"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:a152f5f33d64a6be73f1d30c9cc82dfc73cec6477ec268e7c6e4c7d23c2d2291"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:39049da0ffb96c8cbb65cbf5c5f3ca3168990adf3551bd1dee10c48fce8ae820"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-win32.whl", hash = "sha256:4457ea6774b5611f4bed5eaa5df55f70abde42364d498c5134b7ef4c6958e20e"}, + {file = "charset_normalizer-3.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:e62164b50f84e20601c1ff8eb55620d2ad25fb81b59e3cd776a1902527a788af"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:8eade758719add78ec36dc13201483f8e9b5d940329285edcd5f70c0a9edbd7f"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:8499ca8f4502af841f68135133d8258f7b32a53a1d594aa98cc52013fff55678"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3fc1c4a2ffd64890aebdb3f97e1278b0cc72579a08ca4de8cd2c04799a3a22be"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:00d3ffdaafe92a5dc603cb9bd5111aaa36dfa187c8285c543be562e61b755f6b"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c2ac1b08635a8cd4e0cbeaf6f5e922085908d48eb05d44c5ae9eabab148512ca"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f6f45710b4459401609ebebdbcfb34515da4fc2aa886f95107f556ac69a9147e"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3ae1de54a77dc0d6d5fcf623290af4266412a7c4be0b1ff7444394f03f5c54e3"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3b590df687e3c5ee0deef9fc8c547d81986d9a1b56073d82de008744452d6541"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ab5de034a886f616a5668aa5d098af2b5385ed70142090e2a31bcbd0af0fdb3d"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9cb3032517f1627cc012dbc80a8ec976ae76d93ea2b5feaa9d2a5b8882597579"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:608862a7bf6957f2333fc54ab4399e405baad0163dc9f8d99cb236816db169d4"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:0f438ae3532723fb6ead77e7c604be7c8374094ef4ee2c5e03a3a17f1fca256c"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:356541bf4381fa35856dafa6a965916e54bed415ad8a24ee6de6e37deccf2786"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-win32.whl", hash = "sha256:39cf9ed17fe3b1bc81f33c9ceb6ce67683ee7526e65fde1447c772afc54a1bb8"}, + {file = "charset_normalizer-3.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:0a11e971ed097d24c534c037d298ad32c6ce81a45736d31e0ff0ad37ab437d59"}, + {file = "charset_normalizer-3.0.1-py3-none-any.whl", hash = "sha256:7e189e2e1d3ed2f4aebabd2d5b0f931e883676e51c7624826e0a4e5fe8a0bf24"}, ] -[package.extras] -unicode-backport = ["unicodedata2"] - [[package]] name = "click" version = "8.1.3" @@ -1098,22 +1181,6 @@ files = [ {file = "pytz-2022.7.tar.gz", hash = "sha256:7ccfae7b4b2c067464a6733c6261673fdb8fd1be905460396b97a073e9fa683a"}, ] -[[package]] -name = "pytz-deprecation-shim" -version = "0.1.0.post0" -description = "Shims to make deprecation of pytz easier" -category = "main" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" -files = [ - {file = "pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl", hash = "sha256:8314c9692a636c8eb3bda879b9f119e350e93223ae83e70e80c31675a0fdc1a6"}, - {file = "pytz_deprecation_shim-0.1.0.post0.tar.gz", hash = "sha256:af097bae1b616dde5c5744441e2ddc69e74dfdcb0c263129610d85b87445a59d"}, -] - -[package.dependencies] -"backports.zoneinfo" = {version = "*", markers = "python_version >= \"3.6\" and python_version < \"3.9\""} -tzdata = {version = "*", markers = "python_version >= \"3.6\""} - [[package]] name = "pyyaml" version = "6.0" @@ -1285,19 +1352,19 @@ files = [ [[package]] name = "requests" -version = "2.28.1" +version = "2.28.2" description = "Python HTTP for Humans." category = "main" optional = false python-versions = ">=3.7, <4" files = [ - {file = "requests-2.28.1-py3-none-any.whl", hash = "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"}, - {file = "requests-2.28.1.tar.gz", hash = "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"}, + {file = "requests-2.28.2-py3-none-any.whl", hash = "sha256:64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa"}, + {file = "requests-2.28.2.tar.gz", hash = "sha256:98b1b2782e3c6c4904938b84c0eb932721069dfdb9134313beff7c83c2df24bf"}, ] [package.dependencies] certifi = ">=2017.4.17" -charset-normalizer = ">=2,<3" +charset-normalizer = ">=2,<4" idna = ">=2.5,<4" urllib3 = ">=1.21.1,<1.27" @@ -1680,23 +1747,21 @@ files = [ [[package]] name = "tzlocal" -version = "4.2" +version = "3.0" description = "tzinfo object for the local timezone" category = "main" optional = false python-versions = ">=3.6" files = [ - {file = "tzlocal-4.2-py3-none-any.whl", hash = "sha256:89885494684c929d9191c57aa27502afc87a579be5cdd3225c77c463ea043745"}, - {file = "tzlocal-4.2.tar.gz", hash = "sha256:ee5842fa3a795f023514ac2d801c4a81d1743bbe642e3940143326b3a00addd7"}, + {file = "tzlocal-3.0-py3-none-any.whl", hash = "sha256:c736f2540713deb5938d789ca7c3fc25391e9a20803f05b60ec64987cf086559"}, + {file = "tzlocal-3.0.tar.gz", hash = "sha256:f4e6e36db50499e0d92f79b67361041f048e2609d166e93456b50746dc4aef12"}, ] [package.dependencies] "backports.zoneinfo" = {version = "*", markers = "python_version < \"3.9\""} -pytz-deprecation-shim = "*" tzdata = {version = "*", markers = "platform_system == \"Windows\""} [package.extras] -devenv = ["black", "pyroma", "pytest-cov", "zest.releaser"] test = ["pytest (>=4.3)", "pytest-mock (>=3.3)"] [[package]] @@ -1771,4 +1836,4 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools" [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "986b9cfc1e566b769ed3eda035cc3b1c25eb7c8b1b278cbe054be801f68d75cf" +content-hash = "d1d1272071ef863a341ea79ed3597dde0c3a09d400f0eeaf830eaa724ae2ba42" diff --git a/pynyaata/bridge/animeultime.py b/pynyaata/bridge/animeultime.py index bd4c6a5..a544be1 100644 --- a/pynyaata/bridge/animeultime.py +++ b/pynyaata/bridge/animeultime.py @@ -7,7 +7,7 @@ from pydantic import HttpUrl, parse_obj_as from pynyaata.cache import cache_data from pynyaata.filters import filter_data -from pynyaata.types import Bridge, Color, RemoteFile, log_async +from pynyaata.types import Bridge, Color, RemoteFile, async_wrap import requests @@ -33,10 +33,10 @@ class AnimeUltime(Bridge): ), ) - @log_async + @async_wrap @cache_data @filter_data - async def search(self, query: str = "", page: int = 1) -> List[RemoteFile]: + def search(self, query: str = "", page: int = 1) -> List[RemoteFile]: response = ( requests.post(self.search_url(query, page), {"search": query}) if query @@ -82,16 +82,17 @@ class AnimeUltime(Bridge): tds = tr.find_all("td") - torrents.append( - RemoteFile( - bridge=self.__class__.__name__, - id=tds[0].a["href"].split("/")[-2], - category=tds[4].get_text(), - name=tds[0].get_text(), - link=f"{self.base_url}/{tds[0].a['href']}", - date=parse(h3s[i].get_text()[:-3], ["%A %d %B %Y"]), + if tds[0].a["href"] != "#": + torrents.append( + RemoteFile( + bridge=self.__class__.__name__, + id=tds[0].a["href"].split("/")[-2], + category=tds[4].get_text(), + name=tds[0].get_text(), + link=f"{self.base_url}/{tds[0].a['href']}", + date=parse(h3s[i].get_text()[:-3], ["%A %d %B %Y"]), + ) ) - ) elif player and title and history and tables: torrents.append( RemoteFile( diff --git a/pynyaata/bridge/nyaa.py b/pynyaata/bridge/nyaa.py index 055dc3e..1a2b031 100644 --- a/pynyaata/bridge/nyaa.py +++ b/pynyaata/bridge/nyaa.py @@ -8,7 +8,7 @@ from pydantic import HttpUrl, parse_obj_as from pynyaata.cache import cache_data from pynyaata.filters import filter_data -from pynyaata.types import Bridge, Color, RemoteFile, log_async +from pynyaata.types import Bridge, Color, RemoteFile, async_wrap import requests @@ -37,10 +37,10 @@ class Nyaa(Bridge): return parse_obj_as(HttpUrl, f"{self.base_url}?{params}") - @log_async + @async_wrap @cache_data @filter_data - async def search(self, query: str = "", page: int = 1) -> List[RemoteFile]: + def search(self, query: str = "", page: int = 1) -> List[RemoteFile]: response = requests.get(self.search_url(query, page)) if response.status_code != 200: diff --git a/pynyaata/bridge/yggtorrent.py b/pynyaata/bridge/yggtorrent.py index ba1643a..00007a8 100644 --- a/pynyaata/bridge/yggtorrent.py +++ b/pynyaata/bridge/yggtorrent.py @@ -7,7 +7,7 @@ from pydantic import HttpUrl, parse_obj_as from pynyaata.cache import cache_data from pynyaata.filters import filter_data -from pynyaata.types import Bridge, Color, RemoteFile, log_async +from pynyaata.types import Bridge, Color, RemoteFile, async_wrap import requests @@ -39,10 +39,10 @@ class YggTorrent(Bridge): return parse_obj_as(HttpUrl, f"{self.base_url}/engine/search?{params}") - @log_async + @async_wrap @cache_data @filter_data - async def search(self, query: str = "", page: int = 1) -> List[RemoteFile]: + def search(self, query: str = "", page: int = 1) -> List[RemoteFile]: search_url = self.search_url(query, page) response = requests.get( f"{self.hidden_url}/{search_url.path}?{search_url.query}", diff --git a/pynyaata/cache/__init__.py b/pynyaata/cache/__init__.py index 07671e8..5fc3343 100644 --- a/pynyaata/cache/__init__.py +++ b/pynyaata/cache/__init__.py @@ -24,14 +24,14 @@ if REDIS_URL: def cache_data(f): @wraps(f) - async def wrapper(bridge: Bridge, query: str = "", page: int = 1): + def wrapper(bridge: Bridge, query: str = "", page: int = 1): key = f"pynyaata.{bridge.__class__.__name__}.{f.__name__}.{query}.{page}" cached = client.get(key) if cached: return cached - reals = await f(bridge, query, page) + reals = f(bridge, query, page) client.set(key, reals) return reals diff --git a/pynyaata/filters.py b/pynyaata/filters.py index 70142df..65d9563 100644 --- a/pynyaata/filters.py +++ b/pynyaata/filters.py @@ -54,8 +54,8 @@ def danger(remotes: List[RemoteFile]) -> List[RemoteFile]: def filter_data(f): @wraps(f) - async def wrapper(*args, **kwargs): - ret = await f(*args, **kwargs) + def wrapper(*args, **kwargs): + ret = f(*args, **kwargs) ret = duplicate(ret) ret = inactive(ret) diff --git a/pynyaata/types.py b/pynyaata/types.py index 52ae5ad..561baf7 100644 --- a/pynyaata/types.py +++ b/pynyaata/types.py @@ -1,8 +1,8 @@ from abc import ABC, abstractmethod +from asyncio import get_event_loop from datetime import datetime from enum import Enum -from functools import wraps -from logging import exception +from functools import partial, wraps from typing import List, Optional from pydantic import BaseModel, ByteSize, HttpUrl @@ -66,13 +66,13 @@ class Cache(ABC): pass -def log_async(f): - @wraps(f) - async def wrapper(*args, **kwargs): - try: - return await f(*args, **kwargs) - except Exception as e: - exception(e) - raise e +def async_wrap(func): + @wraps(func) + async def run(*args, loop=None, executor=None, **kwargs): + if loop is None: + loop = get_event_loop() - return wrapper + pfunc = partial(func, *args, **kwargs) + return await loop.run_in_executor(executor, pfunc) + + return run diff --git a/pyproject.toml b/pyproject.toml index 8e1d13e..bcb6fae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,36 +15,37 @@ pynyaata = 'pynyaata:run' [tool.poetry.dependencies] python = "^3.7" -beautifulsoup4 = "4.11.1" -dateparser = "1.1.6" -flask = "2.2.2" -flask-httpauth = "4.7.0" -flask-sqlalchemy = "3.0.2" -flask-wtf = "1.0.1" -pg8000 = "1.29.4" -pydantic = "1.10.4" -pymysql = "1.0.2" -redis = "4.4.2" -requests = "2.28.1" -sentry-sdk = {extras = ["flask"], version = "1.13.0"} +beautifulsoup4 = "^4.11.1" +dateparser = "^1.1.6" +flask = "^2.2.2" +flask-httpauth = "^4.7.0" +flask-sqlalchemy = "^3.0.2" +flask-wtf = "^1.0.1" +pg8000 = "^1.29.4" +pydantic = "^1.10.4" +pymysql = "^1.0.2" +redis = "^4.4.2" +requests = "^2.28.2" +sentry-sdk = {extras = ["flask"], version = "^1.13.0"} +tzlocal = "^3.0" [tool.poetry.group.dev.dependencies] -black = "22.12.0" -flake8-alphabetize = "0.0.19" -flake8-black = "0.3.6" -mypy = "0.991" -pytest = "7.2.0" -pytest-asyncio = "0.20.3" -requests-mock = "1.10.0" -types-beautifulsoup4 = "4.11.6.2" -types-dateparser = "1.1.4.4" -types-humanfriendly = "10.0.1.3" -types-redis = "4.4.0.0" -types-requests = "2.28.11.7" -djlint = "1.9.3" -flake8 = "3.9.2" -pydantic-factories = "1.15.0" +black = "^22.12.0" +flake8-alphabetize = "^0.0.19" +flake8-black = "^0.3.6" +mypy = "^0.991" +pytest = "^7.2.0" +pytest-asyncio = "^0.20.3" +requests-mock = "^1.10.0" +types-beautifulsoup4 = "^4.11.6.2" +types-dateparser = "^1.1.4.4" +types-humanfriendly = "^10.0.1.3" +types-redis = "^4.4.0.0" +types-requests = "^2.28.11.7" +djlint = "^1.9.3" +flake8 = "^3.9.2" +pydantic-factories = "^1.15.0" [build-system] diff --git a/tests/bridge/test_animeultime.py b/tests/bridge/test_animeultime.py index ab0445f..d7c3b33 100644 --- a/tests/bridge/test_animeultime.py +++ b/tests/bridge/test_animeultime.py @@ -5,6 +5,8 @@ from pynyaata.bridge.animeultime import AnimeUltime from pynyaata.types import RemoteFile from pytest import mark +import requests +from requests_mock import Mocker def test_search_url(): @@ -20,9 +22,7 @@ def test_search_url(): == f"http://www.anime-ultime.net/history-0-1/{previous_month.strftime('%m%Y')}" ) - assert ( - AnimeUltime().search_url("test", 1) == "http://www.anime-ultime.net/search-0-1/" - ) + assert AnimeUltime().search_url("test") == "http://www.anime-ultime.net/search-0-1/" assert ( AnimeUltime().search_url("test", 2) == "http://www.anime-ultime.net/search-0-1/" @@ -31,7 +31,7 @@ def test_search_url(): @mark.asyncio async def test_search(): - remotes = [ + assert await AnimeUltime().search("test") == [ RemoteFile( bridge="AnimeUltime", id=4631, @@ -132,4 +132,22 @@ async def test_search(): ), ] - assert await AnimeUltime().search("test") == remotes + +@mark.asyncio +async def test_history(requests_mock: Mocker): + requests_mock.real_http = True + requests_mock.get( + AnimeUltime().search_url(), + text=requests.get("http://www.anime-ultime.net/history-0-1/042006").text, + ) + + assert await AnimeUltime().search() == [ + RemoteFile( + bridge="AnimeUltime", + id=167, + category="Film", + name="Crayon Shin-chan - Arashi wo Yobu Appare! Sengoku Dai Kassen", + link="http://www.anime-ultime.net/file-0-1/167/Crayon-Shin-chan---Arashi-wo-Yobu-Appare-Sengoku-Dai-Kassen-vostfr", + date="2006-04-10 00:00:00" + ), + ] diff --git a/tests/bridge/test_nyaa.py b/tests/bridge/test_nyaa.py index 5b0f5c7..e5f4887 100644 --- a/tests/bridge/test_nyaa.py +++ b/tests/bridge/test_nyaa.py @@ -30,7 +30,7 @@ def test_search_url(): ) assert ( - Nyaa().search_url("test", 1) + Nyaa().search_url("test") == "https://nyaa.si?f=0&c=1_3&q=%28test+vf%29%7C%28test+vostfr%29%7C%28test+multi%29%7C%28test+fre%29&s=size&o=desc&p=1" ) @@ -50,7 +50,7 @@ def test_search_url(): ) assert ( - EraiRaws().search_url("test", 1) + EraiRaws().search_url("test") == "https://nyaa.si/user/Erai-raws?f=0&c=1_2&q=test+fre&s=size&o=desc&p=1" ) @@ -67,7 +67,7 @@ async def test_search(requests_mock: Mocker): Nyaa().search_url(), text=requests.get("https://nyaa.si/user/Chaussette33").text ) - remotes = [ + assert normalize(await Nyaa().search()) == [ RemoteFile( bridge="Nyaa", id=1080919, @@ -105,5 +105,3 @@ async def test_search(requests_mock: Mocker): nb_pages=1, ), ] - - assert normalize(await Nyaa().search()) == remotes