StreamingCommunity 1.9.1__py3-none-any.whl → 1.9.4__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.

Files changed (96) hide show
  1. StreamingCommunity/run.py +4 -5
  2. {StreamingCommunity-1.9.1.dist-info → StreamingCommunity-1.9.4.dist-info}/METADATA +37 -7
  3. StreamingCommunity-1.9.4.dist-info/RECORD +7 -0
  4. {StreamingCommunity-1.9.1.dist-info → StreamingCommunity-1.9.4.dist-info}/WHEEL +1 -1
  5. {StreamingCommunity-1.9.1.dist-info → StreamingCommunity-1.9.4.dist-info}/entry_points.txt +1 -0
  6. StreamingCommunity/Api/Player/Helper/Vixcloud/js_parser.py +0 -143
  7. StreamingCommunity/Api/Player/Helper/Vixcloud/util.py +0 -166
  8. StreamingCommunity/Api/Player/ddl.py +0 -89
  9. StreamingCommunity/Api/Player/maxstream.py +0 -151
  10. StreamingCommunity/Api/Player/supervideo.py +0 -194
  11. StreamingCommunity/Api/Player/vixcloud.py +0 -224
  12. StreamingCommunity/Api/Site/1337xx/__init__.py +0 -50
  13. StreamingCommunity/Api/Site/1337xx/costant.py +0 -15
  14. StreamingCommunity/Api/Site/1337xx/site.py +0 -84
  15. StreamingCommunity/Api/Site/1337xx/title.py +0 -66
  16. StreamingCommunity/Api/Site/altadefinizione/__init__.py +0 -50
  17. StreamingCommunity/Api/Site/altadefinizione/costant.py +0 -15
  18. StreamingCommunity/Api/Site/altadefinizione/film.py +0 -69
  19. StreamingCommunity/Api/Site/altadefinizione/site.py +0 -86
  20. StreamingCommunity/Api/Site/animeunity/__init__.py +0 -50
  21. StreamingCommunity/Api/Site/animeunity/costant.py +0 -15
  22. StreamingCommunity/Api/Site/animeunity/film_serie.py +0 -130
  23. StreamingCommunity/Api/Site/animeunity/site.py +0 -165
  24. StreamingCommunity/Api/Site/animeunity/util/ScrapeSerie.py +0 -97
  25. StreamingCommunity/Api/Site/bitsearch/__init__.py +0 -51
  26. StreamingCommunity/Api/Site/bitsearch/costant.py +0 -15
  27. StreamingCommunity/Api/Site/bitsearch/site.py +0 -84
  28. StreamingCommunity/Api/Site/bitsearch/title.py +0 -47
  29. StreamingCommunity/Api/Site/cb01new/__init__.py +0 -51
  30. StreamingCommunity/Api/Site/cb01new/costant.py +0 -15
  31. StreamingCommunity/Api/Site/cb01new/film.py +0 -69
  32. StreamingCommunity/Api/Site/cb01new/site.py +0 -74
  33. StreamingCommunity/Api/Site/ddlstreamitaly/__init__.py +0 -57
  34. StreamingCommunity/Api/Site/ddlstreamitaly/costant.py +0 -16
  35. StreamingCommunity/Api/Site/ddlstreamitaly/series.py +0 -141
  36. StreamingCommunity/Api/Site/ddlstreamitaly/site.py +0 -93
  37. StreamingCommunity/Api/Site/ddlstreamitaly/util/ScrapeSerie.py +0 -85
  38. StreamingCommunity/Api/Site/guardaserie/__init__.py +0 -52
  39. StreamingCommunity/Api/Site/guardaserie/costant.py +0 -15
  40. StreamingCommunity/Api/Site/guardaserie/series.py +0 -195
  41. StreamingCommunity/Api/Site/guardaserie/site.py +0 -84
  42. StreamingCommunity/Api/Site/guardaserie/util/ScrapeSerie.py +0 -110
  43. StreamingCommunity/Api/Site/mostraguarda/__init__.py +0 -48
  44. StreamingCommunity/Api/Site/mostraguarda/costant.py +0 -15
  45. StreamingCommunity/Api/Site/mostraguarda/film.py +0 -94
  46. StreamingCommunity/Api/Site/piratebays/__init__.py +0 -50
  47. StreamingCommunity/Api/Site/piratebays/costant.py +0 -15
  48. StreamingCommunity/Api/Site/piratebays/site.py +0 -89
  49. StreamingCommunity/Api/Site/piratebays/title.py +0 -45
  50. StreamingCommunity/Api/Site/streamingcommunity/__init__.py +0 -55
  51. StreamingCommunity/Api/Site/streamingcommunity/costant.py +0 -15
  52. StreamingCommunity/Api/Site/streamingcommunity/film.py +0 -70
  53. StreamingCommunity/Api/Site/streamingcommunity/series.py +0 -205
  54. StreamingCommunity/Api/Site/streamingcommunity/site.py +0 -126
  55. StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py +0 -113
  56. StreamingCommunity/Api/Template/Class/SearchType.py +0 -101
  57. StreamingCommunity/Api/Template/Util/__init__.py +0 -5
  58. StreamingCommunity/Api/Template/Util/get_domain.py +0 -137
  59. StreamingCommunity/Api/Template/Util/manage_ep.py +0 -153
  60. StreamingCommunity/Api/Template/Util/recall_search.py +0 -37
  61. StreamingCommunity/Api/Template/__init__.py +0 -3
  62. StreamingCommunity/Api/Template/site.py +0 -87
  63. StreamingCommunity/Lib/Downloader/HLS/downloader.py +0 -968
  64. StreamingCommunity/Lib/Downloader/HLS/proxyes.py +0 -110
  65. StreamingCommunity/Lib/Downloader/HLS/segments.py +0 -538
  66. StreamingCommunity/Lib/Downloader/MP4/downloader.py +0 -156
  67. StreamingCommunity/Lib/Downloader/TOR/downloader.py +0 -222
  68. StreamingCommunity/Lib/Downloader/__init__.py +0 -5
  69. StreamingCommunity/Lib/Driver/driver_1.py +0 -76
  70. StreamingCommunity/Lib/FFmpeg/__init__.py +0 -4
  71. StreamingCommunity/Lib/FFmpeg/capture.py +0 -170
  72. StreamingCommunity/Lib/FFmpeg/command.py +0 -292
  73. StreamingCommunity/Lib/FFmpeg/util.py +0 -242
  74. StreamingCommunity/Lib/M3U8/__init__.py +0 -6
  75. StreamingCommunity/Lib/M3U8/decryptor.py +0 -164
  76. StreamingCommunity/Lib/M3U8/estimator.py +0 -176
  77. StreamingCommunity/Lib/M3U8/parser.py +0 -666
  78. StreamingCommunity/Lib/M3U8/url_fixer.py +0 -52
  79. StreamingCommunity/Lib/TMBD/__init__.py +0 -2
  80. StreamingCommunity/Lib/TMBD/obj_tmbd.py +0 -39
  81. StreamingCommunity/Lib/TMBD/tmdb.py +0 -346
  82. StreamingCommunity/Upload/update.py +0 -68
  83. StreamingCommunity/Upload/version.py +0 -5
  84. StreamingCommunity/Util/_jsonConfig.py +0 -204
  85. StreamingCommunity/Util/call_stack.py +0 -42
  86. StreamingCommunity/Util/color.py +0 -20
  87. StreamingCommunity/Util/console.py +0 -12
  88. StreamingCommunity/Util/ffmpeg_installer.py +0 -275
  89. StreamingCommunity/Util/headers.py +0 -147
  90. StreamingCommunity/Util/logger.py +0 -53
  91. StreamingCommunity/Util/message.py +0 -46
  92. StreamingCommunity/Util/os.py +0 -514
  93. StreamingCommunity/Util/table.py +0 -163
  94. StreamingCommunity-1.9.1.dist-info/RECORD +0 -95
  95. {StreamingCommunity-1.9.1.dist-info → StreamingCommunity-1.9.4.dist-info}/LICENSE +0 -0
  96. {StreamingCommunity-1.9.1.dist-info → StreamingCommunity-1.9.4.dist-info}/top_level.txt +0 -0
