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.

Files changed (97) hide show
  1. StreamingCommunity/Src/Api/Player/Helper/Vixcloud/js_parser.py +140 -0
  2. StreamingCommunity/Src/Api/Player/Helper/Vixcloud/util.py +166 -0
  3. StreamingCommunity/Src/Api/Player/ddl.py +89 -0
  4. StreamingCommunity/Src/Api/Player/maxstream.py +151 -0
  5. StreamingCommunity/Src/Api/Player/supervideo.py +194 -0
  6. StreamingCommunity/Src/Api/Player/vixcloud.py +212 -0
  7. StreamingCommunity/Src/Api/Site/1337xx/__init__.py +50 -0
  8. StreamingCommunity/Src/Api/Site/1337xx/costant.py +15 -0
  9. StreamingCommunity/Src/Api/Site/1337xx/site.py +84 -0
  10. StreamingCommunity/Src/Api/Site/1337xx/title.py +66 -0
  11. StreamingCommunity/Src/Api/Site/altadefinizione/__init__.py +50 -0
  12. StreamingCommunity/Src/Api/Site/altadefinizione/costant.py +15 -0
  13. StreamingCommunity/Src/Api/Site/altadefinizione/film.py +69 -0
  14. StreamingCommunity/Src/Api/Site/altadefinizione/site.py +86 -0
  15. StreamingCommunity/Src/Api/Site/animeunity/__init__.py +50 -0
  16. StreamingCommunity/Src/Api/Site/animeunity/anime.py +126 -0
  17. StreamingCommunity/Src/Api/Site/animeunity/costant.py +15 -0
  18. StreamingCommunity/Src/Api/Site/animeunity/film_serie.py +131 -0
  19. StreamingCommunity/Src/Api/Site/animeunity/site.py +165 -0
  20. StreamingCommunity/Src/Api/Site/animeunity/util/ScrapeSerie.py +97 -0
  21. StreamingCommunity/Src/Api/Site/bitsearch/__init__.py +51 -0
  22. StreamingCommunity/Src/Api/Site/bitsearch/costant.py +15 -0
  23. StreamingCommunity/Src/Api/Site/bitsearch/site.py +84 -0
  24. StreamingCommunity/Src/Api/Site/bitsearch/title.py +47 -0
  25. StreamingCommunity/Src/Api/Site/cb01new/__init__.py +51 -0
  26. StreamingCommunity/Src/Api/Site/cb01new/costant.py +15 -0
  27. StreamingCommunity/Src/Api/Site/cb01new/film.py +69 -0
  28. StreamingCommunity/Src/Api/Site/cb01new/site.py +74 -0
  29. StreamingCommunity/Src/Api/Site/ddlstreamitaly/Player/ScrapeSerie.py +83 -0
  30. StreamingCommunity/Src/Api/Site/ddlstreamitaly/__init__.py +57 -0
  31. StreamingCommunity/Src/Api/Site/ddlstreamitaly/costant.py +16 -0
  32. StreamingCommunity/Src/Api/Site/ddlstreamitaly/series.py +142 -0
  33. StreamingCommunity/Src/Api/Site/ddlstreamitaly/site.py +93 -0
  34. StreamingCommunity/Src/Api/Site/ddlstreamitaly/util/ScrapeSerie.py +83 -0
  35. StreamingCommunity/Src/Api/Site/guardaserie/Player/ScrapeSerie.py +110 -0
  36. StreamingCommunity/Src/Api/Site/guardaserie/__init__.py +52 -0
  37. StreamingCommunity/Src/Api/Site/guardaserie/costant.py +15 -0
  38. StreamingCommunity/Src/Api/Site/guardaserie/series.py +195 -0
  39. StreamingCommunity/Src/Api/Site/guardaserie/site.py +84 -0
  40. StreamingCommunity/Src/Api/Site/guardaserie/util/ScrapeSerie.py +110 -0
  41. StreamingCommunity/Src/Api/Site/mostraguarda/__init__.py +48 -0
  42. StreamingCommunity/Src/Api/Site/mostraguarda/costant.py +15 -0
  43. StreamingCommunity/Src/Api/Site/mostraguarda/film.py +94 -0
  44. StreamingCommunity/Src/Api/Site/piratebays/__init__.py +50 -0
  45. StreamingCommunity/Src/Api/Site/piratebays/costant.py +15 -0
  46. StreamingCommunity/Src/Api/Site/piratebays/site.py +89 -0
  47. StreamingCommunity/Src/Api/Site/piratebays/title.py +45 -0
  48. StreamingCommunity/Src/Api/Site/streamingcommunity/__init__.py +55 -0
  49. StreamingCommunity/Src/Api/Site/streamingcommunity/costant.py +15 -0
  50. StreamingCommunity/Src/Api/Site/streamingcommunity/film.py +70 -0
  51. StreamingCommunity/Src/Api/Site/streamingcommunity/series.py +203 -0
  52. StreamingCommunity/Src/Api/Site/streamingcommunity/site.py +126 -0
  53. StreamingCommunity/Src/Api/Site/streamingcommunity/util/ScrapeSerie.py +113 -0
  54. StreamingCommunity/Src/Api/Template/Class/SearchType.py +101 -0
  55. StreamingCommunity/Src/Api/Template/Util/__init__.py +5 -0
  56. StreamingCommunity/Src/Api/Template/Util/get_domain.py +137 -0
  57. StreamingCommunity/Src/Api/Template/Util/manage_ep.py +153 -0
  58. StreamingCommunity/Src/Api/Template/Util/recall_search.py +37 -0
  59. StreamingCommunity/Src/Api/Template/__init__.py +3 -0
  60. StreamingCommunity/Src/Api/Template/site.py +87 -0
  61. StreamingCommunity/Src/Lib/Downloader/HLS/downloader.py +968 -0
  62. StreamingCommunity/Src/Lib/Downloader/HLS/proxyes.py +110 -0
  63. StreamingCommunity/Src/Lib/Downloader/HLS/segments.py +540 -0
  64. StreamingCommunity/Src/Lib/Downloader/MP4/downloader.py +156 -0
  65. StreamingCommunity/Src/Lib/Downloader/TOR/downloader.py +222 -0
  66. StreamingCommunity/Src/Lib/Downloader/__init__.py +5 -0
  67. StreamingCommunity/Src/Lib/Driver/driver_1.py +76 -0
  68. StreamingCommunity/Src/Lib/FFmpeg/__init__.py +4 -0
  69. StreamingCommunity/Src/Lib/FFmpeg/capture.py +170 -0
  70. StreamingCommunity/Src/Lib/FFmpeg/command.py +292 -0
  71. StreamingCommunity/Src/Lib/FFmpeg/util.py +242 -0
  72. StreamingCommunity/Src/Lib/M3U8/__init__.py +6 -0
  73. StreamingCommunity/Src/Lib/M3U8/decryptor.py +129 -0
  74. StreamingCommunity/Src/Lib/M3U8/estimator.py +173 -0
  75. StreamingCommunity/Src/Lib/M3U8/parser.py +666 -0
  76. StreamingCommunity/Src/Lib/M3U8/url_fixer.py +52 -0
  77. StreamingCommunity/Src/Lib/TMBD/__init__.py +2 -0
  78. StreamingCommunity/Src/Lib/TMBD/obj_tmbd.py +39 -0
  79. StreamingCommunity/Src/Lib/TMBD/tmdb.py +346 -0
  80. StreamingCommunity/Src/Upload/update.py +64 -0
  81. StreamingCommunity/Src/Upload/version.py +5 -0
  82. StreamingCommunity/Src/Util/_jsonConfig.py +204 -0
  83. StreamingCommunity/Src/Util/call_stack.py +42 -0
  84. StreamingCommunity/Src/Util/color.py +20 -0
  85. StreamingCommunity/Src/Util/console.py +12 -0
  86. StreamingCommunity/Src/Util/headers.py +147 -0
  87. StreamingCommunity/Src/Util/logger.py +53 -0
  88. StreamingCommunity/Src/Util/message.py +46 -0
  89. StreamingCommunity/Src/Util/os.py +417 -0
  90. StreamingCommunity/Src/Util/table.py +163 -0
  91. StreamingCommunity/run.py +196 -0
  92. StreamingCommunity-1.7.6.dist-info/LICENSE +674 -0
  93. StreamingCommunity-1.7.6.dist-info/METADATA +348 -0
  94. StreamingCommunity-1.7.6.dist-info/RECORD +97 -0
  95. StreamingCommunity-1.7.6.dist-info/WHEEL +5 -0
  96. StreamingCommunity-1.7.6.dist-info/entry_points.txt +2 -0
  97. StreamingCommunity-1.7.6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,417 @@
