diff --git a/.dockerignore b/.dockerignore index 8e39412..c0b87a4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,6 @@ .git -.gitignore .github +.gitignore +.gitmodules +.run deploy diff --git a/.run/Dockerfile.run.xml b/.run/BuildAndRun.run.xml similarity index 57% rename from .run/Dockerfile.run.xml rename to .run/BuildAndRun.run.xml index 93b934b..41cc785 100644 --- a/.run/Dockerfile.run.xml +++ b/.run/BuildAndRun.run.xml @@ -1,8 +1,9 @@ - + - diff --git a/Dockerfile b/Dockerfile index e28a7a7..543ad38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,7 +46,8 @@ RUN locale-gen en_US.UTF-8 RUN pip3 install --no-cache-dir /root/sdk/bindings/python/dist/megasdk-*.whl WORKDIR /usr/src/app RUN chmod 777 /usr/src/app -COPY requirements.txt . -RUN pip3 install --no-cache-dir -r requirements.txt +COPY Pipfile . +COPY grt.py . +RUN python3 grt.py && pip3 install --no-cache-dir -r requirements.txt COPY tgmb tgmb CMD ["python3", "-m", "tgmb"] diff --git a/Pipfile b/Pipfile index f1906f3..9261449 100644 --- a/Pipfile +++ b/Pipfile @@ -4,16 +4,16 @@ verify_ssl = true name = "pypi" [packages] -aria2p = "==0.10.4" -google-api-python-client = "==2.7.0" +aria2p = "==0.11.2" +google-api-python-client = "==2.65.0" google-auth-httplib2 = "==0.1.0" -google-auth-oauthlib = "==0.4.4" -psutil = "==5.8.0" -python-magic = "==0.4.24" -python-telegram-bot = "==13.5" -qbittorrent-api = "==2021.8.23" +google-auth-oauthlib = "==0.7.1" +psutil = "==5.9.4" +python-magic = "==0.4.27" +python-telegram-bot = "==13.14" +qbittorrent-api = "==2022.10.39" torrentool = "==1.1.1" -youtube_dl = "==2021.6.6" +youtube_dl = "==2021.12.17" [dev-packages] build = "*" diff --git a/Pipfile.lock b/Pipfile.lock index fd53a80..9c2fbf5 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "e5dedd8bcf433eb3255683698566e49f0913d92f790f21c2556a87fdbb1aa75c" + "sha256": "d32314c1a2bd2874d22c6d06f694eed3b0e72cc8bcbf3b3a0942871cd04a13b2" }, "pipfile-spec": 6, "requires": { @@ -32,11 +32,11 @@ }, "aria2p": { "hashes": [ - "sha256:3cba57e902685f24ead28179984b57710f8f35452026c12390c9469b02413216", - "sha256:df5e0b56768d118d9dbdc103f37cb9dda0cd82e4f9221e061ebf4a2ed375680b" + "sha256:c3c0a87958dacc6b3ad194b5320811baf1e593ddaf83542320d439f6a82f865d", + "sha256:e5a86d0bc306835cd42ff12aa8970a979d4b629966d1d089edbad5992ca47060" ], "index": "pypi", - "version": "==0.10.4" + "version": "==0.11.2" }, "backports.zoneinfo": { "hashes": [ @@ -62,11 +62,11 @@ }, "cachetools": { "hashes": [ - "sha256:89ea6f1b638d5a73a4f9226be57ac5e4f399d22770b92355f92dcb0f7f001693", - "sha256:92971d3cb7d2a97efff7c7bb1657f21a8f5fb309a37530537c71b1774189f2d1" + "sha256:2cc0b89715337ab6dbba85b5b50effe2b0c74e035d83ee8ed637cf52f12ae001", + "sha256:61b5ed1e22a0924aed1d23b478f37e8d52549ff8a961de2909c69bf950020cff" ], "markers": "python_version ~= '3.5'", - "version": "==4.2.4" + "version": "==4.2.2" }, "certifi": { "hashes": [ @@ -86,27 +86,27 @@ }, "google-api-core": { "hashes": [ - "sha256:3b21d4488a898963df91ded12b3125ff0a87ab2af0b658944fad8e9636dd01d8", - "sha256:63c7136f678e83ec72d571b4bd1ea38605866276c3f52746f9dca38367aa0607" + "sha256:10c06f7739fe57781f87523375e8e1a3a4674bf6392cd6131a3222182b971320", + "sha256:34f24bd1d5f72a8c4519773d99ca6bf080a6c4e041b4e9f024fe230191dda62e" ], "markers": "python_version >= '3.7'", - "version": "==1.33.2" + "version": "==2.10.2" }, "google-api-python-client": { "hashes": [ - "sha256:9879b8d1d18212ae92b35bab61e8ea9ed5ea63ef9c8ca847938538da10dd193b", - "sha256:ee59ceea417781d1c68c9ea9b9af41b4bd5a4008ae3008cfc70b2623c3bba76a" + "sha256:2c6611530308b3f931dcf1360713aa3a20cf465d0bf2bac65f2ec99e8c9860de", + "sha256:b8a0ca8454ad57bc65199044717d3d214197ae1e2d666426bbcd4021b36762e0" ], "index": "pypi", - "version": "==2.7.0" + "version": "==2.65.0" }, "google-auth": { "hashes": [ - "sha256:997516b42ecb5b63e8d80f5632c1a61dddf41d2a4c2748057837e06e00014258", - "sha256:b7033be9028c188ee30200b204ea00ed82ea1162e8ac1df4aa6ded19a191d88e" + "sha256:ccaa901f31ad5cbb562615eb8b664b3dd0bf5404a67618e642307f00613eda4d", + "sha256:f5d8701633bebc12e0deea4df8abd8aff31c28b355360597f7f2ee60f2e4d016" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", - "version": "==1.35.0" + "version": "==2.14.1" }, "google-auth-httplib2": { "hashes": [ @@ -118,11 +118,11 @@ }, "google-auth-oauthlib": { "hashes": [ - "sha256:09832c6e75032f93818edf1affe4746121d640c625a5bef9b5c96af676e98eee", - "sha256:0e92aacacfb94978de3b7972cf4b0f204c3cd206f74ddd0dc0b31e91164e6317" + "sha256:860e54c4b58b2664116c9cb44325bc0ec92bcd93e8211698ceea911b1b873b86", + "sha256:9940f543f77d1447432a93781d7c931fb53e418023351ad4bf9e92837a1154ec" ], "index": "pypi", - "version": "==0.4.4" + "version": "==0.7.1" }, "googleapis-common-protos": { "hashes": [ @@ -174,65 +174,43 @@ }, "protobuf": { "hashes": [ - "sha256:03038ac1cfbc41aa21f6afcbcd357281d7521b4157926f30ebecc8d4ea59dcb7", - "sha256:28545383d61f55b57cf4df63eebd9827754fd2dc25f80c5253f9184235db242c", - "sha256:2e3427429c9cffebf259491be0af70189607f365c2f41c7c3764af6f337105f2", - "sha256:398a9e0c3eaceb34ec1aee71894ca3299605fa8e761544934378bbc6c97de23b", - "sha256:44246bab5dd4b7fbd3c0c80b6f16686808fab0e4aca819ade6e8d294a29c7050", - "sha256:447d43819997825d4e71bf5769d869b968ce96848b6479397e29fc24c4a5dfe9", - "sha256:67a3598f0a2dcbc58d02dd1928544e7d88f764b47d4a286202913f0b2801c2e7", - "sha256:74480f79a023f90dc6e18febbf7b8bac7508420f2006fabd512013c0c238f454", - "sha256:819559cafa1a373b7096a482b504ae8a857c89593cf3a25af743ac9ecbd23480", - "sha256:899dc660cd599d7352d6f10d83c95df430a38b410c1b66b407a6b29265d66469", - "sha256:8c0c984a1b8fef4086329ff8dd19ac77576b384079247c770f29cc8ce3afa06c", - "sha256:9aae4406ea63d825636cc11ffb34ad3379335803216ee3a856787bcf5ccc751e", - "sha256:a7ca6d488aa8ff7f329d4c545b2dbad8ac31464f1d8b1c87ad1346717731e4db", - "sha256:b6cc7ba72a8850621bfec987cb72623e703b7fe2b9127a161ce61e61558ad905", - "sha256:bf01b5720be110540be4286e791db73f84a2b721072a3711efff6c324cdf074b", - "sha256:c02ce36ec760252242a33967d51c289fd0e1c0e6e5cc9397e2279177716add86", - "sha256:d9e4432ff660d67d775c66ac42a67cf2453c27cb4d738fc22cb53b5d84c135d4", - "sha256:daa564862dd0d39c00f8086f88700fdbe8bc717e993a21e90711acfed02f2402", - "sha256:de78575669dddf6099a8a0f46a27e82a1783c557ccc38ee620ed8cc96d3be7d7", - "sha256:e64857f395505ebf3d2569935506ae0dfc4a15cb80dc25261176c784662cdcc4", - "sha256:f4bd856d702e5b0d96a00ec6b307b0f51c1982c2bf9c0052cf9019e9a544ba99", - "sha256:f4c42102bc82a51108e449cbb32b19b180022941c727bac0cfd50170341f16ee" + "sha256:2c9c2ed7466ad565f18668aa4731c535511c5d9a40c6da39524bccf43e441719", + "sha256:48e2cd6b88c6ed3d5877a3ea40df79d08374088e89bedc32557348848dff250b", + "sha256:5b0834e61fb38f34ba8840d7dcb2e5a2f03de0c714e0293b3963b79db26de8ce", + "sha256:61f21493d96d2a77f9ca84fefa105872550ab5ef71d21c458eb80edcf4885a99", + "sha256:6e0be9f09bf9b6cf497b27425487706fa48c6d1632ddd94dab1a5fe11a422392", + "sha256:6e312e280fbe3c74ea9e080d9e6080b636798b5e3939242298b591064470b06b", + "sha256:7eb8f2cc41a34e9c956c256e3ac766cf4e1a4c9c925dc757a41a01be3e852965", + "sha256:84ea107016244dfc1eecae7684f7ce13c788b9a644cd3fca5b77871366556444", + "sha256:9227c14010acd9ae7702d6467b4625b6fe853175a6b150e539b21d2b2f2b409c", + "sha256:a419cc95fca8694804709b8c4f2326266d29659b126a93befe210f5bbc772536", + "sha256:a7d0ea43949d45b836234f4ebb5ba0b22e7432d065394b532cdca8f98415e3cf", + "sha256:b5ab0b8918c136345ff045d4b3d5f719b505b7c8af45092d7f45e304f55e50a1", + "sha256:e575c57dc8b5b2b2caa436c16d44ef6981f2235eb7179bfc847557886376d740", + "sha256:f9eae277dd240ae19bb06ff4e2346e771252b0e619421965504bd1b1bba7c5fa" ], "markers": "python_version >= '3.7'", - "version": "==3.20.3" + "version": "==4.21.9" }, "psutil": { "hashes": [ - "sha256:0066a82f7b1b37d334e68697faba68e5ad5e858279fd6351c8ca6024e8d6ba64", - "sha256:02b8292609b1f7fcb34173b25e48d0da8667bc85f81d7476584d889c6e0f2131", - "sha256:0ae6f386d8d297177fd288be6e8d1afc05966878704dad9847719650e44fc49c", - "sha256:0c9ccb99ab76025f2f0bbecf341d4656e9c1351db8cc8a03ccd62e318ab4b5c6", - "sha256:0dd4465a039d343925cdc29023bb6960ccf4e74a65ad53e768403746a9207023", - "sha256:12d844996d6c2b1d3881cfa6fa201fd635971869a9da945cf6756105af73d2df", - "sha256:1bff0d07e76114ec24ee32e7f7f8d0c4b0514b3fae93e3d2aaafd65d22502394", - "sha256:245b5509968ac0bd179287d91210cd3f37add77dad385ef238b275bad35fa1c4", - "sha256:28ff7c95293ae74bf1ca1a79e8805fcde005c18a122ca983abf676ea3466362b", - "sha256:36b3b6c9e2a34b7d7fbae330a85bf72c30b1c827a4366a07443fc4b6270449e2", - "sha256:52de075468cd394ac98c66f9ca33b2f54ae1d9bff1ef6b67a212ee8f639ec06d", - "sha256:5da29e394bdedd9144c7331192e20c1f79283fb03b06e6abd3a8ae45ffecee65", - "sha256:61f05864b42fedc0771d6d8e49c35f07efd209ade09a5afe6a5059e7bb7bf83d", - "sha256:6223d07a1ae93f86451d0198a0c361032c4c93ebd4bf6d25e2fb3edfad9571ef", - "sha256:6323d5d845c2785efb20aded4726636546b26d3b577aded22492908f7c1bdda7", - "sha256:6ffe81843131ee0ffa02c317186ed1e759a145267d54fdef1bc4ea5f5931ab60", - "sha256:74f2d0be88db96ada78756cb3a3e1b107ce8ab79f65aa885f76d7664e56928f6", - "sha256:74fb2557d1430fff18ff0d72613c5ca30c45cdbfcddd6a5773e9fc1fe9364be8", - "sha256:90d4091c2d30ddd0a03e0b97e6a33a48628469b99585e2ad6bf21f17423b112b", - "sha256:90f31c34d25b1b3ed6c40cdd34ff122b1887a825297c017e4cbd6796dd8b672d", - "sha256:99de3e8739258b3c3e8669cb9757c9a861b2a25ad0955f8e53ac662d66de61ac", - "sha256:c6a5fd10ce6b6344e616cf01cc5b849fa8103fbb5ba507b6b2dee4c11e84c935", - "sha256:ce8b867423291cb65cfc6d9c4955ee9bfc1e21fe03bb50e177f2b957f1c2469d", - "sha256:d225cd8319aa1d3c85bf195c4e07d17d3cd68636b8fc97e6cf198f782f99af28", - "sha256:ea313bb02e5e25224e518e4352af4bf5e062755160f77e4b1767dd5ccb65f876", - "sha256:ea372bcc129394485824ae3e3ddabe67dc0b118d262c568b4d2602a7070afdb0", - "sha256:f4634b033faf0d968bb9220dd1c793b897ab7f1189956e1aa9eae752527127d3", - "sha256:fcc01e900c1d7bee2a37e5d6e4f9194760a93597c97fee89c4ae51701de03563" + "sha256:149555f59a69b33f056ba1c4eb22bb7bf24332ce631c44a319cec09f876aaeff", + "sha256:16653106f3b59386ffe10e0bad3bb6299e169d5327d3f187614b1cb8f24cf2e1", + "sha256:3d7f9739eb435d4b1338944abe23f49584bde5395f27487d2ee25ad9a8774a62", + "sha256:3ff89f9b835100a825b14c2808a106b6fdcc4b15483141482a12c725e7f78549", + "sha256:54c0d3d8e0078b7666984e11b12b88af2db11d11249a8ac8920dd5ef68a66e08", + "sha256:54d5b184728298f2ca8567bf83c422b706200bcbbfafdc06718264f9393cfeb7", + "sha256:6001c809253a29599bc0dfd5179d9f8a5779f9dffea1da0f13c53ee568115e1e", + "sha256:68908971daf802203f3d37e78d3f8831b6d1014864d7a85937941bb35f09aefe", + "sha256:6b92c532979bafc2df23ddc785ed116fced1f492ad90a6830cf24f4d1ea27d24", + "sha256:852dd5d9f8a47169fe62fd4a971aa07859476c2ba22c2254d4a1baa4e10b95ad", + "sha256:9120cd39dca5c5e1c54b59a41d205023d436799b1c8c4d3ff71af18535728e94", + "sha256:c1ca331af862803a42677c120aff8a814a804e09832f166f226bfd22b56feee8", + "sha256:efeae04f9516907be44904cc7ce08defb6b665128992a56957abc9b61dca94b7", + "sha256:fd8522436a6ada7b4aad6638662966de0d61d241cb821239b2ae7013d41a43d4" ], "index": "pypi", - "version": "==5.8.0" + "version": "==5.9.4" }, "pyasn1": { "hashes": [ @@ -280,19 +258,19 @@ }, "python-magic": { "hashes": [ - "sha256:4fec8ee805fea30c07afccd1592c0f17977089895bdfaae5fec870a84e997626", - "sha256:de800df9fb50f8ec5974761054a708af6e4246b03b4bdaee993f948947b0ebcf" + "sha256:c1ba14b08e4a5f5c31a302b7721239695b2f0f058d125bd5ce1ee36b9d9d3c3b", + "sha256:c212960ad306f700aa0d01e5d7a325d20548ff97eb9920dcd29513174f0294d3" ], "index": "pypi", - "version": "==0.4.24" + "version": "==0.4.27" }, "python-telegram-bot": { "hashes": [ - "sha256:3f2887317ab045fc65d3c2905a66fd2c5dafcaa96af36700ac8cfaa5a51fd3ee", - "sha256:83dbf4cd46327fd818bb6655f2508024a0ade68ebdb3544da35c469adc23bddb" + "sha256:79abc66355af2310bbaaf7f41746230b996434e287f21f27070c92978dc0964f", + "sha256:e9391d43eb1123de2677a9d24ea878a9d5327d65b2419afba653f476d26aecc3" ], "index": "pypi", - "version": "==13.5" + "version": "==13.14" }, "pytz": { "hashes": [ @@ -311,11 +289,11 @@ }, "qbittorrent-api": { "hashes": [ - "sha256:470f9deb539853f952707372ad840306c88b65c4ae761a7566500018e863fc94", - "sha256:596ad4ee47e0a9f2be8af17fba62caf2ee666b41f256b26155aca0487e10df11" + "sha256:0e0728cbc9fc0c97668379d5261ed5e807829274ee982d446120d4a843e88b11", + "sha256:e2f3d7f857a047a47160c61b1e664843d0cd14a82184679d371e2ac7b46faaad" ], "index": "pypi", - "version": "==2021.8.23" + "version": "==2022.10.39" }, "requests": { "hashes": [ @@ -367,20 +345,50 @@ }, "tornado": { "hashes": [ - "sha256:1d54d13ab8414ed44de07efecb97d4ef7c39f7438cf5e976ccd356bebb1b5fca", - "sha256:20f638fd8cc85f3cbae3c732326e96addff0a15e22d80f049e00121651e82e72", - "sha256:5c87076709343557ef8032934ce5f637dbb552efa7b21d08e89ae7619ed0eb23", - "sha256:5f8c52d219d4995388119af7ccaa0bcec289535747620116a58d830e7c25d8a8", - "sha256:6fdfabffd8dfcb6cf887428849d30cf19a3ea34c2c248461e1f7d718ad30b66b", - "sha256:87dcafae3e884462f90c90ecc200defe5e580a7fbbb4365eda7c7c1eb809ebc9", - "sha256:9b630419bde84ec666bfd7ea0a4cb2a8a651c2d5cccdbdd1972a0c859dfc3c13", - "sha256:b8150f721c101abdef99073bf66d3903e292d851bee51910839831caba341a75", - "sha256:ba09ef14ca9893954244fd872798b4ccb2367c165946ce2dd7376aebdde8e3ac", - "sha256:d3a2f5999215a3a06a4fc218026cd84c61b8b2b40ac5296a6db1f1451ef04c1e", - "sha256:e5f923aa6a47e133d1cf87d60700889d7eae68988704e20c75fb2d65677a8e4b" + "sha256:0a00ff4561e2929a2c37ce706cb8233b7907e0cdc22eab98888aca5dd3775feb", + "sha256:0d321a39c36e5f2c4ff12b4ed58d41390460f798422c4504e09eb5678e09998c", + "sha256:1e8225a1070cd8eec59a996c43229fe8f95689cb16e552d130b9793cb570a288", + "sha256:20241b3cb4f425e971cb0a8e4ffc9b0a861530ae3c52f2b0434e6c1b57e9fd95", + "sha256:25ad220258349a12ae87ede08a7b04aca51237721f63b1808d39bdb4b2164558", + "sha256:33892118b165401f291070100d6d09359ca74addda679b60390b09f8ef325ffe", + "sha256:33c6e81d7bd55b468d2e793517c909b139960b6c790a60b7991b9b6b76fb9791", + "sha256:3447475585bae2e77ecb832fc0300c3695516a47d46cefa0528181a34c5b9d3d", + "sha256:34ca2dac9e4d7afb0bed4677512e36a52f09caa6fded70b4e3e1c89dbd92c326", + "sha256:3e63498f680547ed24d2c71e6497f24bca791aca2fe116dbc2bd0ac7f191691b", + "sha256:548430be2740e327b3fe0201abe471f314741efcb0067ec4f2d7dcfb4825f3e4", + "sha256:6196a5c39286cc37c024cd78834fb9345e464525d8991c21e908cc046d1cc02c", + "sha256:61b32d06ae8a036a6607805e6720ef00a3c98207038444ba7fd3d169cd998910", + "sha256:6286efab1ed6e74b7028327365cf7346b1d777d63ab30e21a0f4d5b275fc17d5", + "sha256:65d98939f1a2e74b58839f8c4dab3b6b3c1ce84972ae712be02845e65391ac7c", + "sha256:66324e4e1beede9ac79e60f88de548da58b1f8ab4b2f1354d8375774f997e6c0", + "sha256:6c77c9937962577a6a76917845d06af6ab9197702a42e1346d8ae2e76b5e3675", + "sha256:70dec29e8ac485dbf57481baee40781c63e381bebea080991893cd297742b8fd", + "sha256:7250a3fa399f08ec9cb3f7b1b987955d17e044f1ade821b32e5f435130250d7f", + "sha256:748290bf9112b581c525e6e6d3820621ff020ed95af6f17fedef416b27ed564c", + "sha256:7da13da6f985aab7f6f28debab00c67ff9cbacd588e8477034c0652ac141feea", + "sha256:8f959b26f2634a091bb42241c3ed8d3cedb506e7c27b8dd5c7b9f745318ddbb6", + "sha256:9de9e5188a782be6b1ce866e8a51bc76a0fbaa0e16613823fc38e4fc2556ad05", + "sha256:a48900ecea1cbb71b8c71c620dee15b62f85f7c14189bdeee54966fbd9a0c5bd", + "sha256:b87936fd2c317b6ee08a5741ea06b9d11a6074ef4cc42e031bc6403f82a32575", + "sha256:c77da1263aa361938476f04c4b6c8916001b90b2c2fdd92d8d535e1af48fba5a", + "sha256:cb5ec8eead331e3bb4ce8066cf06d2dfef1bfb1b2a73082dfe8a161301b76e37", + "sha256:cc0ee35043162abbf717b7df924597ade8e5395e7b66d18270116f8745ceb795", + "sha256:d14d30e7f46a0476efb0deb5b61343b1526f73ebb5ed84f23dc794bdb88f9d9f", + "sha256:d371e811d6b156d82aa5f9a4e08b58debf97c302a35714f6f45e35139c332e32", + "sha256:d3d20ea5782ba63ed13bc2b8c291a053c8d807a8fa927d941bd718468f7b950c", + "sha256:d3f7594930c423fd9f5d1a76bee85a2c36fd8b4b16921cae7e965f22575e9c01", + "sha256:dcef026f608f678c118779cd6591c8af6e9b4155c44e0d1bc0c87c036fb8c8c4", + "sha256:e0791ac58d91ac58f694d8d2957884df8e4e2f6687cdf367ef7eb7497f79eaa2", + "sha256:e385b637ac3acaae8022e7e47dfa7b83d3620e432e3ecb9a3f7f58f150e50921", + "sha256:e519d64089b0876c7b467274468709dadf11e41d65f63bba207e04217f47c085", + "sha256:e7229e60ac41a1202444497ddde70a48d33909e484f96eb0da9baf8dc68541df", + "sha256:ed3ad863b1b40cd1d4bd21e7498329ccaece75db5a5bf58cd3c9f130843e7102", + "sha256:f0ba29bafd8e7e22920567ce0d232c26d4d47c8b5cf4ed7b562b5db39fa199c5", + "sha256:fa2ba70284fa42c2a5ecb35e322e68823288a4251f9ba9cc77be04ae15eada68", + "sha256:fba85b6cd9c39be262fcd23865652920832b61583de2a2ca907dbd8e8a8c81e5" ], - "markers": "python_version >= '3.7'", - "version": "==6.2" + "markers": "python_version >= '3.5'", + "version": "==6.1" }, "torrentool": { "hashes": [ @@ -408,11 +416,11 @@ }, "uritemplate": { "hashes": [ - "sha256:07620c3f3f8eed1f12600845892b0e036a2420acf513c53f7de0abd911a5894f", - "sha256:5af8ad10cec94f215e3f48112de2022e1d5a37ed427fbd88652fa908f2ab7cae" + "sha256:4346edfc5c3b79f694bccd6d6099a322bbeb628dbf2cd86eea55a456ce5124f0", + "sha256:830c08b8d99bdd312ea4ead05994a38e8936266f84b9a7878232db50b044e02e" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==3.0.1" + "markers": "python_version >= '3.6'", + "version": "==4.1.1" }, "urllib3": { "hashes": [ @@ -432,11 +440,11 @@ }, "youtube-dl": { "hashes": [ - "sha256:263e04d53fb8ba3dfbd246ad09b7d388e896c132a20cc770c26ee7684de050ac", - "sha256:cb2d3ee002158ede783e97a82c95f3817594df54367ea6a77ce5ceea4772f0ab" + "sha256:bc59e86c5d15d887ac590454511f08ce2c47698d5a82c27bfe27b5d814bbaed2", + "sha256:f1336d5de68647e0364a47b3c0712578e59ec76f02048ff5c50ef1c69d79cd55" ], "index": "pypi", - "version": "==2021.6.6" + "version": "==2021.12.17" } }, "develop": { diff --git a/grt.py b/grt.py new file mode 100644 index 0000000..f6e3322 --- /dev/null +++ b/grt.py @@ -0,0 +1,12 @@ +import re + +if __name__ == '__main__': + fPipfile = 'Pipfile' + fRequirements = 'requirements.txt' + with open(fPipfile, 'rt') as fP: + pipfileContents = fP.read() + rSearch = r"\[packages\]\n[a-zA-Z0-9 =._\-\"\n]*" + sSearch: list[str] = re.findall(rSearch, pipfileContents) + requirementsContents = sSearch[0].replace(' = "', '').replace('"\n', '\n').replace('[packages]\n', '') + with open(fRequirements, 'wt') as fR: + fR.write(requirementsContents) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index cd60c1a..0000000 --- a/requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -aria2p==0.10.4 -google-api-python-client==2.7.0 -google-auth-httplib2==0.1.0 -google-auth-oauthlib==0.4.4 -psutil==5.8.0 -python-magic==0.4.24 -python-telegram-bot==13.5 -qbittorrent-api==2021.8.23 -torrentool==1.1.1 -youtube_dl==2021.6.6 diff --git a/tgmb/__init__.py b/tgmb/__init__.py index 0e74775..701eb37 100644 --- a/tgmb/__init__.py +++ b/tgmb/__init__.py @@ -7,6 +7,7 @@ # TODO: decide between confDefaults and optVals for AriaHelper, QbitTorrentHelper import aria2p import asyncio +import enum import googleapiclient.discovery import googleapiclient.errors import googleapiclient.http @@ -733,30 +734,32 @@ def onCancelMirror(self, mirrorInfo: 'MirrorInfo') -> None: if mirrorInfo.previousStatus in [ MirrorStatus.downloadProgress ]: - if mirrorInfo.isAriaDownload: - self.botHelper.ariaHelper.cancelDownload(mirrorInfo) - if mirrorInfo.isGoogleDriveDownload: - self.botHelper.googleDriveHelper.cancelDownload(mirrorInfo) - if mirrorInfo.isMegaDownload: - self.botHelper.megaHelper.cancelDownload(mirrorInfo) - if mirrorInfo.isQbitTorrentDownload: - self.botHelper.qbitTorrentHelper.cancelDownload(mirrorInfo) - if mirrorInfo.isTelegramDownload: - self.botHelper.telegramHelper.cancelDownload(mirrorInfo) - if mirrorInfo.isYouTubeDownload: - self.botHelper.youTubeHelper.cancelDownload(mirrorInfo) + match mirrorInfo.downloadType: + case DownloadType.Aria: + self.botHelper.ariaHelper.cancelDownload(mirrorInfo) + case DownloadType.GoogleDrive: + self.botHelper.googleDriveHelper.cancelDownload(mirrorInfo) + case DownloadType.Mega: + self.botHelper.megaHelper.cancelDownload(mirrorInfo) + case DownloadType.QbitTorrent: + self.botHelper.qbitTorrentHelper.cancelDownload(mirrorInfo) + case DownloadType.Telegram: + self.botHelper.telegramHelper.cancelDownload(mirrorInfo) + case DownloadType.YouTube: + self.botHelper.youTubeHelper.cancelDownload(mirrorInfo) self.downloadQueue.remove(mirrorInfo.uid) self.downloadQueueActive -= 1 self.checkDownloadQueue() if mirrorInfo.previousStatus in [ MirrorStatus.uploadProgress ]: - if mirrorInfo.isGoogleDriveUpload: - self.botHelper.googleDriveHelper.cancelUpload(mirrorInfo) - if mirrorInfo.isMegaUpload: - self.botHelper.megaHelper.cancelUpload(mirrorInfo) - if mirrorInfo.isTelegramUpload: - self.botHelper.telegramHelper.cancelUpload(mirrorInfo) + match mirrorInfo.uploadType: + case UploadType.GoogleDrive: + self.botHelper.googleDriveHelper.cancelUpload(mirrorInfo) + case UploadType.Mega: + self.botHelper.megaHelper.cancelUpload(mirrorInfo) + case UploadType.Telegram: + self.botHelper.telegramHelper.cancelUpload(mirrorInfo) self.uploadQueue.remove(mirrorInfo.uid) self.uploadQueueActive -= 1 self.checkUploadQueue() @@ -802,7 +805,7 @@ def onCancelMirror(self, mirrorInfo: 'MirrorInfo') -> None: def onCompleteMirror(self, mirrorInfo: 'MirrorInfo') -> None: shutil.rmtree(mirrorInfo.path) self.botHelper.mirrorHelper.mirrorInfos.pop(mirrorInfo.uid) - if mirrorInfo.isGoogleDriveUpload or mirrorInfo.isMegaUpload: + if mirrorInfo.uploadType != UploadType.Telegram: self.botHelper.bot.sendMessage(text=f'Uploaded: [{mirrorInfo.uid}] [{mirrorInfo.uploadUrl}]', parse_mode='HTML', chat_id=mirrorInfo.chatId, reply_to_message_id=mirrorInfo.msgId) @@ -822,24 +825,25 @@ def removeDownloadQueue(self, uid: str) -> None: def onDownloadStart(self, mirrorInfo: 'MirrorInfo') -> None: os.mkdir(mirrorInfo.path) - if mirrorInfo.isAriaDownload: - self.botHelper.threadingHelper.initThread(target=self.botHelper.ariaHelper.addDownload, - name=f'{mirrorInfo.uid}-AriaDownload', mirrorInfo=mirrorInfo) - if mirrorInfo.isGoogleDriveDownload: - self.botHelper.threadingHelper.initThread(target=self.botHelper.googleDriveHelper.addDownload, - name=f'{mirrorInfo.uid}-GoogleDriveDownload', mirrorInfo=mirrorInfo) - if mirrorInfo.isMegaDownload: - self.botHelper.threadingHelper.initThread(target=self.botHelper.megaHelper.addDownload, - name=f'{mirrorInfo.uid}-MegaDownload', mirrorInfo=mirrorInfo) - if mirrorInfo.isQbitTorrentDownload: - self.botHelper.threadingHelper.initThread(target=self.botHelper.qbitTorrentHelper.addDownload, - name=f'{mirrorInfo.uid}-QbitTorrentDownload', mirrorInfo=mirrorInfo) - if mirrorInfo.isTelegramDownload: - self.botHelper.threadingHelper.initThread(target=self.botHelper.telegramHelper.addDownload, - name=f'{mirrorInfo.uid}-TelegramDownload', mirrorInfo=mirrorInfo) - if mirrorInfo.isYouTubeDownload: - self.botHelper.threadingHelper.initThread(target=self.botHelper.youTubeHelper.addDownload, - name=f'{mirrorInfo.uid}-YouTubeDownload', mirrorInfo=mirrorInfo) + match mirrorInfo.downloadType: + case DownloadType.Aria: + self.botHelper.threadingHelper.initThread(target=self.botHelper.ariaHelper.addDownload, + name=f'{mirrorInfo.uid}-AriaDownload', mirrorInfo=mirrorInfo) + case DownloadType.GoogleDrive: + self.botHelper.threadingHelper.initThread(target=self.botHelper.googleDriveHelper.addDownload, + name=f'{mirrorInfo.uid}-GoogleDriveDownload', mirrorInfo=mirrorInfo) + case DownloadType.Mega: + self.botHelper.threadingHelper.initThread(target=self.botHelper.megaHelper.addDownload, + name=f'{mirrorInfo.uid}-MegaDownload', mirrorInfo=mirrorInfo) + case DownloadType.QbitTorrent: + self.botHelper.threadingHelper.initThread(target=self.botHelper.qbitTorrentHelper.addDownload, + name=f'{mirrorInfo.uid}-QbitTorrentDownload', mirrorInfo=mirrorInfo) + case DownloadType.Telegram: + self.botHelper.threadingHelper.initThread(target=self.botHelper.telegramHelper.addDownload, + name=f'{mirrorInfo.uid}-TelegramDownload', mirrorInfo=mirrorInfo) + case DownloadType.YouTube: + self.botHelper.threadingHelper.initThread(target=self.botHelper.youTubeHelper.addDownload, + name=f'{mirrorInfo.uid}-YouTubeDownload', mirrorInfo=mirrorInfo) self.updateStatus(mirrorInfo.uid, MirrorStatus.downloadProgress) def onDownloadProgress(self, mirrorInfo: 'MirrorInfo') -> None: @@ -953,15 +957,16 @@ def removeUploadQueue(self, uid: str) -> None: self.checkUploadQueue() def onUploadStart(self, mirrorInfo: 'MirrorInfo') -> None: - if mirrorInfo.isGoogleDriveUpload: - self.botHelper.threadingHelper.initThread(target=self.botHelper.googleDriveHelper.addUpload, - name=f'{mirrorInfo.uid}-GoogleDriveUpload', mirrorInfo=mirrorInfo) - if mirrorInfo.isMegaUpload: - self.botHelper.threadingHelper.initThread(target=self.botHelper.megaHelper.addUpload, - name=f'{mirrorInfo.uid}-MegaUpload', mirrorInfo=mirrorInfo) - if mirrorInfo.isTelegramUpload: - self.botHelper.threadingHelper.initThread(target=self.botHelper.telegramHelper.addUpload, - name=f'{mirrorInfo.uid}-TelegramUpload', mirrorInfo=mirrorInfo) + match mirrorInfo.uploadType: + case UploadType.GoogleDrive: + self.botHelper.threadingHelper.initThread(target=self.botHelper.googleDriveHelper.addUpload, + name=f'{mirrorInfo.uid}-GoogleDriveUpload', mirrorInfo=mirrorInfo) + case UploadType.Mega: + self.botHelper.threadingHelper.initThread(target=self.botHelper.megaHelper.addUpload, + name=f'{mirrorInfo.uid}-MegaUpload', mirrorInfo=mirrorInfo) + case UploadType.Telegram: + self.botHelper.threadingHelper.initThread(target=self.botHelper.telegramHelper.addUpload, + name=f'{mirrorInfo.uid}-TelegramUpload', mirrorInfo=mirrorInfo) self.updateStatus(mirrorInfo.uid, MirrorStatus.uploadProgress) def onUploadProgress(self, mirrorInfo: 'MirrorInfo') -> None: @@ -1102,22 +1107,21 @@ def cancelMirror(self, msg: telegram.Message) -> None: def genMirrorInfo(self, msg: telegram.Message) -> (bool, 'MirrorInfo'): mirrorInfo = MirrorInfo(msg, self.botHelper) - isValidDl: bool = True try: mirrorInfo.downloadUrl = msg.text.split(' ')[1].strip() mirrorInfo.tag = msg.from_user.username if re.findall(UrlRegex.googleDrive, mirrorInfo.downloadUrl): - mirrorInfo.isGoogleDriveDownload = True + mirrorInfo.downloadType = DownloadType.GoogleDrive elif re.findall(UrlRegex.mega, mirrorInfo.downloadUrl): - mirrorInfo.isMegaDownload = True + mirrorInfo.downloadType = DownloadType.Mega elif re.findall(UrlRegex.youTube, mirrorInfo.downloadUrl): - mirrorInfo.isYouTubeDownload = True + mirrorInfo.downloadType = DownloadType.YouTube elif re.findall(UrlRegex.bittorrentMagnet, mirrorInfo.downloadUrl): - mirrorInfo.isQbitTorrentDownload = True + mirrorInfo.downloadType = DownloadType.QbitTorrent elif re.findall(UrlRegex.generalUrl, mirrorInfo.downloadUrl): - mirrorInfo.isAriaDownload = True + mirrorInfo.downloadType = DownloadType.Aria else: - isValidDl = False + pass except IndexError: replyTo = msg.reply_to_message if replyTo: @@ -1125,18 +1129,18 @@ def genMirrorInfo(self, msg: telegram.Message) -> (bool, 'MirrorInfo'): for media in [replyTo.document, replyTo.audio, replyTo.video]: if media: if media.mime_type == self.botHelper.torrentFileMimeType: - mirrorInfo.isQbitTorrentDownload = True + mirrorInfo.downloadType = DownloadType.QbitTorrent torrentFile = media.get_file().file_path mirrorInfo.downloadUrl = self.botHelper.getHelper.magnetFromTorrentFile(torrentFile) os.remove(torrentFile) else: - mirrorInfo.isTelegramDownload = True + mirrorInfo.downloadType = DownloadType.Telegram break else: - isValidDl = False - if not isValidDl: + pass + if mirrorInfo.downloadType == DownloadType.NULL: self.logger.info('No Valid Link Provided !') - return isValidDl, mirrorInfo + return mirrorInfo class StatusHelper(BaseHelper): @@ -1171,9 +1175,9 @@ def getStatusMsgTxt(self) -> str: statusMsgTxt += f'{mirrorInfo.uid} | {mirrorInfo.currentStatus}\n' if mirrorInfo.currentStatus in [MirrorStatus.downloadProgress, MirrorStatus.uploadProgress]: if mirrorInfo.currentStatus == MirrorStatus.downloadProgress: - if mirrorInfo.isAriaDownload: + if mirrorInfo.downloadType == DownloadType.Aria: self.botHelper.ariaHelper.updateProgress(mirrorInfo.uid) - if mirrorInfo.isQbitTorrentDownload: + if mirrorInfo.downloadType == DownloadType.QbitTorrent: self.botHelper.qbitTorrentHelper.updateProgress(mirrorInfo.uid) statusMsgTxt += f'S: {self.botHelper.getHelper.readableSize(mirrorInfo.sizeCurrent)} | ' \ f'{self.botHelper.getHelper.readableSize(mirrorInfo.sizeTotal)} | ' \ @@ -1687,7 +1691,6 @@ def __init__(self, botHelper: BotHelper): def initHelper(self) -> None: super().initHelper() - self.isValidDl: bool self.mirrorInfo: MirrorInfo self.FIRST, self.SECOND, self.THIRD, self.FOURTH, self.FIFTH = range(5) # TODO: filter - restrict to user who sent MirrorCommand @@ -1719,17 +1722,17 @@ def initHelper(self) -> None: conversation_timeout=120, run_async=True) def stageZero(self, update: telegram.Update, _: telegram.ext.CallbackContext) -> int: - self.isValidDl, self.mirrorInfo = self.botHelper.mirrorHelper.genMirrorInfo(update.message) - if self.isValidDl: + self.mirrorInfo = self.botHelper.mirrorHelper.genMirrorInfo(update.message) + if self.mirrorInfo.downloadType != DownloadType.NULL: # - self.mirrorInfo.isGoogleDriveUpload = True + self.mirrorInfo.uploadType = UploadType.GoogleDrive self.mirrorInfo.googleDriveUploadFolderId = \ list(self.botHelper.configHelper.configVars[self.botHelper.configHelper.reqVars[5]].keys())[0] # update.message.reply_text(text=self.getMirrorInfoStr(), reply_to_message_id=update.message.message_id, reply_markup=InlineKeyboardMaker(['Use Defaults', 'Customize']).build(1)) return self.FIRST - if not self.isValidDl: + else: update.message.reply_text(text='No Valid Link Provided !', reply_to_message_id=update.message.message_id) return telegram.ext.ConversationHandler.END @@ -1754,12 +1757,11 @@ def stageTwo(self, update: telegram.Update, _: telegram.ext.CallbackContext) -> query.edit_message_text(text='Choose `googleDriveUploadFolder`:', reply_markup=InlineKeyboardMaker(buttonList).build(1)) return self.THIRD elif query.data in ['2', '3']: - self.mirrorInfo.isGoogleDriveUpload = False self.mirrorInfo.googleDriveUploadFolderId = '' if query.data == '2': - self.mirrorInfo.isMegaUpload = True + self.mirrorInfo.uploadType = UploadType.Mega elif query.data == '3': - self.mirrorInfo.isTelegramUpload = True + self.mirrorInfo.uploadType = UploadType.Telegram buttonList = ['isCompress', 'isDecompress', 'Skip'] query.edit_message_text(text='Choose:', reply_markup=InlineKeyboardMaker(buttonList).build(1)) return self.FOURTH @@ -1798,29 +1800,35 @@ def stageFive(self, update: telegram.Update, _: telegram.ext.CallbackContext) -> # TODO: reduce this method code if possible def getMirrorInfoStr(self): mirrorInfoStr = f'[uid | {self.mirrorInfo.uid}]\n' - if self.mirrorInfo.isAriaDownload: - mirrorInfoStr += f'[isAriaDownload | True]\n' - elif self.mirrorInfo.isGoogleDriveDownload: - mirrorInfoStr += f'[isGoogleDriveDownload | True]\n' - elif self.mirrorInfo.isMegaDownload: - mirrorInfoStr += f'[isMegaDownload | True]\n' - elif self.mirrorInfo.isQbitTorrentDownload: - mirrorInfoStr += f'[isQbitTorrentDownload | True]\n' - elif self.mirrorInfo.isTelegramDownload: - mirrorInfoStr += f'[isTelegramDownload | True]\n' - elif self.mirrorInfo.isYouTubeDownload: - mirrorInfoStr += f'[isYouTubeDownload | True]\n' - if self.mirrorInfo.isGoogleDriveUpload: - mirrorInfoStr += f'[isGoogleDriveUpload | True]\n' - elif self.mirrorInfo.isMegaUpload: - mirrorInfoStr += f'[isMegaUpload | True]\n' - elif self.mirrorInfo.isTelegramUpload: - mirrorInfoStr += f'[isTelegramUpload | True]\n' + mirrorInfoStr += '[downloadType | ' + match self.mirrorInfo.downloadType: + case DownloadType.Aria: + mirrorInfoStr += 'Aria' + case DownloadType.GoogleDrive: + mirrorInfoStr += 'GoogleDrive' + case DownloadType.Mega: + mirrorInfoStr += 'Mega' + case DownloadType.QbitTorrent: + mirrorInfoStr += 'QbitTorrent' + case DownloadType.Telegram: + mirrorInfoStr += 'Telegram' + case DownloadType.YouTube: + mirrorInfoStr += 'YouTube' + mirrorInfoStr += ']\n' + mirrorInfoStr += '[uploadType | ' + match self.mirrorInfo.uploadType: + case UploadType.GoogleDrive: + mirrorInfoStr += 'GoogleDrive' + case UploadType.Mega: + mirrorInfoStr += 'Mega' + case UploadType.Telegram: + mirrorInfoStr += 'Telegram' + mirrorInfoStr += ']\n' if self.mirrorInfo.isCompress: mirrorInfoStr += f'[isCompress | True]\n' - elif self.mirrorInfo.isDecompress: + if self.mirrorInfo.isDecompress: mirrorInfoStr += f'[isDecompress | True]\n' - if self.mirrorInfo.isGoogleDriveUpload: + if self.mirrorInfo.uploadType == UploadType.GoogleDrive: mirrorInfoStr += f'[googleDriveUploadFolderId | {self.mirrorInfo.googleDriveUploadFolderId}]' return mirrorInfoStr @@ -1961,8 +1969,7 @@ def onDownloadComplete(self, _: aria2p.API, gid: str) -> None: dlPath = self.botHelper.mirrorHelper.mirrorInfos[uid].path dlContent = os.path.join(dlPath, os.listdir(dlPath)[0]) if os.path.isfile(dlContent) and (magic.Magic(mime=True).from_file(dlContent) == self.botHelper.torrentFileMimeType): - self.botHelper.mirrorHelper.mirrorInfos[uid].isAriaDownload = False - self.botHelper.mirrorHelper.mirrorInfos[uid].isQbitTorrentDownload = True + self.botHelper.mirrorHelper.mirrorInfos[uid].downloadType = DownloadType.QbitTorrent self.botHelper.mirrorHelper.mirrorInfos[uid].downloadUrl = self.botHelper.getHelper.magnetFromTorrentFile(dlContent) os.remove(dlContent) os.rmdir(self.botHelper.mirrorHelper.mirrorInfos[uid].path) @@ -2018,7 +2025,7 @@ def addDownload(self, mirrorInfo: 'MirrorInfo') -> None: isFolder = False if self.getMetadataById(sourceId, 'mimeType') == self.googleDriveFolderMimeType: isFolder = True - if mirrorInfo.isGoogleDriveUpload and not (mirrorInfo.isCompress or mirrorInfo.isDecompress): + if (mirrorInfo.uploadType == UploadType.GoogleDrive) and not (mirrorInfo.isCompress or mirrorInfo.isDecompress): if isFolder: folderId = self.cloneFolder(sourceFolderId=sourceId, parentFolderId=mirrorInfo.googleDriveUploadFolderId, uid=mirrorInfo.uid) self.botHelper.mirrorHelper.mirrorInfos[mirrorInfo.uid].uploadUrl = self.baseFolderDownloadUrl.format(folderId) @@ -2036,7 +2043,7 @@ def cancelDownload(self, mirrorInfo: 'MirrorInfo') -> None: raise NotImplementedError def addUpload(self, mirrorInfo: 'MirrorInfo') -> None: - if not (mirrorInfo.isGoogleDriveDownload and not (mirrorInfo.isCompress or mirrorInfo.isDecompress)): + if not ((mirrorInfo.downloadType == DownloadType.GoogleDrive) and not (mirrorInfo.isCompress or mirrorInfo.isDecompress)): currVars = {MirrorInfo.UpdatableVars[0]: self.botHelper.getHelper.folderSize(mirrorInfo.path)} self.botHelper.mirrorHelper.mirrorInfos[mirrorInfo.uid].updateVars(currVars) uploadPath = os.path.join(mirrorInfo.path, os.listdir(mirrorInfo.path)[0]) @@ -2756,15 +2763,8 @@ def __init__(self, msg: telegram.Message, botHelper: BotHelper): self.numLeechers: int = 0 self.uploadUrl: str = '' self.googleDriveUploadFolderId: str = '' - self.isAriaDownload: bool = False - self.isGoogleDriveDownload: bool = False - self.isMegaDownload: bool = False - self.isQbitTorrentDownload: bool = False - self.isTelegramDownload: bool = False - self.isYouTubeDownload: bool = False - self.isGoogleDriveUpload: bool = False - self.isMegaUpload: bool = False - self.isTelegramUpload: bool = False + self.downloadType: DownloadType = DownloadType.NULL + self.uploadType: UploadType = UploadType.NULL self.isCompress: bool = False self.isDecompress: bool = False @@ -2832,6 +2832,23 @@ class UrlRegex: youTube = r"((https|http)://)?((www|m)\.)?(youtube\.com|youtu\.be)/(watch\?v=)?[\w\-]+" +class DownloadType(enum.Enum): + NULL = 0 + Aria = 1 + GoogleDrive = 2 + Mega = 3 + QbitTorrent = 4 + Telegram = 5 + YouTube = 6 + + +class UploadType(enum.Enum): + NULL = 0 + GoogleDrive = 1 + Mega = 2 + Telegram = 3 + + class WebhookServer: def __init__(self, botHelper: BotHelper): self.botHelper = botHelper