🎨 Updated variable name

This commit is contained in:
Nikhil Badyal
2023-08-22 21:06:53 +05:30
parent a92de3e6da
commit 07b01bb3a1
8 changed files with 17 additions and 22 deletions
+2 -2
View File
@@ -17,12 +17,12 @@ class RevancedConfig(object):
"""Revanced Configurations."""
def __init__(self, env: Env) -> None:
from src.utils import default_build
from src.utils import default_build, request_header
self.env = env
self.temp_folder = Path("apks")
self.session = Session()
self.session.headers["User-Agent"] = "anything"
self.session.headers["User-Agent"] = request_header["User-Agent"]
self.ci_test = env.bool("CI_TEST", False)
self.apps = env.list(
"PATCH_APPS",
+2 -3
View File
@@ -5,11 +5,10 @@ import requests
from bs4 import BeautifulSoup, Tag
from loguru import logger
from scripts.status_check import headers
from src.downloader.download import Downloader
from src.downloader.sources import APK_MIRROR_BASE_URL, apk_sources
from src.exceptions import APKMirrorAPKDownloadFailure
from src.utils import bs4_parser, contains_any_word
from src.utils import bs4_parser, contains_any_word, request_header
class ApkMirror(Downloader):
@@ -84,7 +83,7 @@ class ApkMirror(Downloader):
@staticmethod
def _extracted_search_div(url: str, search_class: str) -> Tag:
"""Extract search div."""
r = requests.get(url, headers=headers, timeout=60)
r = requests.get(url, headers=request_header, timeout=60)
if r.status_code != 200:
raise APKMirrorAPKDownloadFailure(
f"Unable to connect with {url} on ApkMirror. Are you blocked by APKMirror or abused apkmirror "
+2 -3
View File
@@ -4,11 +4,10 @@ from typing import Any
import requests
from bs4 import BeautifulSoup
from scripts.status_check import headers
from src.downloader.download import Downloader
from src.downloader.sources import apk_sources
from src.exceptions import APKSosAPKDownloadFailure
from src.utils import bs4_parser
from src.utils import bs4_parser, request_header
class ApkSos(Downloader):
@@ -20,7 +19,7 @@ class ApkSos(Downloader):
:param page: Url of the page
:param app: Name of the app
"""
r = requests.get(page, headers=headers, allow_redirects=True)
r = requests.get(page, headers=request_header, allow_redirects=True)
soup = BeautifulSoup(r.text, bs4_parser)
download_button = soup.find(class_="col-sm-12 col-md-8 text-center")
possible_links = download_button.find_all("a")
+2 -3
View File
@@ -5,18 +5,17 @@ import requests
from bs4 import BeautifulSoup
from loguru import logger
from scripts.status_check import headers
from src.downloader.download import Downloader
from src.downloader.sources import apk_sources
from src.exceptions import UptoDownAPKDownloadFailure
from src.utils import bs4_parser
from src.utils import bs4_parser, request_header
class UptoDown(Downloader):
"""Files downloader."""
def extract_download_link(self, page: str, app: str) -> str:
r = requests.get(page, headers=headers, allow_redirects=True, timeout=60)
r = requests.get(page, headers=request_header, allow_redirects=True, timeout=60)
soup = BeautifulSoup(r.text, bs4_parser)
soup = soup.find(id="detail-download-button")
download_url = soup.get("data-url")
-1
View File
@@ -188,7 +188,6 @@ class Patches(object):
parser.include(normalized_patch) if normalized_patch not in getattr(
self, "universal_patch", []
) else ()
logger.info(app)
def get_app_configs(self, app: "APP") -> List[Dict[str, str]]:
"""The function `get_app_configs` retrieves configurations for a given
+5 -3
View File
@@ -17,8 +17,10 @@ default_build = [
]
possible_archs = ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
apk_mirror_base_url = "https://www.apkmirror.com"
apk_mirror_header = {
"User-Agent": "APKUpdater-v" + "3.0.1",
request_header = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (HTML, like Gecko)"
" Chrome/96.0.4664.93 Safari/537.36",
"Authorization": "Basic YXBpLWFwa3VwZGF0ZXI6cm01cmNmcnVVakt5MDRzTXB5TVBKWFc4",
"Content-Type": "application/json",
}
@@ -237,7 +239,7 @@ def apkmirror_status_check(package_name: str) -> Any:
"""
api_url = f"{apk_mirror_base_url}/wp-json/apkm/v1/app_exists/"
body = {"pnames": [package_name]}
response = requests.post(api_url, json=body, headers=apk_mirror_header)
response = requests.post(api_url, json=body, headers=request_header)
return response.json()