@@ -1,514 +0,0 @@
1
- # 24.01.24
2
-
3
- import io
4
- import os
5
- import sys
6
- import time
7
- import shutil
8
- import hashlib
9
- import logging
10
- import platform
11
- import unidecode
12
- import subprocess
13
- import contextlib
14
- import pathvalidate
15
- import urllib.request
16
- import importlib.metadata
17
-
18
-
19
- # External library
20
- import httpx
21
-
22
-
23
- # Internal utilities
24
- from .ffmpeg_installer import check_ffmpeg
25
- from StreamingCommunity.Util.console import console, msg
26
-
27
-
28
- # Variable
29
- OS_CONFIGURATIONS = {
30
- 'windows': {
31
- 'max_length': 255,
32
- 'invalid_chars': '<>:"/\\|?*',
33
- 'reserved_names': [
34
- "CON", "PRN", "AUX", "NUL",
35
- "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
36
- "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"
37
- ],
38
- 'max_path': 255
39
- },
40
- 'darwin': {
41
- 'max_length': 4096,
42
- 'invalid_chars': '/:',
43
- 'reserved_names': [],
44
- 'hidden_file_restriction': True
45
- },
46
- 'linux': {
47
- 'max_length': 4096,
48
- 'invalid_chars': '/\0',
49
- 'reserved_names': []
50
- }
51
- }
52
-
53
-
54
-
55
- class OsManager:
56
- def __init__(self):
57
- self.system = self._detect_system()
58
- self.config = OS_CONFIGURATIONS.get(self.system, {})
59
-
60
- def _detect_system(self) -> str:
61
- """Detect and normalize operating system name."""
62
- system = platform.system().lower()
63
-
64
- if system in OS_CONFIGURATIONS:
65
- return system
66
-
67
- raise ValueError(f"Unsupported operating system: {system}")
68
-
69
- def _process_filename(self, filename: str) -> str:
70
- """
71
- Comprehensively process filename with cross-platform considerations.
72
-
73
- Args:
74
- filename (str): Original filename.
75
-
76
- Returns:
77
- str: Processed filename.
78
- """
79
- # Preserve file extension
80
- logging.info("_process_filename: ", filename)
81
- name, ext = os.path.splitext(filename)
82
-
83
- # Handle length restrictions
84
- if len(name) > self.config['max_length']:
85
- name = self._truncate_filename(name)
86
-
87
- # Reconstruct filename
88
- processed_filename = name + ext
89
-
90
- return processed_filename
91
-
92
- def _truncate_filename(self, name: str) -> str:
93
- """
94
- Truncate filename based on OS-specific rules.
95
-
96
- Args:
97
- name (str): Original filename.
98
-
99
- Returns:
100
- str: Truncated filename.
101
- """
102
- logging.info("_truncate_filename: ", name)
103
-
104
- if self.system == 'windows':
105
- return name[:self.config['max_length'] - 3] + '___'
106
- elif self.system == 'darwin':
107
- return name[:self.config['max_length']]
108
- elif self.system == 'linux':
109
- return name[:self.config['max_length'] - 2] + '___'
110
-
111
- def get_sanitize_file(self, filename: str) -> str:
112
- """
113
- Sanitize filename using pathvalidate with unidecode.
114
-
115
- Args:
116
- filename (str): Original filename.
117
-
118
- Returns:
119
- str: Sanitized filename.
120
- """
121
- logging.info("get_sanitize_file: ", filename)
122
-
123
- # Decode unicode characters and sanitize
124
- decoded_filename = unidecode.unidecode(filename)
125
- sanitized_filename = pathvalidate.sanitize_filename(decoded_filename)
126
-
127
- # Truncate if necessary based on OS configuration
128
- name, ext = os.path.splitext(sanitized_filename)
129
- if len(name) > self.config['max_length']:
130
- name = self._truncate_filename(name)
131
-
132
- logging.info("return :", name + ext)
133
- return name + ext
134
-
135
- def get_sanitize_path(self, path: str) -> str:
136
- """
137
- Sanitize folder path using pathvalidate with unidecode.
138
-
139
- Args:
140
- path (str): Original folder path.
141
-
142
- Returns:
143
- str: Sanitized folder path.
144
- """
145
- logging.info("get_sanitize_file: ", path)
146
-
147
- # Decode unicode characters and sanitize
148
- decoded_path = unidecode.unidecode(path)
149
- sanitized_path = pathvalidate.sanitize_filepath(decoded_path)
150
-
151
- # Split path and process each component
152
- path_components = os.path.normpath(sanitized_path).split(os.sep)
153
- processed_components = []
154
-
155
- for component in path_components:
156
- # Truncate component if necessary
157
- if len(component) > self.config['max_length']:
158
- component = self._truncate_filename(component)
159
- processed_components.append(component)
160
-
161
- logging.info("return :", os.path.join(*processed_components))
162
- return os.path.join(*processed_components)
163
-
164
- def create_path(self, path: str, mode: int = 0o755) -> bool:
165
- """
166
- Create directory path with specified permissions.
167
-
168
- Args:
169
- path (str): Path to create.
170
- mode (int, optional): Directory permissions. Defaults to 0o755.
171
-
172
- Returns:
173
- bool: True if path created successfully, False otherwise.
174
- """
175
- try:
176
- # Sanitize path first
177
- sanitized_path = self.get_sanitize_path(path)
178
-
179
- # Create directory with recursive option
180
- os.makedirs(sanitized_path, mode=mode, exist_ok=True)
181
- return True
182
-
183
- except Exception as e:
184
- logging.error(f"Path creation error: {e}")
185
- return False
186
-
187
- def remove_folder(self, folder_path: str) -> bool:
188
- """
189
- Safely remove a folder.
190
-
191
- Args:
192
- folder_path (str): Path of directory to remove.
193
-
194
- Returns:
195
- bool: Removal status.
196
- """
197
- try:
198
- shutil.rmtree(folder_path)
199
- return True
200
- except OSError as e:
201
- logging.error(f"Folder removal error: {e}")
202
- return False
203
-
204
- def remove_files_except_one(self, folder_path: str, keep_file: str) -> None:
205
- """
206
- Delete all files in a folder except for one specified file.
207
-
208
- Parameters:
209
- - folder_path (str): The path to the folder containing the files.
210
- - keep_file (str): The filename to keep in the folder.
211
- """
212
-
213
- try:
214
- # List all files in the folder
215
- files_in_folder = os.listdir(folder_path)
216
-
217
- # Iterate over each file in the folder
218
- for file_name in files_in_folder:
219
- file_path = os.path.join(folder_path, file_name)
220
-
221
- # Check if the file is not the one to keep and is a regular file
222
- if file_name != keep_file and os.path.isfile(file_path):
223
- os.remove(file_path) # Delete the file
224
-
225
- except Exception as e:
226
- logging.error(f"An error occurred: {e}")
227
- raise
228
-
229
- def check_file(self, file_path: str) -> bool:
230
- """
231
- Check if a file exists at the given file path.
232
-
233
- Parameters:
234
- file_path (str): The path to the file.
235
-
236
- Returns:
237
- bool: True if the file exists, False otherwise.
238
- """
239
- try:
240
- logging.info(f"Check if file exists: {file_path}")
241
- if os.path.exists(file_path):
242
- logging.info(f"The file '{file_path}' exists.")
243
- return True
244
-
245
- else:
246
- return False
247
-
248
- except Exception as e:
249
- logging.error(f"An error occurred while checking file existence: {e}")
250
- return False
251
-
252
-
253
- class InternManager():
254
-
255
- def format_file_size(self, size_bytes: float) -> str:
256
- """
257
- Formats a file size from bytes into a human-readable string representation.
258
-
259
- Parameters:
260
- size_bytes (float): Size in bytes to be formatted.
261
-
262
- Returns:
263
- str: Formatted string representing the file size with appropriate unit (B, KB, MB, GB, TB).
264
- """
265
- if size_bytes <= 0:
266
- return "0B"
267
-
268
- units = ['B', 'KB', 'MB', 'GB', 'TB']
269
- unit_index = 0
270
-
271
- while size_bytes >= 1024 and unit_index < len(units) - 1:
272
- size_bytes /= 1024
273
- unit_index += 1
274
-
275
- return f"{size_bytes:.2f} {units[unit_index]}"
276
-
277
- def format_transfer_speed(self, bytes: float) -> str:
278
- """
279
- Formats a transfer speed from bytes per second into a human-readable string representation.
280
-
281
- Parameters:
282
- bytes (float): Speed in bytes per second to be formatted.
283
-
284
- Returns:
285
- str: Formatted string representing the transfer speed with appropriate unit (Bytes/s, KB/s, MB/s).
286
- """
287
- if bytes < 1024:
288
- return f"{bytes:.2f} Bytes/s"
289
- elif bytes < 1024 * 1024:
290
- return f"{bytes / 1024:.2f} KB/s"
291
- else:
292
- return f"{bytes / (1024 * 1024):.2f} MB/s"
293
-
294
- @staticmethod
295
- def check_internet():
296
- while True:
297
- try:
298
- httpx.get("https://www.google.com")
299
- console.log("[bold green]Internet is available![/bold green]")
300
- break
301
-
302
- except urllib.error.URLError:
303
- console.log("[bold red]Internet is not available. Waiting...[/bold red]")
304
- time.sleep(5)
305
-
306
- print()
307
-
308
-
309
- class OsSummary():
310
-
311
- def get_executable_version(self, command: list):
312
- """
313
- Get the version of a given command-line executable.
314
-
315
- Args:
316
- command (list): The command to run, e.g., `['ffmpeg', '-version']`.
317
-
318
- Returns:
319
- str: The version string of the executable.
320
- """
321
- try:
322
- version_output = subprocess.check_output(command, stderr=subprocess.STDOUT).decode().split('\n')[0]
323
- return version_output.split(" ")[2]
324
-
325
- except (FileNotFoundError, subprocess.CalledProcessError):
326
- console.print(f"{command[0]} not found", style="bold red")
327
- sys.exit(0)
328
-
329
- def check_ffmpeg_location(self, command: list):
330
- """
331
- Run 'where ffmpeg' command to check FFmpeg's location.
332
-
333
- Returns:
334
- str: Location of FFmpeg executable or None if not found
335
- """
336
- try:
337
- result = subprocess.check_output(command, stderr=subprocess.STDOUT, text=True).strip()
338
- return result
339
-
340
- except subprocess.CalledProcessError:
341
- console.print("FFmpeg not found in system PATH", style="bold red")
342
- sys.exit(0)
343
-
344
- def get_library_version(self, lib_name: str):
345
- """
346
- Retrieve the version of a Python library.
347
-
348
- Args:
349
- lib_name (str): The name of the Python library.
350
-
351
- Returns:
352
- str: The library name followed by its version, or `-not installed` if not found.
353
- """
354
- try:
355
- version = importlib.metadata.version(lib_name)
356
- return f"{lib_name}-{version}"
357
-
358
- except importlib.metadata.PackageNotFoundError:
359
- return f"{lib_name}-not installed"
360
-
361
- def download_requirements(self, url: str, filename: str):
362
- """
363
- Download the requirements.txt file from the specified URL if not found locally using requests.
364
-
365
- Args:
366
- url (str): The URL to download the requirements file from.
367
- filename (str): The local filename to save the requirements file as.
368
- """
369
- try:
370
- import requests
371
-
372
- console.print(f"{filename} not found locally. Downloading from {url}...", style="bold yellow")
373
- response = requests.get(url)
374
-
375
- if response.status_code == 200:
376
- with open(filename, 'wb') as f:
377
- f.write(response.content)
378
- console.print(f"{filename} successfully downloaded.", style="bold green")
379
-
380
- else:
381
- console.print(f"Failed to download {filename}. HTTP Status code: {response.status_code}", style="bold red")
382
- sys.exit(1)
383
-
384
- except Exception as e:
385
- console.print(f"Failed to download {filename}: {e}", style="bold red")
386
- sys.exit(1)
387
-
388
- def install_library(self, lib_name: str):
389
- """
390
- Install a Python library using pip.
391
-
392
- Args:
393
- lib_name (str): The name of the library to install.
394
- """
395
- try:
396
- console.print(f"Installing {lib_name}...", style="bold yellow")
397
- subprocess.check_call([sys.executable, "-m", "pip", "install", lib_name])
398
- console.print(f"{lib_name} installed successfully!", style="bold green")
399
-
400
- except subprocess.CalledProcessError as e:
401
- console.print(f"Failed to install {lib_name}: {e}", style="bold red")
402
- sys.exit(1)
403
-
404
- def check_python_version(self):
405
- """
406
- Check if the installed Python is the official CPython distribution.
407
- Exits with a message if not the official version.
408
- """
409
- python_implementation = platform.python_implementation()
410
-
411
- if python_implementation != "CPython":
412
- console.print(f"[bold red]Warning: You are using a non-official Python distribution: {python_implementation}.[/bold red]")
413
- console.print("Please install the official Python from [bold blue]https://www.python.org[/bold blue] and try again.", style="bold yellow")
414
- sys.exit(0)
415
-
416
- async def get_system_summary(self):
417
- """
418
- Generate a summary of the system environment.
419
-
420
- Includes:
421
- - Python version and implementation details.
422
- - Operating system and architecture.
423
- - Versions of `ffmpeg` and `ffprobe` executables.
424
- - Installed Python libraries as listed in `requirements.txt`.
425
- """
426
-
427
- # Check if Python is the official CPython
428
- self.check_python_version()
429
-
430
- # Check internet connectivity
431
- InternManager().check_internet()
432
- console.print("[bold blue]System Summary[/bold blue][white]:")
433
-
434
- # Python version and platform
435
- python_version = sys.version.split()[0]
436
- python_implementation = platform.python_implementation()
437
- arch = platform.machine()
438
- os_info = platform.platform()
439
- glibc_version = 'glibc ' + '.'.join(map(str, platform.libc_ver()[1]))
440
-
441
- console.print(f"[cyan]Python[white]: [bold red]{python_version} ({python_implementation} {arch}) - {os_info} ({glibc_version})[/bold red]")
442
- logging.info(f"Python: {python_version} ({python_implementation} {arch}) - {os_info} ({glibc_version})")
443
-
444
- # ffmpeg and ffprobe versions
445
- ffmpeg_path, ffprobe_path = check_ffmpeg()
446
-
447
- # Locate ffmpeg and ffprobe
448
- if "binary" not in ffmpeg_path:
449
- ffmpeg_path = self.check_ffmpeg_location(['where', 'ffmpeg'])
450
- if "binary" not in ffprobe_path:
451
- ffprobe_path = self.check_ffmpeg_location(['where', 'ffprobe'])
452
-
453
- ffmpeg_version = self.get_executable_version([ffprobe_path, '-version'])
454
- ffprobe_version = self.get_executable_version([ffprobe_path, '-version'])
455
-
456
- console.print(f"[cyan]Path[white]: [red]ffmpeg [bold yellow]'{ffmpeg_path}'[/bold yellow][white], [red]ffprobe '[bold yellow]{ffprobe_path}'[/bold yellow]")
457
- console.print(f"[cyan]Exe versions[white]: [bold red]ffmpeg {ffmpeg_version}, ffprobe {ffprobe_version}[/bold red]")
458
-
459
- # Check if requirements.txt exists, if not on pyinstaller
460
- if not getattr(sys, 'frozen', False):
461
- requirements_file = 'requirements.txt'
462
-
463
- if not os.path.exists(requirements_file):
464
- self.download_requirements(
465
- 'https://raw.githubusercontent.com/Lovi-0/StreamingCommunity/refs/heads/main/requirements.txt',
466
- requirements_file
467
- )
468
-
469
- # Read the optional libraries from the requirements file, get only name without version if "library==1.0.0"
470
- optional_libraries = [line.strip().split("=")[0] for line in open(requirements_file, 'r', encoding='utf-8-sig')]
471
-
472
- # Check if libraries are installed and prompt to install missing ones
473
- for lib in optional_libraries:
474
- installed_version = self.get_library_version(lib)
475
-
476
- if 'not installed' in installed_version:
477
- user_response = msg.ask(f"{lib} is not installed. Do you want to install it? (yes/no)", default="y")
478
-
479
- if user_response.lower().strip() in ["yes", "y"]:
480
- self.install_library(lib)
481
-
482
- else:
483
- logging.info(f"Library: {installed_version}")
484
-
485
- console.print(f"[cyan]Libraries[white]: [bold red]{', '.join([self.get_library_version(lib) for lib in optional_libraries])}[/bold red]\n")
486
- logging.info(f"Libraries: {', '.join([self.get_library_version(lib) for lib in optional_libraries])}")
487
-
488
-
489
-
490
- # OTHER
491
- os_manager = OsManager()
492
- internet_manager = InternManager()
493
- os_summary = OsSummary()
494
-
495
- @contextlib.contextmanager
496
- def suppress_output():
497
- with contextlib.redirect_stdout(io.StringIO()):
498
- yield
499
-
500
- def compute_sha1_hash(input_string: str) -> str:
501
- """
502
- Computes the SHA-1 hash of the input string.
503
-
504
- Parameters:
505
- - input_string (str): The string to be hashed.
506
-
507
- Returns:
508
- str: The SHA-1 hash of the input string.
509
- """
510
- # Compute the SHA-1 hash
511
- hashed_string = hashlib.sha1(input_string.encode()).hexdigest()
512
-
513
- # Return the hashed string
514
- return hashed_string
@@ -1,163 +0,0 @@
1
- # 03.03.24
2
-
3
- from rich.console import Console
4
- from rich.table import Table
5
- from rich.prompt import Prompt
6
- from rich.style import Style
7
- from typing import Dict, List, Any
8
-
9
-
10
- # Internal utilities
11
- from .message import start_message
12
-
13
-
14
- class TVShowManager:
15
- def __init__(self):
16
- """
17
- Initialize TVShowManager with provided column information.
18
-
19
- Parameters:
20
- - column_info (Dict[str, Dict[str, str]]): Dictionary containing column names, their colors, and justification.
21
- """
22
- self.console = Console()
23
- self.tv_shows: List[Dict[str, Any]] = [] # List to store TV show data as dictionaries
24
- self.slice_start: int = 0
25
- self.slice_end: int = 5
26
- self.step: int = self.slice_end
27
- self.column_info = []
28
-
29
- def set_slice_end(self, new_slice: int) -> None:
30
- """
31
- Set the end of the slice for displaying TV shows.
32
-
33
- Parameters:
34
- - new_slice (int): The new value for the slice end.
35
- """
36
- self.slice_end = new_slice
37
- self.step = new_slice
38
-
39
- def add_column(self, column_info: Dict[str, Dict[str, str]]) -> None:
40
- """
41
- Add column information.
42
-
43
- Parameters:
44
- - column_info (Dict[str, Dict[str, str]]): Dictionary containing column names, their colors, and justification.
45
- """
46
- self.column_info = column_info
47
-
48
- def add_tv_show(self, tv_show: Dict[str, Any]):
49
- """
50
- Add a TV show to the list of TV shows.
51
-
52
- Parameters:
53
- - tv_show (Dict[str, Any]): Dictionary containing TV show details.
54
- """
55
- self.tv_shows.append(tv_show)
56
-
57
- def display_data(self, data_slice: List[Dict[str, Any]]):
58
- """
59
- Display TV show data in a tabular format.
60
-
61
- Parameters:
62
- - data_slice (List[Dict[str, Any]]): List of dictionaries containing TV show details to display.
63
- """
64
- table = Table(border_style="white")
65
-
66
- # Add columns dynamically based on provided column information
67
- for col_name, col_style in self.column_info.items():
68
- color = col_style.get("color", None)
69
- if color:
70
- style = Style(color=color)
71
- else:
72
- style = None
73
- table.add_column(col_name, style=style, justify='center')
74
-
75
- # Add rows dynamically based on available TV show data
76
- for entry in data_slice:
77
- # Create row data while handling missing keys
78
- row_data = [entry.get(col_name, '') for col_name in self.column_info.keys()]
79
- table.add_row(*row_data)
80
-
81
- self.console.print(table) # Use self.console.print instead of print
82
-
83
-
84
- def run(self, force_int_input: bool = False, max_int_input: int = 0) -> str:
85
- """
86
- Run the TV show manager application.
87
-
88
- Parameters:
89
- - force_int_input(bool): If True, only accept integer inputs from 0 to max_int_input
90
- - max_int_input (int): range of row to show
91
-
92
- Returns:
93
- str: Last command executed before breaking out of the loop.
94
- """
95
- total_items = len(self.tv_shows)
96
- last_command = "" # Variable to store the last command executed
97
-
98
- while True:
99
- start_message()
100
-
101
- # Display table
102
- self.display_data(self.tv_shows[self.slice_start:self.slice_end])
103
-
104
- # Handling user input for loading more items or quitting
105
- if self.slice_end < total_items:
106
- self.console.print(f"\n\n[yellow][INFO] [green]Press [red]Enter [green]for next page, or [red]'q' [green]to quit.")
107
-
108
- if not force_int_input:
109
- key = Prompt.ask(
110
- "\n[cyan]Insert media index [yellow](e.g., 1), [red]* [cyan]to download all media, "
111
- "[yellow](e.g., 1-2) [cyan]for a range of media, or [yellow](e.g., 3-*) [cyan]to download from a specific index to the end"
112
- )
113
-
114
- else:
115
- choices = [str(i) for i in range(0, max_int_input)]
116
- choices.extend(["q", ""])
117
-
118
- key = Prompt.ask("[cyan]Insert media [red]index", choices=choices, show_choices=False)
119
- last_command = key
120
-
121
- if key.lower() == "q":
122
- break
123
-
124
- elif key == "":
125
- self.slice_start += self.step
126
- self.slice_end += self.step
127
- if self.slice_end > total_items:
128
- self.slice_end = total_items
129
-
130
- else:
131
- break
132
-
133
- else:
134
- # Last slice, ensure all remaining items are shown
135
- self.console.print(f"\n\n[yellow][INFO] [red]You've reached the end. [green]Press [red]Enter [green]for next page, or [red]'q' [green]to quit.")
136
- if not force_int_input:
137
- key = Prompt.ask(
138
- "\n[cyan]Insert media index [yellow](e.g., 1), [red]* [cyan]to download all media, "
139
- "[yellow](e.g., 1-2) [cyan]for a range of media, or [yellow](e.g., 3-*) [cyan]to download from a specific index to the end"
140
- )
141
-
142
-
143
- else:
144
- choices = [str(i) for i in range(0, max_int_input)]
145
- choices.extend(["q", ""])
146
-
147
- key = Prompt.ask("[cyan]Insert media [red]index", choices=choices, show_choices=False)
148
- last_command = key
149
-
150
- if key.lower() == "q":
151
- break
152
-
153
- elif key == "":
154
- self.slice_start = 0
155
- self.slice_end = self.step
156
-
157
- else:
158
- break
159
-
160
- return last_command
161
-
162
- def clear(self):
163
- self.tv_shows = []