1
+ # 24.01.24
2
+
3
+ import io
4
+ import os
5
+ import sys
6
+ import ssl
7
+ import time
8
+ import shutil
9
+ import hashlib
10
+ import logging
11
+ import platform
12
+ import unidecode
13
+ import importlib
14
+ import subprocess
15
+ import contextlib
16
+ import pathvalidate
17
+ import urllib.request
18
+ import importlib.metadata
19
+
20
+
21
+ # External library
22
+ import httpx
23
+
24
+
25
+ # Internal utilities
26
+ from StreamingCommunity.Src.Util.console import console
27
+
28
+
29
+ # Variable
30
+ OS_CONFIGURATIONS = {
31
+ 'windows': {
32
+ 'max_length': 255,
33
+ 'invalid_chars': '<>:"/\\|?*',
34
+ 'reserved_names': [
35
+ "CON", "PRN", "AUX", "NUL",
36
+ "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
37
+ "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9"
38
+ ],
39
+ 'max_path': 255
40
+ },
41
+ 'darwin': {
42
+ 'max_length': 4096,
43
+ 'invalid_chars': '/:',
44
+ 'reserved_names': [],
45
+ 'hidden_file_restriction': True
46
+ },
47
+ 'linux': {
48
+ 'max_length': 4096,
49
+ 'invalid_chars': '/\0',
50
+ 'reserved_names': []
51
+ }
52
+ }
53
+
54
+
55
+
56
+ class OsManager:
57
+ def __init__(self):
58
+ self.system = self._detect_system()
59
+ self.config = OS_CONFIGURATIONS.get(self.system, {})
60
+
61
+ def _detect_system(self) -> str:
62
+ """Detect and normalize operating system name."""
63
+ system = platform.system().lower()
64
+
65
+ if system in OS_CONFIGURATIONS:
66
+ return system
67
+
68
+ raise ValueError(f"Unsupported operating system: {system}")
69
+
70
+ def _process_filename(self, filename: str) -> str:
71
+ """
72
+ Comprehensively process filename with cross-platform considerations.
73
+
74
+ Args:
75
+ filename (str): Original filename.
76
+
77
+ Returns:
78
+ str: Processed filename.
79
+ """
80
+ # Preserve file extension
81
+ logging.info("_process_filename: ", filename)
82
+ name, ext = os.path.splitext(filename)
83
+
84
+ # Handle length restrictions
85
+ if len(name) > self.config['max_length']:
86
+ name = self._truncate_filename(name)
87
+
88
+ # Reconstruct filename
89
+ processed_filename = name + ext
90
+
91
+ return processed_filename
92
+
93
+ def _truncate_filename(self, name: str) -> str:
94
+ """
95
+ Truncate filename based on OS-specific rules.
96
+
97
+ Args:
98
+ name (str): Original filename.
99
+
100
+ Returns:
101
+ str: Truncated filename.
102
+ """
103
+ logging.info("_truncate_filename: ", name)
104
+
105
+ if self.system == 'windows':
106
+ return name[:self.config['max_length'] - 3] + '___'
107
+ elif self.system == 'darwin':
108
+ return name[:self.config['max_length']]
109
+ elif self.system == 'linux':
110
+ return name[:self.config['max_length'] - 2] + '___'
111
+
112
+ def get_sanitize_file(self, filename: str) -> str:
113
+ """
114
+ Sanitize filename using pathvalidate with unidecode.
115
+
116
+ Args:
117
+ filename (str): Original filename.
118
+
119
+ Returns:
120
+ str: Sanitized filename.
121
+ """
122
+ logging.info("get_sanitize_file: ", filename)
123
+
124
+ # Decode unicode characters and sanitize
125
+ decoded_filename = unidecode.unidecode(filename)
126
+ sanitized_filename = pathvalidate.sanitize_filename(decoded_filename)
127
+
128
+ # Truncate if necessary based on OS configuration
129
+ name, ext = os.path.splitext(sanitized_filename)
130
+ if len(name) > self.config['max_length']:
131
+ name = self._truncate_filename(name)
132
+
133
+ logging.info("return :", name + ext)
134
+ return name + ext
135
+
136
+ def get_sanitize_path(self, path: str) -> str:
137
+ """
138
+ Sanitize folder path using pathvalidate with unidecode.
139
+
140
+ Args:
141
+ path (str): Original folder path.
142
+
143
+ Returns:
144
+ str: Sanitized folder path.
145
+ """
146
+ logging.info("get_sanitize_file: ", path)
147
+
148
+ # Decode unicode characters and sanitize
149
+ decoded_path = unidecode.unidecode(path)
150
+ sanitized_path = pathvalidate.sanitize_filepath(decoded_path)
151
+
152
+ # Split path and process each component
153
+ path_components = os.path.normpath(sanitized_path).split(os.sep)
154
+ processed_components = []
155
+
156
+ for component in path_components:
157
+ # Truncate component if necessary
158
+ if len(component) > self.config['max_length']:
159
+ component = self._truncate_filename(component)
160
+ processed_components.append(component)
161
+
162
+ logging.info("return :", os.path.join(*processed_components))
163
+ return os.path.join(*processed_components)
164
+
165
+ def create_path(self, path: str, mode: int = 0o755) -> bool:
166
+ """
167
+ Create directory path with specified permissions.
168
+
169
+ Args:
170
+ path (str): Path to create.
171
+ mode (int, optional): Directory permissions. Defaults to 0o755.
172
+
173
+ Returns:
174
+ bool: True if path created successfully, False otherwise.
175
+ """
176
+ try:
177
+ # Sanitize path first
178
+ sanitized_path = self.get_sanitize_path(path)
179
+
180
+ # Create directory with recursive option
181
+ os.makedirs(sanitized_path, mode=mode, exist_ok=True)
182
+ return True
183
+
184
+ except Exception as e:
185
+ logging.error(f"Path creation error: {e}")
186
+ return False
187
+
188
+ def remove_folder(self, folder_path: str) -> bool:
189
+ """
190
+ Safely remove a folder.
191
+
192
+ Args:
193
+ folder_path (str): Path of directory to remove.
194
+
195
+ Returns:
196
+ bool: Removal status.
197
+ """
198
+ try:
199
+ shutil.rmtree(folder_path)
200
+ return True
201
+ except OSError as e:
202
+ logging.error(f"Folder removal error: {e}")
203
+ return False
204
+
205
+ def remove_files_except_one(self, folder_path: str, keep_file: str) -> None:
206
+ """
207
+ Delete all files in a folder except for one specified file.
208
+
209
+ Parameters:
210
+ - folder_path (str): The path to the folder containing the files.
211
+ - keep_file (str): The filename to keep in the folder.
212
+ """
213
+
214
+ try:
215
+ # List all files in the folder
216
+ files_in_folder = os.listdir(folder_path)
217
+
218
+ # Iterate over each file in the folder
219
+ for file_name in files_in_folder:
220
+ file_path = os.path.join(folder_path, file_name)
221
+
222
+ # Check if the file is not the one to keep and is a regular file
223
+ if file_name != keep_file and os.path.isfile(file_path):
224
+ os.remove(file_path) # Delete the file
225
+
226
+ except Exception as e:
227
+ logging.error(f"An error occurred: {e}")
228
+ raise
229
+
230
+ def check_file(self, file_path: str) -> bool:
231
+ """
232
+ Check if a file exists at the given file path.
233
+
234
+ Parameters:
235
+ file_path (str): The path to the file.
236
+
237
+ Returns:
238
+ bool: True if the file exists, False otherwise.
239
+ """
240
+ try:
241
+ logging.info(f"Check if file exists: {file_path}")
242
+ if os.path.exists(file_path):
243
+ logging.info(f"The file '{file_path}' exists.")
244
+ return True
245
+
246
+ else:
247
+ return False
248
+
249
+ except Exception as e:
250
+ logging.error(f"An error occurred while checking file existence: {e}")
251
+ return False
252
+
253
+
254
+ class InternManager():
255
+
256
+ def format_file_size(self, size_bytes: float) -> str:
257
+ """
258
+ Formats a file size from bytes into a human-readable string representation.
259
+
260
+ Parameters:
261
+ size_bytes (float): Size in bytes to be formatted.
262
+
263
+ Returns:
264
+ str: Formatted string representing the file size with appropriate unit (B, KB, MB, GB, TB).
265
+ """
266
+ if size_bytes <= 0:
267
+ return "0B"
268
+
269
+ units = ['B', 'KB', 'MB', 'GB', 'TB']
270
+ unit_index = 0
271
+
272
+ while size_bytes >= 1024 and unit_index < len(units) - 1:
273
+ size_bytes /= 1024
274
+ unit_index += 1
275
+
276
+ return f"{size_bytes:.2f} {units[unit_index]}"
277
+
278
+ def format_transfer_speed(self, bytes: float) -> str:
279
+ """
280
+ Formats a transfer speed from bytes per second into a human-readable string representation.
281
+
282
+ Parameters:
283
+ bytes (float): Speed in bytes per second to be formatted.
284
+
285
+ Returns:
286
+ str: Formatted string representing the transfer speed with appropriate unit (Bytes/s, KB/s, MB/s).
287
+ """
288
+ if bytes < 1024:
289
+ return f"{bytes:.2f} Bytes/s"
290
+ elif bytes < 1024 * 1024:
291
+ return f"{bytes / 1024:.2f} KB/s"
292
+ else:
293
+ return f"{bytes / (1024 * 1024):.2f} MB/s"
294
+
295
+ @staticmethod
296
+ def check_internet():
297
+ while True:
298
+ try:
299
+ httpx.get("https://www.google.com")
300
+ console.log("[bold green]Internet is available![/bold green]")
301
+ break
302
+
303
+ except urllib.error.URLError:
304
+ console.log("[bold red]Internet is not available. Waiting...[/bold red]")
305
+ time.sleep(5)
306
+
307
+ print()
308
+
309
+
310
+ class OsSummary():
311
+
312
+ def get_executable_version(self, command: list):
313
+ """
314
+ Get the version of a given command-line executable.
315
+
316
+ Args:
317
+ command (list): The command to run, e.g., `['ffmpeg', '-version']`.
318
+
319
+ Returns:
320
+ str: The version string of the executable.
321
+
322
+ Raises:
323
+ SystemExit: If the command is not found or fails to execute.
324
+ """
325
+
326
+ try:
327
+ version_output = subprocess.check_output(command, stderr=subprocess.STDOUT).decode().split('\n')[0]
328
+ return version_output.split(" ")[2]
329
+
330
+ except (FileNotFoundError, subprocess.CalledProcessError):
331
+ print(f"{command[0]} not found")
332
+ sys.exit(0)
333
+
334
+ def get_library_version(self, lib_name: str):
335
+ """
336
+ Retrieve the version of a Python library.
337
+
338
+ Args:
339
+ lib_name (str): The name of the Python library.
340
+
341
+ Returns:
342
+ str: The library name followed by its version, or `-not installed` if not found.
343
+ """
344
+
345
+ try:
346
+ version = importlib.metadata.version(lib_name)
347
+ return f"{lib_name}-{version}"
348
+
349
+ except importlib.metadata.PackageNotFoundError:
350
+ return f"{lib_name}-not installed"
351
+
352
+ def get_system_summary(self):
353
+ """
354
+ Generate a summary of the system environment.
355
+
356
+ Includes:
357
+ - Python version and implementation details.
358
+ - Operating system and architecture.
359
+ - Versions of `ffmpeg` and `ffprobe` executables.
360
+ - Installed Python libraries as listed in `requirements.txt`.
361
+ """
362
+
363
+ # Check internet connectivity
364
+ InternManager().check_internet()
365
+ console.print("[bold blue]System Summary[/bold blue][white]:")
366
+
367
+ # Python version and platform
368
+ python_version = sys.version.split()[0]
369
+ python_implementation = platform.python_implementation()
370
+ arch = platform.machine()
371
+ os_info = platform.platform()
372
+ glibc_version = 'glibc ' + '.'.join(map(str, platform.libc_ver()[1]))
373
+
374
+ console.print(f"[cyan]Python[white]: [bold red]{python_version} ({python_implementation} {arch}) - {os_info} ({glibc_version})[/bold red]")
375
+ logging.info(f"Python: {python_version} ({python_implementation} {arch}) - {os_info} ({glibc_version})")
376
+
377
+ # ffmpeg and ffprobe versions
378
+ ffmpeg_version = self.get_executable_version(['ffmpeg', '-version'])
379
+ ffprobe_version = self.get_executable_version(['ffprobe', '-version'])
380
+
381
+ console.print(f"[cyan]Exe versions[white]: [bold red]ffmpeg {ffmpeg_version}, ffprobe {ffprobe_version}[/bold red]")
382
+ logging.info(f"Dependencies: ffmpeg {ffmpeg_version}, ffprobe {ffprobe_version}")
383
+
384
+ # Optional libraries versions
385
+ """optional_libraries = [line.strip() for line in open('requirements.txt', 'r', encoding='utf-8-sig')]
386
+ optional_libs_versions = [self.get_library_version(lib) for lib in optional_libraries]
387
+
388
+ console.print(f"[cyan]Libraries[white]: [bold red]{', '.join(optional_libs_versions)}[/bold red]\n")
389
+ logging.info(f"Libraries: {', '.join(optional_libs_versions)}")"""
390
+
391
+
392
+
393
+ # OTHER
394
+ os_manager = OsManager()
395
+ internet_manager = InternManager()
396
+ os_summary = OsSummary()
397
+
398
+ @contextlib.contextmanager
399
+ def suppress_output():
400
+ with contextlib.redirect_stdout(io.StringIO()):
401
+ yield
402
+
403
+ def compute_sha1_hash(input_string: str) -> str:
404
+ """
405
+ Computes the SHA-1 hash of the input string.
406
+
407
+ Parameters:
408
+ - input_string (str): The string to be hashed.
409
+
410
+ Returns:
411
+ str: The SHA-1 hash of the input string.
412
+ """
413
+ # Compute the SHA-1 hash
414
+ hashed_string = hashlib.sha1(input_string.encode()).hexdigest()
415
+
416
+ # Return the hashed string
417
+ return hashed_string
@@ -0,0 +1,163 @@
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 = []