StreamingCommunity 1.7.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of StreamingCommunity might be problematic. Click here for more details.
- StreamingCommunity/Src/Api/Player/Helper/Vixcloud/js_parser.py +140 -0
- StreamingCommunity/Src/Api/Player/Helper/Vixcloud/util.py +166 -0
- StreamingCommunity/Src/Api/Player/ddl.py +89 -0
- StreamingCommunity/Src/Api/Player/maxstream.py +151 -0
- StreamingCommunity/Src/Api/Player/supervideo.py +194 -0
- StreamingCommunity/Src/Api/Player/vixcloud.py +212 -0
- StreamingCommunity/Src/Api/Site/1337xx/__init__.py +50 -0
- StreamingCommunity/Src/Api/Site/1337xx/costant.py +15 -0
- StreamingCommunity/Src/Api/Site/1337xx/site.py +84 -0
- StreamingCommunity/Src/Api/Site/1337xx/title.py +66 -0
- StreamingCommunity/Src/Api/Site/altadefinizione/__init__.py +50 -0
- StreamingCommunity/Src/Api/Site/altadefinizione/costant.py +15 -0
- StreamingCommunity/Src/Api/Site/altadefinizione/film.py +69 -0
- StreamingCommunity/Src/Api/Site/altadefinizione/site.py +86 -0
- StreamingCommunity/Src/Api/Site/animeunity/__init__.py +50 -0
- StreamingCommunity/Src/Api/Site/animeunity/anime.py +126 -0
- StreamingCommunity/Src/Api/Site/animeunity/costant.py +15 -0
- StreamingCommunity/Src/Api/Site/animeunity/film_serie.py +131 -0
- StreamingCommunity/Src/Api/Site/animeunity/site.py +165 -0
- StreamingCommunity/Src/Api/Site/animeunity/util/ScrapeSerie.py +97 -0
- StreamingCommunity/Src/Api/Site/bitsearch/__init__.py +51 -0
- StreamingCommunity/Src/Api/Site/bitsearch/costant.py +15 -0
- StreamingCommunity/Src/Api/Site/bitsearch/site.py +84 -0
- StreamingCommunity/Src/Api/Site/bitsearch/title.py +47 -0
- StreamingCommunity/Src/Api/Site/cb01new/__init__.py +51 -0
- StreamingCommunity/Src/Api/Site/cb01new/costant.py +15 -0
- StreamingCommunity/Src/Api/Site/cb01new/film.py +69 -0
- StreamingCommunity/Src/Api/Site/cb01new/site.py +74 -0
- StreamingCommunity/Src/Api/Site/ddlstreamitaly/Player/ScrapeSerie.py +83 -0
- StreamingCommunity/Src/Api/Site/ddlstreamitaly/__init__.py +57 -0
- StreamingCommunity/Src/Api/Site/ddlstreamitaly/costant.py +16 -0
- StreamingCommunity/Src/Api/Site/ddlstreamitaly/series.py +142 -0
- StreamingCommunity/Src/Api/Site/ddlstreamitaly/site.py +93 -0
- StreamingCommunity/Src/Api/Site/ddlstreamitaly/util/ScrapeSerie.py +83 -0
- StreamingCommunity/Src/Api/Site/guardaserie/Player/ScrapeSerie.py +110 -0
- StreamingCommunity/Src/Api/Site/guardaserie/__init__.py +52 -0
- StreamingCommunity/Src/Api/Site/guardaserie/costant.py +15 -0
- StreamingCommunity/Src/Api/Site/guardaserie/series.py +195 -0
- StreamingCommunity/Src/Api/Site/guardaserie/site.py +84 -0
- StreamingCommunity/Src/Api/Site/guardaserie/util/ScrapeSerie.py +110 -0
- StreamingCommunity/Src/Api/Site/mostraguarda/__init__.py +48 -0
- StreamingCommunity/Src/Api/Site/mostraguarda/costant.py +15 -0
- StreamingCommunity/Src/Api/Site/mostraguarda/film.py +94 -0
- StreamingCommunity/Src/Api/Site/piratebays/__init__.py +50 -0
- StreamingCommunity/Src/Api/Site/piratebays/costant.py +15 -0
- StreamingCommunity/Src/Api/Site/piratebays/site.py +89 -0
- StreamingCommunity/Src/Api/Site/piratebays/title.py +45 -0
- StreamingCommunity/Src/Api/Site/streamingcommunity/__init__.py +55 -0
- StreamingCommunity/Src/Api/Site/streamingcommunity/costant.py +15 -0
- StreamingCommunity/Src/Api/Site/streamingcommunity/film.py +70 -0
- StreamingCommunity/Src/Api/Site/streamingcommunity/series.py +203 -0
- StreamingCommunity/Src/Api/Site/streamingcommunity/site.py +126 -0
- StreamingCommunity/Src/Api/Site/streamingcommunity/util/ScrapeSerie.py +113 -0
- StreamingCommunity/Src/Api/Template/Class/SearchType.py +101 -0
- StreamingCommunity/Src/Api/Template/Util/__init__.py +5 -0
- StreamingCommunity/Src/Api/Template/Util/get_domain.py +137 -0
- StreamingCommunity/Src/Api/Template/Util/manage_ep.py +153 -0
- StreamingCommunity/Src/Api/Template/Util/recall_search.py +37 -0
- StreamingCommunity/Src/Api/Template/__init__.py +3 -0
- StreamingCommunity/Src/Api/Template/site.py +87 -0
- StreamingCommunity/Src/Lib/Downloader/HLS/downloader.py +968 -0
- StreamingCommunity/Src/Lib/Downloader/HLS/proxyes.py +110 -0
- StreamingCommunity/Src/Lib/Downloader/HLS/segments.py +540 -0
- StreamingCommunity/Src/Lib/Downloader/MP4/downloader.py +156 -0
- StreamingCommunity/Src/Lib/Downloader/TOR/downloader.py +222 -0
- StreamingCommunity/Src/Lib/Downloader/__init__.py +5 -0
- StreamingCommunity/Src/Lib/Driver/driver_1.py +76 -0
- StreamingCommunity/Src/Lib/FFmpeg/__init__.py +4 -0
- StreamingCommunity/Src/Lib/FFmpeg/capture.py +170 -0
- StreamingCommunity/Src/Lib/FFmpeg/command.py +292 -0
- StreamingCommunity/Src/Lib/FFmpeg/util.py +242 -0
- StreamingCommunity/Src/Lib/M3U8/__init__.py +6 -0
- StreamingCommunity/Src/Lib/M3U8/decryptor.py +129 -0
- StreamingCommunity/Src/Lib/M3U8/estimator.py +173 -0
- StreamingCommunity/Src/Lib/M3U8/parser.py +666 -0
- StreamingCommunity/Src/Lib/M3U8/url_fixer.py +52 -0
- StreamingCommunity/Src/Lib/TMBD/__init__.py +2 -0
- StreamingCommunity/Src/Lib/TMBD/obj_tmbd.py +39 -0
- StreamingCommunity/Src/Lib/TMBD/tmdb.py +346 -0
- StreamingCommunity/Src/Upload/update.py +64 -0
- StreamingCommunity/Src/Upload/version.py +5 -0
- StreamingCommunity/Src/Util/_jsonConfig.py +204 -0
- StreamingCommunity/Src/Util/call_stack.py +42 -0
- StreamingCommunity/Src/Util/color.py +20 -0
- StreamingCommunity/Src/Util/console.py +12 -0
- StreamingCommunity/Src/Util/headers.py +147 -0
- StreamingCommunity/Src/Util/logger.py +53 -0
- StreamingCommunity/Src/Util/message.py +46 -0
- StreamingCommunity/Src/Util/os.py +417 -0
- StreamingCommunity/Src/Util/table.py +163 -0
- StreamingCommunity/run.py +196 -0
- StreamingCommunity-1.7.6.dist-info/LICENSE +674 -0
- StreamingCommunity-1.7.6.dist-info/METADATA +348 -0
- StreamingCommunity-1.7.6.dist-info/RECORD +97 -0
- StreamingCommunity-1.7.6.dist-info/WHEEL +5 -0
- StreamingCommunity-1.7.6.dist-info/entry_points.txt +2 -0
- StreamingCommunity-1.7.6.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# 29.01.24
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import json
|
|
5
|
+
import httpx
|
|
6
|
+
import logging
|
|
7
|
+
from typing import Any, List
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class ConfigManager:
|
|
11
|
+
def __init__(self, file_path: str = 'config.json') -> None:
|
|
12
|
+
"""Initialize the ConfigManager.
|
|
13
|
+
|
|
14
|
+
Parameters:
|
|
15
|
+
- file_path (str, optional): The path to the configuration file. Default is 'config.json'.
|
|
16
|
+
"""
|
|
17
|
+
self.file_path = file_path
|
|
18
|
+
self.config = {}
|
|
19
|
+
self.cache = {}
|
|
20
|
+
|
|
21
|
+
def read_config(self) -> None:
|
|
22
|
+
"""Read the configuration file."""
|
|
23
|
+
try:
|
|
24
|
+
logging.info(f"Reading file: {self.file_path}")
|
|
25
|
+
|
|
26
|
+
# Check if file exist
|
|
27
|
+
if os.path.exists(self.file_path):
|
|
28
|
+
with open(self.file_path, 'r') as f:
|
|
29
|
+
self.config = json.load(f)
|
|
30
|
+
logging.info("Configuration file loaded successfully.")
|
|
31
|
+
|
|
32
|
+
# Download config.json
|
|
33
|
+
else:
|
|
34
|
+
logging.info("Configuration file does not exist. Downloading...")
|
|
35
|
+
url = "https://raw.githubusercontent.com/Lovi-0/StreamingCommunity/refs/heads/main/config.json"
|
|
36
|
+
|
|
37
|
+
with httpx.Client() as client:
|
|
38
|
+
response = client.get(url)
|
|
39
|
+
|
|
40
|
+
if response.status_code == 200:
|
|
41
|
+
with open(self.file_path, 'w') as f:
|
|
42
|
+
f.write(response.text)
|
|
43
|
+
|
|
44
|
+
self.config = json.loads(response.text)
|
|
45
|
+
logging.info("Configuration file downloaded and saved.")
|
|
46
|
+
|
|
47
|
+
else:
|
|
48
|
+
logging.error(f"Failed to download configuration file. Status code: {response.status_code}")
|
|
49
|
+
|
|
50
|
+
except Exception as e:
|
|
51
|
+
logging.error(f"Error reading configuration file: {e}")
|
|
52
|
+
|
|
53
|
+
def read_key(self, section: str, key: str, data_type: type = str) -> Any:
|
|
54
|
+
"""Read a key from the configuration file.
|
|
55
|
+
|
|
56
|
+
Parameters:
|
|
57
|
+
- section (str): The section in the configuration file.
|
|
58
|
+
- key (str): The key to be read.
|
|
59
|
+
- data_type (type, optional): The expected data type of the key's value. Default is str.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
The value of the key converted to the specified data type.
|
|
63
|
+
"""
|
|
64
|
+
cache_key = f"{section}.{key}"
|
|
65
|
+
logging.info(f"Read key: {cache_key}")
|
|
66
|
+
|
|
67
|
+
if cache_key in self.cache:
|
|
68
|
+
return self.cache[cache_key]
|
|
69
|
+
|
|
70
|
+
if section in self.config and key in self.config[section]:
|
|
71
|
+
value = self.config[section][key]
|
|
72
|
+
else:
|
|
73
|
+
raise ValueError(f"Key '{key}' not found in section '{section}'")
|
|
74
|
+
|
|
75
|
+
value = self._convert_to_data_type(value, data_type)
|
|
76
|
+
self.cache[cache_key] = value
|
|
77
|
+
|
|
78
|
+
return value
|
|
79
|
+
|
|
80
|
+
def _convert_to_data_type(self, value: str, data_type: type) -> Any:
|
|
81
|
+
"""Convert the value to the specified data type.
|
|
82
|
+
|
|
83
|
+
Parameters:
|
|
84
|
+
- value (str): The value to be converted.
|
|
85
|
+
- data_type (type): The expected data type.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
The value converted to the specified data type.
|
|
89
|
+
"""
|
|
90
|
+
if data_type == int:
|
|
91
|
+
return int(value)
|
|
92
|
+
elif data_type == bool:
|
|
93
|
+
return bool(value)
|
|
94
|
+
elif data_type == list:
|
|
95
|
+
return value if isinstance(value, list) else [item.strip() for item in value.split(',')]
|
|
96
|
+
elif data_type == type(None):
|
|
97
|
+
return None
|
|
98
|
+
else:
|
|
99
|
+
return value
|
|
100
|
+
|
|
101
|
+
def get(self, section: str, key: str) -> Any:
|
|
102
|
+
"""Read a value from the configuration file.
|
|
103
|
+
|
|
104
|
+
Parameters:
|
|
105
|
+
- section (str): The section in the configuration file.
|
|
106
|
+
- key (str): The key to be read.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
The value associated with the key.
|
|
110
|
+
"""
|
|
111
|
+
return self.read_key(section, key)
|
|
112
|
+
|
|
113
|
+
def get_int(self, section: str, key: str) -> int:
|
|
114
|
+
"""Read an integer value from the configuration file.
|
|
115
|
+
|
|
116
|
+
Parameters:
|
|
117
|
+
- section (str): The section in the configuration file.
|
|
118
|
+
- key (str): The key to be read.
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
int: The integer value.
|
|
122
|
+
"""
|
|
123
|
+
return self.read_key(section, key, int)
|
|
124
|
+
|
|
125
|
+
def get_float(self, section: str, key: str) -> int:
|
|
126
|
+
"""Read an float value from the configuration file.
|
|
127
|
+
|
|
128
|
+
Parameters:
|
|
129
|
+
- section (str): The section in the configuration file.
|
|
130
|
+
- key (str): The key to be read.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
float: The float value.
|
|
134
|
+
"""
|
|
135
|
+
return self.read_key(section, key, float)
|
|
136
|
+
|
|
137
|
+
def get_bool(self, section: str, key: str) -> bool:
|
|
138
|
+
"""Read a boolean value from the configuration file.
|
|
139
|
+
|
|
140
|
+
Parameters:
|
|
141
|
+
- section (str): The section in the configuration file.
|
|
142
|
+
- key (str): The key to be read.
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
bool: The boolean value.
|
|
146
|
+
"""
|
|
147
|
+
return self.read_key(section, key, bool)
|
|
148
|
+
|
|
149
|
+
def get_list(self, section: str, key: str) -> List[str]:
|
|
150
|
+
"""Read a list value from the configuration file.
|
|
151
|
+
|
|
152
|
+
Parameters:
|
|
153
|
+
- section (str): The section in the configuration file.
|
|
154
|
+
- key (str): The key to be read.
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
list: The list value.
|
|
158
|
+
"""
|
|
159
|
+
return self.read_key(section, key, list)
|
|
160
|
+
|
|
161
|
+
def get_dict(self, section: str, key: str) -> dict:
|
|
162
|
+
"""Read a dictionary value from the configuration file.
|
|
163
|
+
|
|
164
|
+
Parameters:
|
|
165
|
+
- section (str): The section in the configuration file.
|
|
166
|
+
- key (str): The key to be read.
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
dict: The dictionary value.
|
|
170
|
+
"""
|
|
171
|
+
return self.read_key(section, key, dict)
|
|
172
|
+
|
|
173
|
+
def set_key(self, section: str, key: str, value: Any) -> None:
|
|
174
|
+
"""Set a key in the configuration file.
|
|
175
|
+
|
|
176
|
+
Parameters:
|
|
177
|
+
- section (str): The section in the configuration file.
|
|
178
|
+
- key (str): The key to be set.
|
|
179
|
+
- value (Any): The value to be associated with the key.
|
|
180
|
+
"""
|
|
181
|
+
try:
|
|
182
|
+
if section not in self.config:
|
|
183
|
+
self.config[section] = {}
|
|
184
|
+
|
|
185
|
+
self.config[section][key] = value
|
|
186
|
+
cache_key = f"{section}.{key}"
|
|
187
|
+
self.cache[cache_key] = value
|
|
188
|
+
self.write_config()
|
|
189
|
+
|
|
190
|
+
except Exception as e:
|
|
191
|
+
print(f"Error setting key '{key}' in section '{section}': {e}")
|
|
192
|
+
|
|
193
|
+
def write_config(self) -> None:
|
|
194
|
+
"""Write the configuration to the file."""
|
|
195
|
+
try:
|
|
196
|
+
with open(self.file_path, 'w') as f:
|
|
197
|
+
json.dump(self.config, f, indent=4)
|
|
198
|
+
except Exception as e:
|
|
199
|
+
print(f"Error writing configuration file: {e}")
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
# Initialize
|
|
203
|
+
config_manager = ConfigManager()
|
|
204
|
+
config_manager.read_config()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# 21.06.24
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import inspect
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_call_stack():
|
|
8
|
+
"""
|
|
9
|
+
Retrieves the current call stack with details about each call.
|
|
10
|
+
|
|
11
|
+
This function inspects the current call stack and returns a list of dictionaries,
|
|
12
|
+
where each dictionary contains details about a function call in the stack.
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
list: A list of dictionaries, each containing the following keys:
|
|
16
|
+
- function (str): The name of the function.
|
|
17
|
+
- folder (str): The directory path of the script containing the function.
|
|
18
|
+
- folder_base (str): The base name of the directory path.
|
|
19
|
+
- script (str): The name of the script file containing the function.
|
|
20
|
+
- line (int): The line number in the script where the function is defined.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
stack = inspect.stack()
|
|
24
|
+
call_stack = []
|
|
25
|
+
|
|
26
|
+
for frame_info in stack:
|
|
27
|
+
function_name = frame_info.function
|
|
28
|
+
filename = frame_info.filename
|
|
29
|
+
lineno = frame_info.lineno
|
|
30
|
+
folder_name = os.path.dirname(filename)
|
|
31
|
+
folder_base = os.path.basename(folder_name)
|
|
32
|
+
script_name = os.path.basename(filename)
|
|
33
|
+
|
|
34
|
+
call_stack.append({
|
|
35
|
+
"function": function_name,
|
|
36
|
+
"folder": folder_name,
|
|
37
|
+
"folder_base": folder_base,
|
|
38
|
+
"script": script_name,
|
|
39
|
+
"line": lineno
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
return call_stack
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# 24.05.24
|
|
2
|
+
|
|
3
|
+
class Colors:
|
|
4
|
+
BLACK = "\033[30m"
|
|
5
|
+
RED = "\033[31m"
|
|
6
|
+
GREEN = "\033[32m"
|
|
7
|
+
YELLOW = "\033[33m"
|
|
8
|
+
BLUE = "\033[34m"
|
|
9
|
+
MAGENTA = "\033[35m"
|
|
10
|
+
CYAN = "\033[36m"
|
|
11
|
+
LIGHT_GRAY = "\033[37m"
|
|
12
|
+
DARK_GRAY = "\033[90m"
|
|
13
|
+
LIGHT_RED = "\033[91m"
|
|
14
|
+
LIGHT_GREEN = "\033[92m"
|
|
15
|
+
LIGHT_YELLOW = "\033[93m"
|
|
16
|
+
LIGHT_BLUE = "\033[94m"
|
|
17
|
+
LIGHT_MAGENTA = "\033[95m"
|
|
18
|
+
LIGHT_CYAN = "\033[96m"
|
|
19
|
+
WHITE = "\033[97m"
|
|
20
|
+
RESET = "\033[0m"
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# 4.04.24
|
|
2
|
+
|
|
3
|
+
import re
|
|
4
|
+
import random
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# External library
|
|
8
|
+
from fake_useragent import UserAgent
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# Variable
|
|
12
|
+
ua = UserAgent()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def extract_versions(user_agent):
|
|
16
|
+
"""
|
|
17
|
+
Extract browser versions from the user agent.
|
|
18
|
+
|
|
19
|
+
Parameters:
|
|
20
|
+
user_agent (str): User agent of the browser.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
list: List of browser versions.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
# Patterns to extract versions from various user agents
|
|
27
|
+
patterns = {
|
|
28
|
+
'chrome': re.compile(r'Chrome/(\d+)\.(\d+)\.(\d+)\.(\d+)'),
|
|
29
|
+
'firefox': re.compile(r'Firefox/(\d+)\.?(\d+)?\.?(\d+)?'),
|
|
30
|
+
'safari': re.compile(r'Version/(\d+)\.(\d+)\.(\d+) Safari/(\d+)\.(\d+)\.(\d+)'),
|
|
31
|
+
'edge': re.compile(r'Edg/(\d+)\.(\d+)\.(\d+)\.(\d+)'),
|
|
32
|
+
'edgios': re.compile(r'EdgiOS/(\d+)\.(\d+)\.(\d+)\.(\d+)'),
|
|
33
|
+
'crios': re.compile(r'CriOS/(\d+)\.(\d+)\.(\d+)\.(\d+)'),
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for key, pattern in patterns.items():
|
|
37
|
+
match = pattern.search(user_agent)
|
|
38
|
+
if match:
|
|
39
|
+
return [match.group(i+1) for i in range(match.lastindex)]
|
|
40
|
+
|
|
41
|
+
# Fallback values if specific versions are not found
|
|
42
|
+
return ['99', '0', '0', '0']
|
|
43
|
+
|
|
44
|
+
def get_platform(user_agent):
|
|
45
|
+
"""
|
|
46
|
+
Determine the device platform from the user agent.
|
|
47
|
+
|
|
48
|
+
Parameters:
|
|
49
|
+
user_agent (str): User agent of the browser.
|
|
50
|
+
|
|
51
|
+
Returns:
|
|
52
|
+
str: Device platform.
|
|
53
|
+
"""
|
|
54
|
+
if 'Windows' in user_agent:
|
|
55
|
+
return '"Windows"'
|
|
56
|
+
elif 'Mac OS X' in user_agent:
|
|
57
|
+
return '"macOS"'
|
|
58
|
+
elif 'Android' in user_agent:
|
|
59
|
+
return '"Android"'
|
|
60
|
+
elif 'iPhone' in user_agent or 'iPad' in user_agent:
|
|
61
|
+
return '"iOS"'
|
|
62
|
+
elif 'Linux' in user_agent:
|
|
63
|
+
return '"Linux"'
|
|
64
|
+
return '"Unknown"'
|
|
65
|
+
|
|
66
|
+
def get_model(user_agent):
|
|
67
|
+
"""
|
|
68
|
+
Determine the device model from the user agent.
|
|
69
|
+
|
|
70
|
+
Parameters:
|
|
71
|
+
user_agent (str): User agent of the browser.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
str: Device model.
|
|
75
|
+
"""
|
|
76
|
+
if 'iPhone' in user_agent:
|
|
77
|
+
return '"iPhone"'
|
|
78
|
+
elif 'iPad' in user_agent:
|
|
79
|
+
return '"iPad"'
|
|
80
|
+
elif 'Android' in user_agent:
|
|
81
|
+
return '"Android"'
|
|
82
|
+
elif 'Windows' in user_agent:
|
|
83
|
+
return '"PC"'
|
|
84
|
+
elif 'Mac OS X' in user_agent:
|
|
85
|
+
return '"Mac"'
|
|
86
|
+
elif 'Linux' in user_agent:
|
|
87
|
+
return '"Linux"'
|
|
88
|
+
return '"Unknown"'
|
|
89
|
+
|
|
90
|
+
def random_headers(referer: str = None):
|
|
91
|
+
"""
|
|
92
|
+
Generate random HTTP headers to simulate human-like behavior.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
dict: Generated HTTP headers.
|
|
96
|
+
"""
|
|
97
|
+
user_agent = ua.random
|
|
98
|
+
versions = extract_versions(user_agent)
|
|
99
|
+
platform = get_platform(user_agent)
|
|
100
|
+
model = get_model(user_agent)
|
|
101
|
+
is_mobile = 'Mobi' in user_agent or 'Android' in user_agent
|
|
102
|
+
|
|
103
|
+
# Generate sec-ch-ua string based on the browser
|
|
104
|
+
if 'Chrome' in user_agent or 'CriOS' in user_agent:
|
|
105
|
+
sec_ch_ua = f'" Not;A Brand";v="{versions[0]}", "Chromium";v="{versions[0]}", "Google Chrome";v="{versions[0]}"'
|
|
106
|
+
elif 'Edg' in user_agent or 'EdgiOS' in user_agent:
|
|
107
|
+
sec_ch_ua = f'" Not;A Brand";v="{versions[0]}", "Chromium";v="{versions[0]}", "Microsoft Edge";v="{versions[0]}"'
|
|
108
|
+
elif 'Firefox' in user_agent:
|
|
109
|
+
sec_ch_ua = f'" Not;A Brand";v="{versions[0]}", "Firefox";v="{versions[0]}"'
|
|
110
|
+
elif 'Safari' in user_agent:
|
|
111
|
+
sec_ch_ua = f'" Not;A Brand";v="{versions[0]}", "Safari";v="{versions[0]}"'
|
|
112
|
+
else:
|
|
113
|
+
sec_ch_ua = f'" Not;A Brand";v="{versions[0]}"'
|
|
114
|
+
|
|
115
|
+
headers = {
|
|
116
|
+
'User-Agent': user_agent,
|
|
117
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
|
|
118
|
+
'Accept-Language': random.choice(['en-US', 'en-GB', 'fr-FR', 'es-ES', 'de-DE']),
|
|
119
|
+
'Accept-Encoding': 'gzip, deflate, br',
|
|
120
|
+
'Connection': 'keep-alive',
|
|
121
|
+
'Upgrade-Insecure-Requests': '1',
|
|
122
|
+
'Sec-Fetch-Dest': 'document',
|
|
123
|
+
'Sec-Fetch-Mode': 'navigate',
|
|
124
|
+
'Sec-Fetch-Site': 'none',
|
|
125
|
+
'Sec-Fetch-User': '?1',
|
|
126
|
+
'sec-ch-ua-mobile': '?1' if is_mobile else '?0',
|
|
127
|
+
'sec-ch-ua-platform': platform,
|
|
128
|
+
'sec-ch-ua': sec_ch_ua,
|
|
129
|
+
'sec-ch-ua-model': model
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if referer:
|
|
133
|
+
headers['Origin'] = referer
|
|
134
|
+
headers['Referer'] = referer
|
|
135
|
+
|
|
136
|
+
return headers
|
|
137
|
+
|
|
138
|
+
def get_headers() -> str:
|
|
139
|
+
"""
|
|
140
|
+
Generate a random user agent to use in HTTP requests.
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
- str: A random user agent string.
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
# Get a random user agent string from the user agent rotator
|
|
147
|
+
return str(ua.chrome)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# 26.03.24
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from logging.handlers import RotatingFileHandler
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Internal utilities
|
|
8
|
+
from StreamingCommunity.Src.Util._jsonConfig import config_manager
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Logger:
|
|
12
|
+
def __init__(self):
|
|
13
|
+
|
|
14
|
+
# Fetching configuration values
|
|
15
|
+
self.DEBUG_MODE = config_manager.get_bool("DEFAULT", "debug")
|
|
16
|
+
self.log_to_file = config_manager.get_bool("DEFAULT", "log_to_file")
|
|
17
|
+
self.log_file = config_manager.get("DEFAULT", "log_file") if self.log_to_file else None
|
|
18
|
+
|
|
19
|
+
logging.getLogger("httpx").setLevel(logging.WARNING)
|
|
20
|
+
logging.getLogger("httpcore").setLevel(logging.WARNING)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# Setting logging level based on DEBUG_MODE
|
|
24
|
+
if self.DEBUG_MODE:
|
|
25
|
+
logging.getLogger('root').setLevel(logging.DEBUG)
|
|
26
|
+
|
|
27
|
+
# Configure file logging if debug mode and logging to file are both enabled
|
|
28
|
+
if self.log_to_file:
|
|
29
|
+
self.configure_file_logging()
|
|
30
|
+
else:
|
|
31
|
+
|
|
32
|
+
# If DEBUG_MODE is False, set logging level to ERROR
|
|
33
|
+
logging.getLogger('root').setLevel(logging.ERROR)
|
|
34
|
+
|
|
35
|
+
# Configure console logging
|
|
36
|
+
self.configure_logging()
|
|
37
|
+
|
|
38
|
+
def configure_logging(self):
|
|
39
|
+
"""
|
|
40
|
+
Configure console logging.
|
|
41
|
+
"""
|
|
42
|
+
logging.basicConfig(level=logging.DEBUG, format='[%(filename)s:%(lineno)s - %(funcName)20s() ] %(asctime)s - %(levelname)s - %(message)s')
|
|
43
|
+
|
|
44
|
+
def configure_file_logging(self):
|
|
45
|
+
"""
|
|
46
|
+
Configure file logging if enabled.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
file_handler = RotatingFileHandler(self.log_file, maxBytes=10*1024*1024, backupCount=5)
|
|
50
|
+
file_handler.setLevel(logging.DEBUG)
|
|
51
|
+
formatter = logging.Formatter('[%(filename)s:%(lineno)s - %(funcName)20s() ] %(asctime)s - %(levelname)s - %(message)s')
|
|
52
|
+
file_handler.setFormatter(formatter)
|
|
53
|
+
logging.getLogger('').addHandler(file_handler)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# 3.12.23
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import platform
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Internal utilities
|
|
8
|
+
from StreamingCommunity.Src.Util.console import console
|
|
9
|
+
from StreamingCommunity.Src.Util._jsonConfig import config_manager
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# Variable
|
|
13
|
+
CLEAN = config_manager.get_bool('DEFAULT', 'clean_console')
|
|
14
|
+
SHOW = config_manager.get_bool('DEFAULT', 'show_message')
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def start_message():
|
|
18
|
+
"""
|
|
19
|
+
Display a start message.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
msg = r'''
|
|
23
|
+
|
|
24
|
+
_____ _ _ _____ _ _
|
|
25
|
+
/ ____| | (_) / ____| (_) |
|
|
26
|
+
| (___ | |_ _ __ ___ __ _ _ __ ___ _ _ __ __ _ | | ___ _ __ ___ _ __ ___ _ _ _ __ _| |_ _ _
|
|
27
|
+
\___ \| __| '__/ _ \/ _` | '_ ` _ \| | '_ \ / _` | | | / _ \| '_ ` _ \| '_ ` _ \| | | | '_ \| | __| | | |
|
|
28
|
+
____) | |_| | | __/ (_| | | | | | | | | | | (_| | | |___| (_) | | | | | | | | | | | |_| | | | | | |_| |_| |
|
|
29
|
+
|_____/ \__|_| \___|\__,_|_| |_| |_|_|_| |_|\__, | \_____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|_|\__|\__, |
|
|
30
|
+
__/ | __/ |
|
|
31
|
+
|___/ |___/
|
|
32
|
+
|
|
33
|
+
'''
|
|
34
|
+
|
|
35
|
+
if CLEAN:
|
|
36
|
+
if platform.system() == 'Windows':
|
|
37
|
+
os.system("cls")
|
|
38
|
+
else:
|
|
39
|
+
os.system("clear")
|
|
40
|
+
|
|
41
|
+
if SHOW:
|
|
42
|
+
console.print(f"[bold yellow]{msg}")
|
|
43
|
+
console.print(f"[magenta]Created by: Lovi\n")
|
|
44
|
+
|
|
45
|
+
row = "-" * console.width
|
|
46
|
+
console.print(f"[yellow]{row} \n")
|