From 31016f45dd3dbaab89d7fdbb33a51d86a18ad919 Mon Sep 17 00:00:00 2001
From: Lovi <62809003+Lovi-0@users.noreply.github.com>
Date: Thu, 19 Dec 2024 12:39:43 +0100
Subject: [PATCH] Migrate to pycryptodomex
---
README.md | 17 +----
StreamingCommunity/Api/Player/maxstream.py | 2 +-
StreamingCommunity/Api/Player/vixcloud.py | 2 +-
.../ilcorsaronero/util/ilCorsarScraper.py | 4 +-
.../Api/Template/Util/get_domain.py | 5 ++
.../Lib/Downloader/HLS/downloader.py | 1 -
.../Lib/Downloader/HLS/segments.py | 14 ++--
.../Lib/Downloader/MP4/downloader.py | 1 -
.../Lib/Downloader/TOR/downloader.py | 1 -
StreamingCommunity/Lib/Driver/driver_1.py | 76 -------------------
StreamingCommunity/Lib/M3U8/decryptor.py | 12 +--
StreamingCommunity/run.py | 8 --
config.json | 10 +--
requirements.txt | 3 +-
14 files changed, 26 insertions(+), 130 deletions(-)
delete mode 100644 StreamingCommunity/Lib/Driver/driver_1.py
diff --git a/README.md b/README.md
index 3911fd6..774a20f 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,6 @@ Chat, contribute, and have fun in our **Git_StreamingCommunity** Discord [Server
- [Configuration](#configuration)
- [Default](#default-settings)
- [Request](#requests-settings)
- - [Browser](#browser-settings)
- [Download](#m3u8_download-settings)
- [Parser](#m3u8_parser-settings)
- [Docker](#docker)
@@ -173,8 +172,7 @@ The configuration file is divided into several main sections:
"movie_folder_name": "Movie",
"serie_folder_name": "TV",
"map_episode_name": "%(tv_name)_S%(season)E%(episode)_%(episode_name)",
- "not_close": false,
- "show_trending": false
+ "not_close": false
}
```
@@ -202,7 +200,6 @@ The configuration file is divided into several main sections:
`
`
- `not_close`: If true, continues running after downloading
-- `show_trending`: Display trending content on startup
### qBittorrent Configuration
@@ -235,18 +232,6 @@ The configuration file is divided into several main sections:
-## BROWSER Settings
-
-```json
-{
- "headless": false
-}
-```
-
-- `headless`: Controls whether to run browser in headless mode
-
-
-
## M3U8_DOWNLOAD Settings
```json
diff --git a/StreamingCommunity/Api/Player/maxstream.py b/StreamingCommunity/Api/Player/maxstream.py
index d05b714..3cb17b2 100644
--- a/StreamingCommunity/Api/Player/maxstream.py
+++ b/StreamingCommunity/Api/Player/maxstream.py
@@ -78,7 +78,7 @@ class VideoSource:
logging.warning("Anchor tag not found. Trying the alternative method.")
headers = {
'origin': 'https://stayonline.pro',
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 OPR/111.0.0.0',
+ 'user-agent': get_headers(),
'x-requested-with': 'XMLHttpRequest',
}
diff --git a/StreamingCommunity/Api/Player/vixcloud.py b/StreamingCommunity/Api/Player/vixcloud.py
index 73e6da6..d9531c6 100644
--- a/StreamingCommunity/Api/Player/vixcloud.py
+++ b/StreamingCommunity/Api/Player/vixcloud.py
@@ -12,7 +12,7 @@ from bs4 import BeautifulSoup
# Internal utilities
from StreamingCommunity.Util.headers import get_headers
-from StreamingCommunity.Util.console import console, Panel
+from StreamingCommunity.Util.console import console
from StreamingCommunity.Util._jsonConfig import config_manager
from .Helper.Vixcloud.util import WindowVideo, WindowParameter, StreamsCollection
from .Helper.Vixcloud.js_parser import JavaScriptParser
diff --git a/StreamingCommunity/Api/Site/ilcorsaronero/util/ilCorsarScraper.py b/StreamingCommunity/Api/Site/ilcorsaronero/util/ilCorsarScraper.py
index 362f10a..90804fa 100644
--- a/StreamingCommunity/Api/Site/ilcorsaronero/util/ilCorsarScraper.py
+++ b/StreamingCommunity/Api/Site/ilcorsaronero/util/ilCorsarScraper.py
@@ -1,4 +1,5 @@
# 12.14.24
+
import logging
import asyncio
from typing import List, Dict, Optional
@@ -11,6 +12,7 @@ from bs4 import BeautifulSoup
# Internal utilities
from StreamingCommunity.Util._jsonConfig import config_manager
+from StreamingCommunity.Util.headers import get_headers
from StreamingCommunity.Util.console import console
@@ -23,7 +25,7 @@ class IlCorsaroNeroScraper:
self.base_url = base_url
self.max_page = max_page
self.headers = {
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
+ 'User-Agent': get_headers(),
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Connection': 'keep-alive',
diff --git a/StreamingCommunity/Api/Template/Util/get_domain.py b/StreamingCommunity/Api/Template/Util/get_domain.py
index 5e145e2..9c66ab5 100644
--- a/StreamingCommunity/Api/Template/Util/get_domain.py
+++ b/StreamingCommunity/Api/Template/Util/get_domain.py
@@ -60,6 +60,11 @@ def get_final_redirect_url(initial_url, max_timeout):
) as client:
response = client.get(initial_url)
+
+ if response.status_code == 403:
+ console.print("[bold red]The owner of this website has banned your IP[/bold red]")
+ raise
+
response.raise_for_status()
# Capture the final URL after all redirects
diff --git a/StreamingCommunity/Lib/Downloader/HLS/downloader.py b/StreamingCommunity/Lib/Downloader/HLS/downloader.py
index 8aa2226..e903cb4 100644
--- a/StreamingCommunity/Lib/Downloader/HLS/downloader.py
+++ b/StreamingCommunity/Lib/Downloader/HLS/downloader.py
@@ -49,7 +49,6 @@ GET_ONLY_LINK = config_manager.get_bool('M3U8_PARSER', 'get_only_link')
# Variable
max_timeout = config_manager.get_int("REQUESTS", "timeout")
-headers_index = config_manager.get_dict('REQUESTS', 'user-agent')
m3u8_url_fixer = M3U8_UrlFix()
list_MissingTs = []
diff --git a/StreamingCommunity/Lib/Downloader/HLS/segments.py b/StreamingCommunity/Lib/Downloader/HLS/segments.py
index 9787598..1063eac 100644
--- a/StreamingCommunity/Lib/Downloader/HLS/segments.py
+++ b/StreamingCommunity/Lib/Downloader/HLS/segments.py
@@ -43,7 +43,7 @@ TQDM_DELAY_WORKER = config_manager.get_float('M3U8_DOWNLOAD', 'tqdm_delay')
TQDM_USE_LARGE_BAR = config_manager.get_int('M3U8_DOWNLOAD', 'tqdm_use_large_bar')
REQUEST_MAX_RETRY = config_manager.get_int('REQUESTS', 'max_retry')
-REQUEST_VERIFY = config_manager.get_bool('REQUESTS', 'verify_ssl')
+REQUEST_VERIFY = False
THERE_IS_PROXY_LIST = os_manager.check_file("list_proxy.txt")
PROXY_START_MIN = config_manager.get_float('REQUESTS', 'proxy_start_min')
@@ -55,7 +55,6 @@ DEFAULT_AUDIO_WORKERS = config_manager.get_int('M3U8_DOWNLOAD', 'default_audio_w
# Variable
-headers_index = config_manager.get_dict('REQUESTS', 'user-agent')
max_timeout = config_manager.get_int("REQUESTS", "timeout")
@@ -110,7 +109,6 @@ class M3U8_Segments:
Returns:
bytes: The encryption key in bytes.
"""
- headers_index = {'user-agent': get_headers()}
# Construct the full URL of the key
key_uri = urljoin(self.url, m3u8_parser.keys.get('uri'))
@@ -122,7 +120,7 @@ class M3U8_Segments:
try:
response = httpx.get(
url=key_uri,
- headers=headers_index,
+ headers={'User-Agent': get_headers()},
timeout=max_timeout
)
response.raise_for_status()
@@ -194,14 +192,12 @@ class M3U8_Segments:
"""
Makes a request to the index M3U8 file to get information about segments.
"""
- headers_index = {'user-agent': get_headers()}
-
if self.is_index_url:
# Send a GET request to retrieve the index M3U8 file
response = httpx.get(
self.url,
- headers=headers_index,
+ headers={'User-Agent': get_headers()},
timeout=max_timeout
)
response.raise_for_status()
@@ -271,7 +267,7 @@ class M3U8_Segments:
else:
response = client.get(
url=ts_url,
- headers={'user-agent': get_headers()},
+ headers={'User-Agent': get_headers()},
timeout=max_timeout,
follow_redirects=True
)
@@ -289,7 +285,7 @@ class M3U8_Segments:
else:
response = client_2.get(
url=ts_url,
- headers={'user-agent': get_headers()},
+ headers={'User-Agent': get_headers()},
timeout=max_timeout,
follow_redirects=True
)
diff --git a/StreamingCommunity/Lib/Downloader/MP4/downloader.py b/StreamingCommunity/Lib/Downloader/MP4/downloader.py
index e008cd4..51c1be7 100644
--- a/StreamingCommunity/Lib/Downloader/MP4/downloader.py
+++ b/StreamingCommunity/Lib/Downloader/MP4/downloader.py
@@ -32,7 +32,6 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# Config
GET_ONLY_LINK = config_manager.get_bool('M3U8_PARSER', 'get_only_link')
TQDM_USE_LARGE_BAR = config_manager.get_int('M3U8_DOWNLOAD', 'tqdm_use_large_bar')
-REQUEST_VERIFY = config_manager.get_float('REQUESTS', 'verify_ssl')
REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout')
diff --git a/StreamingCommunity/Lib/Downloader/TOR/downloader.py b/StreamingCommunity/Lib/Downloader/TOR/downloader.py
index 49271be..e2f763d 100644
--- a/StreamingCommunity/Lib/Downloader/TOR/downloader.py
+++ b/StreamingCommunity/Lib/Downloader/TOR/downloader.py
@@ -29,7 +29,6 @@ PASSWORD = str(config_manager.get_dict('DEFAULT', 'config_qbit_tor')['pass'])
# Config
TQDM_USE_LARGE_BAR = config_manager.get_int('M3U8_DOWNLOAD', 'tqdm_use_large_bar')
-REQUEST_VERIFY = config_manager.get_float('REQUESTS', 'verify_ssl')
REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout')
diff --git a/StreamingCommunity/Lib/Driver/driver_1.py b/StreamingCommunity/Lib/Driver/driver_1.py
deleted file mode 100644
index 5a17a24..0000000
--- a/StreamingCommunity/Lib/Driver/driver_1.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# 29.06.24
-
-import tempfile
-import logging
-
-
-# External library
-from bs4 import BeautifulSoup
-from seleniumbase import Driver
-
-
-# Internal utilities
-from StreamingCommunity.Util._jsonConfig import config_manager
-
-
-# Config
-USE_HEADLESS = config_manager.get_bool("BROWSER", "headless")
-
-
-class WebAutomation:
- """
- A class for automating web interactions using SeleniumBase and BeautifulSoup.
- """
-
- def __init__(self):
- """
- Initializes the WebAutomation instance with SeleniumBase Driver.
-
- Parameters:
- headless (bool, optional): Whether to run the browser in headless mode. Default is True.
- """
- logging.getLogger('seleniumbase').setLevel(logging.ERROR)
-
- self.driver = Driver(
- uc=True,
- uc_cdp_events=True,
- headless=USE_HEADLESS,
- user_data_dir = tempfile.mkdtemp(),
- chromium_arg="--disable-search-engine-choice-screen"
- )
-
- def quit(self):
- """
- Quits the WebDriver instance.
- """
- self.driver.quit()
-
- def get_page(self, url):
- """
- Navigates the browser to the specified URL.
-
- Parameters:
- url (str): The URL to navigate to.
- """
- self.driver.get(url)
-
- def retrieve_soup(self):
- """
- Retrieves the BeautifulSoup object for the current page's HTML content.
-
- Returns:
- BeautifulSoup object: Parsed HTML content of the current page.
- """
- html_content = self.driver.page_source
- soup = BeautifulSoup(html_content, 'html.parser')
- return soup
-
- def get_content(self):
- """
- Returns the HTML content of the current page.
-
- Returns:
- str: The HTML content of the current page.
- """
- return self.driver.page_source
-
diff --git a/StreamingCommunity/Lib/M3U8/decryptor.py b/StreamingCommunity/Lib/M3U8/decryptor.py
index 336627f..8480bbf 100644
--- a/StreamingCommunity/Lib/M3U8/decryptor.py
+++ b/StreamingCommunity/Lib/M3U8/decryptor.py
@@ -12,14 +12,14 @@ from StreamingCommunity.Util.console import console
# Check if Crypto module is installed
-crypto_spec = importlib.util.find_spec("Crypto")
+crypto_spec = importlib.util.find_spec("Cryptodome")
crypto_installed = crypto_spec is not None
if crypto_installed:
- logging.info("Decrypy use: Crypto")
- from Crypto.Cipher import AES # type: ignore
- from Crypto.Util.Padding import unpad # type: ignore
+ console.print("[cyan]Decrypy use: Cryptodome")
+ from Cryptodome.Cipher import AES
+ from Cryptodome.Util.Padding import unpad
class M3U8_Decryption:
"""
@@ -93,12 +93,12 @@ else:
# Check if openssl command is available
try:
openssl_available = subprocess.run(["openssl", "version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0
- logging.info("Decrypy use: OPENSSL")
+ console.print("[cyan]Decrypy use: OPENSSL")
except:
openssl_available = False
if not openssl_available:
- console.log("[red]Neither python library: pycryptodome nor openssl software is installed. Please install either one of them. Read readme.md [Requirement].")
+ console.log("[red]Neither python library: pycryptodomex nor openssl software is installed. Please install either one of them. Read readme.md [Requirement].")
sys.exit(0)
class M3U8_Decryption:
diff --git a/StreamingCommunity/run.py b/StreamingCommunity/run.py
index e58a47f..0482158 100644
--- a/StreamingCommunity/run.py
+++ b/StreamingCommunity/run.py
@@ -23,7 +23,6 @@ from StreamingCommunity.Util.logger import Logger
# Config
CLOSE_CONSOLE = config_manager.get_bool('DEFAULT', 'not_close')
-SHOW_TRENDING = config_manager.get_bool('DEFAULT', 'show_trending')
def run_function(func: Callable[..., None], close_console: bool = False) -> None:
@@ -126,13 +125,6 @@ def initialize():
except:
console.log("[red]Error with loading github.")
- # Show trending film and series
- if SHOW_TRENDING:
- tmdb.display_trending_films()
- print()
- tmdb.display_trending_tv_shows()
- print()
-
def main():
diff --git a/config.json b/config.json
index a8eab9b..c23131d 100644
--- a/config.json
+++ b/config.json
@@ -15,19 +15,13 @@
"user": "admin",
"pass": "adminadmin"
},
- "not_close": false,
- "show_trending": false
+ "not_close": false
},
"REQUESTS": {
"timeout": 20,
"max_retry": 8,
- "verify_ssl": true,
"proxy_start_min": 0.1,
- "proxy_start_max": 0.5,
- "user-agent": ""
- },
- "BROWSER": {
- "headless": false
+ "proxy_start_max": 0.5
},
"M3U8_DOWNLOAD": {
"tqdm_delay": 0.01,
diff --git a/requirements.txt b/requirements.txt
index 51162b4..30a2516 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,5 @@
httpx
+cffi
bs4
rich
tqdm
@@ -7,7 +8,7 @@ psutil
unidecode
jsbeautifier
pathvalidate
-pycryptodome
+pycryptodomex
fake-useragent==1.1.3
qbittorrent-api
python-qbittorrent