From dd6f72b600f478c8d3d1b8ff5701fddf824137a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Val=C3=A9ry=20Febvre?= Date: Tue, 28 Mar 2023 00:59:34 +0200 Subject: [PATCH] [Servers] Removes Python Cloudscraper dependency --- flatpak/info.febvre.Komikku.json | 2 +- flatpak/python3-cloudscraper.json | 49 ------------------------- komikku/servers/mangahub/__init__.py | 4 +- komikku/servers/mangakawaii/__init__.py | 3 +- komikku/servers/mangasee/__init__.py | 4 +- requirements.txt | 2 +- 6 files changed, 7 insertions(+), 57 deletions(-) delete mode 100644 flatpak/python3-cloudscraper.json diff --git a/flatpak/info.febvre.Komikku.json b/flatpak/info.febvre.Komikku.json index 60774472..30312b15 100644 --- a/flatpak/info.febvre.Komikku.json +++ b/flatpak/info.febvre.Komikku.json @@ -31,7 +31,7 @@ "python3-lxml.json", "python3-beautifulsoup4.json", "python3-brotli.json", - "python3-cloudscraper.json", + "python3-requests.json", "python3-rarfile.json", "python3-emoji.json", "python3-piexif.json", diff --git a/flatpak/python3-cloudscraper.json b/flatpak/python3-cloudscraper.json deleted file mode 100644 index ed5ecff6..00000000 --- a/flatpak/python3-cloudscraper.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "python3-cloudscraper", - "buildsystem": "simple", - "build-commands": [ - "pip3 install --verbose --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"cloudscraper\" --no-build-isolation" - ], - "sources": [ - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/db/51/a507c856293ab05cdc1db77ff4bc1268ddd39f29e7dc4919aa497f0adbec/charset_normalizer-2.1.1-py3-none-any.whl", - "sha256": "83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/fc/34/3030de6f1370931b9dbb4dad48f6ab1015ab1d32447850b9fc94e60097be/idna-3.4-py3-none-any.whl", - "sha256": "90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/3f/ca/81fdcc8f69349d9fe0423d1b2d203d3e4748cb84abcfdacf7370db33640d/cloudscraper-1.2.66-py2.py3-none-any.whl", - "sha256": "ec30da6cee60d0a95e898d9b3aaf09291a0d8b6cf751e86c6f3420b699a00091" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/71/4c/3db2b8021bd6f2f0ceb0e088d6b2d49147671f25832fb17970e9b583d742/certifi-2022.12.7-py3-none-any.whl", - "sha256": "4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/65/0c/cc6644eaa594585e5875f46f3c83ee8762b647b51fc5b0fb253a242df2dc/urllib3-1.26.13-py2.py3-none-any.whl", - "sha256": "47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/ca/91/6d9b8ccacd0412c08820f72cebaa4f0c0441b5cda699c90f618b6f8a1b42/requests-2.28.1-py3-none-any.whl", - "sha256": "8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/6c/10/a7d0fa5baea8fe7b50f448ab742f26f52b80bfca85ac2be9d35cdd9a3246/pyparsing-3.0.9-py3-none-any.whl", - "sha256": "5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc" - }, - { - "type": "file", - "url": "https://files.pythonhosted.org/packages/05/d3/bf87a36bff1cb88fd30a509fd366c70ec30676517ee791b2f77e0e29817a/requests_toolbelt-0.10.1-py2.py3-none-any.whl", - "sha256": "18565aa58116d9951ac39baa288d3adb5b3ff975c4f25eee78555d89e8f247f7" - } - ] -} \ No newline at end of file diff --git a/komikku/servers/mangahub/__init__.py b/komikku/servers/mangahub/__init__.py index fbc7acfe..a173c017 100644 --- a/komikku/servers/mangahub/__init__.py +++ b/komikku/servers/mangahub/__init__.py @@ -2,10 +2,10 @@ # SPDX-License-Identifier: GPL-3.0-only or GPL-3.0-or-later # Author: ISO-morphism -import cloudscraper from functools import wraps import json import logging +import requests from komikku.servers import Server from komikku.servers import USER_AGENT @@ -50,7 +50,7 @@ class Mangahub(Server): self.api_key = None if self.session is None: - self.session = cloudscraper.create_scraper() + self.session = requests.Session() self.session.headers = { 'User-Agent': USER_AGENT, } diff --git a/komikku/servers/mangakawaii/__init__.py b/komikku/servers/mangakawaii/__init__.py index 51c1d9cc..32e69197 100644 --- a/komikku/servers/mangakawaii/__init__.py +++ b/komikku/servers/mangakawaii/__init__.py @@ -3,7 +3,6 @@ # Author: Valéry Febvre from bs4 import BeautifulSoup -import cloudscraper from functools import wraps import json import requests @@ -53,7 +52,7 @@ class Mangakawaii(Server): def __init__(self): if self.session is None: - self.session = cloudscraper.create_scraper() + self.session = requests.Session() cookie = requests.cookies.create_cookie( name='mk_search_type', value='manga', diff --git a/komikku/servers/mangasee/__init__.py b/komikku/servers/mangasee/__init__.py index bc915eb4..1bf4bb23 100644 --- a/komikku/servers/mangasee/__init__.py +++ b/komikku/servers/mangasee/__init__.py @@ -3,8 +3,8 @@ # Author: Valéry Febvre from bs4 import BeautifulSoup -import cloudscraper import json +import requests from komikku.servers import Server from komikku.servers import USER_AGENT_MOBILE @@ -38,7 +38,7 @@ class Mangasee(Server): def __init__(self): if self.session is None: - self.session = cloudscraper.create_scraper() + self.session = requests.Session() self.session.headers = headers def get_manga_data(self, initial_data): diff --git a/requirements.txt b/requirements.txt index 4d4694a0..034008d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ beautifulsoup4 brotli -cloudscraper dateparser >= 1.1.4 emoji keyring >= 21.6.0 @@ -12,4 +11,5 @@ pure-protobuf PyGObject python_magic rarfile +requests Unidecode