StreamingCommunity 1.9.5__py3-none-any.whl → 1.9.90__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 (93) hide show
  1. StreamingCommunity/Api/Player/Helper/Vixcloud/js_parser.py +143 -0
  2. StreamingCommunity/Api/Player/Helper/Vixcloud/util.py +145 -0
  3. StreamingCommunity/Api/Player/ddl.py +89 -0
  4. StreamingCommunity/Api/Player/maxstream.py +151 -0
  5. StreamingCommunity/Api/Player/supervideo.py +194 -0
  6. StreamingCommunity/Api/Player/vixcloud.py +273 -0
  7. StreamingCommunity/Api/Site/1337xx/__init__.py +51 -0
  8. StreamingCommunity/Api/Site/1337xx/costant.py +15 -0
  9. StreamingCommunity/Api/Site/1337xx/site.py +86 -0
  10. StreamingCommunity/Api/Site/1337xx/title.py +66 -0
  11. StreamingCommunity/Api/Site/altadefinizione/__init__.py +51 -0
  12. StreamingCommunity/Api/Site/altadefinizione/costant.py +15 -0
  13. StreamingCommunity/Api/Site/altadefinizione/film.py +74 -0
  14. StreamingCommunity/Api/Site/altadefinizione/site.py +89 -0
  15. StreamingCommunity/Api/Site/animeunity/__init__.py +51 -0
  16. StreamingCommunity/Api/Site/animeunity/costant.py +15 -0
  17. StreamingCommunity/Api/Site/animeunity/film_serie.py +135 -0
  18. StreamingCommunity/Api/Site/animeunity/site.py +167 -0
  19. StreamingCommunity/Api/Site/animeunity/util/ScrapeSerie.py +97 -0
  20. StreamingCommunity/Api/Site/cb01new/__init__.py +52 -0
  21. StreamingCommunity/Api/Site/cb01new/costant.py +15 -0
  22. StreamingCommunity/Api/Site/cb01new/film.py +73 -0
  23. StreamingCommunity/Api/Site/cb01new/site.py +76 -0
  24. StreamingCommunity/Api/Site/ddlstreamitaly/__init__.py +58 -0
  25. StreamingCommunity/Api/Site/ddlstreamitaly/costant.py +16 -0
  26. StreamingCommunity/Api/Site/ddlstreamitaly/series.py +146 -0
  27. StreamingCommunity/Api/Site/ddlstreamitaly/site.py +95 -0
  28. StreamingCommunity/Api/Site/ddlstreamitaly/util/ScrapeSerie.py +85 -0
  29. StreamingCommunity/Api/Site/guardaserie/__init__.py +53 -0
  30. StreamingCommunity/Api/Site/guardaserie/costant.py +15 -0
  31. StreamingCommunity/Api/Site/guardaserie/series.py +199 -0
  32. StreamingCommunity/Api/Site/guardaserie/site.py +86 -0
  33. StreamingCommunity/Api/Site/guardaserie/util/ScrapeSerie.py +110 -0
  34. StreamingCommunity/Api/Site/ilcorsaronero/__init__.py +52 -0
  35. StreamingCommunity/Api/Site/ilcorsaronero/costant.py +15 -0
  36. StreamingCommunity/Api/Site/ilcorsaronero/site.py +63 -0
  37. StreamingCommunity/Api/Site/ilcorsaronero/title.py +46 -0
  38. StreamingCommunity/Api/Site/ilcorsaronero/util/ilCorsarScraper.py +141 -0
  39. StreamingCommunity/Api/Site/mostraguarda/__init__.py +49 -0
  40. StreamingCommunity/Api/Site/mostraguarda/costant.py +15 -0
  41. StreamingCommunity/Api/Site/mostraguarda/film.py +99 -0
  42. StreamingCommunity/Api/Site/streamingcommunity/__init__.py +56 -0
  43. StreamingCommunity/Api/Site/streamingcommunity/costant.py +15 -0
  44. StreamingCommunity/Api/Site/streamingcommunity/film.py +75 -0
  45. StreamingCommunity/Api/Site/streamingcommunity/series.py +206 -0
  46. StreamingCommunity/Api/Site/streamingcommunity/site.py +137 -0
  47. StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py +123 -0
  48. StreamingCommunity/Api/Template/Class/SearchType.py +101 -0
  49. StreamingCommunity/Api/Template/Util/__init__.py +5 -0
  50. StreamingCommunity/Api/Template/Util/get_domain.py +173 -0
  51. StreamingCommunity/Api/Template/Util/manage_ep.py +179 -0
  52. StreamingCommunity/Api/Template/Util/recall_search.py +37 -0
  53. StreamingCommunity/Api/Template/__init__.py +3 -0
  54. StreamingCommunity/Api/Template/site.py +87 -0
  55. StreamingCommunity/Lib/Downloader/HLS/downloader.py +946 -0
  56. StreamingCommunity/Lib/Downloader/HLS/proxyes.py +110 -0
  57. StreamingCommunity/Lib/Downloader/HLS/segments.py +561 -0
  58. StreamingCommunity/Lib/Downloader/MP4/downloader.py +155 -0
  59. StreamingCommunity/Lib/Downloader/TOR/downloader.py +296 -0
  60. StreamingCommunity/Lib/Downloader/__init__.py +5 -0
  61. StreamingCommunity/Lib/FFmpeg/__init__.py +4 -0
  62. StreamingCommunity/Lib/FFmpeg/capture.py +170 -0
  63. StreamingCommunity/Lib/FFmpeg/command.py +296 -0
  64. StreamingCommunity/Lib/FFmpeg/util.py +249 -0
  65. StreamingCommunity/Lib/M3U8/__init__.py +6 -0
  66. StreamingCommunity/Lib/M3U8/decryptor.py +164 -0
  67. StreamingCommunity/Lib/M3U8/estimator.py +176 -0
  68. StreamingCommunity/Lib/M3U8/parser.py +666 -0
  69. StreamingCommunity/Lib/M3U8/url_fixer.py +52 -0
  70. StreamingCommunity/Lib/TMBD/__init__.py +2 -0
  71. StreamingCommunity/Lib/TMBD/obj_tmbd.py +39 -0
  72. StreamingCommunity/Lib/TMBD/tmdb.py +346 -0
  73. StreamingCommunity/Upload/update.py +68 -0
  74. StreamingCommunity/Upload/version.py +5 -0
  75. StreamingCommunity/Util/_jsonConfig.py +204 -0
  76. StreamingCommunity/Util/call_stack.py +42 -0
  77. StreamingCommunity/Util/color.py +20 -0
  78. StreamingCommunity/Util/console.py +12 -0
  79. StreamingCommunity/Util/ffmpeg_installer.py +311 -0
  80. StreamingCommunity/Util/headers.py +147 -0
  81. StreamingCommunity/Util/logger.py +53 -0
  82. StreamingCommunity/Util/message.py +64 -0
  83. StreamingCommunity/Util/os.py +554 -0
  84. StreamingCommunity/Util/table.py +229 -0
  85. StreamingCommunity/__init__.py +0 -0
  86. StreamingCommunity/run.py +2 -11
  87. {StreamingCommunity-1.9.5.dist-info → StreamingCommunity-1.9.90.dist-info}/METADATA +10 -27
  88. StreamingCommunity-1.9.90.dist-info/RECORD +92 -0
  89. {StreamingCommunity-1.9.5.dist-info → StreamingCommunity-1.9.90.dist-info}/WHEEL +1 -1
  90. {StreamingCommunity-1.9.5.dist-info → StreamingCommunity-1.9.90.dist-info}/entry_points.txt +0 -1
  91. StreamingCommunity-1.9.5.dist-info/RECORD +0 -7
  92. {StreamingCommunity-1.9.5.dist-info → StreamingCommunity-1.9.90.dist-info}/LICENSE +0 -0
  93. {StreamingCommunity-1.9.5.dist-info → StreamingCommunity-1.9.90.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,164 @@
1
+ # 03.04.24
2
+
3
+ import sys
4
+ import time
5
+ import logging
6
+ import subprocess
7
+ import importlib.util
8
+
9
+
10
+ # Internal utilities
11
+ from StreamingCommunity.Util.console import console
12
+
13
+
14
+ # Check if Crypto module is installed
15
+ crypto_spec = importlib.util.find_spec("Cryptodome")
16
+ crypto_installed = crypto_spec is not None
17
+
18
+
19
+ if crypto_installed:
20
+ console.print("[cyan]Decrypy use: Cryptodomex")
21
+ from Cryptodome.Cipher import AES
22
+ from Cryptodome.Util.Padding import unpad
23
+
24
+ class M3U8_Decryption:
25
+ """
26
+ Class for decrypting M3U8 playlist content using AES encryption when the Crypto module is available.
27
+ """
28
+ def __init__(self, key: bytes, iv: bytes, method: str) -> None:
29
+ """
30
+ Initialize the M3U8_Decryption object.
31
+
32
+ Parameters:
33
+ - key (bytes): The encryption key.
34
+ - iv (bytes): The initialization vector (IV).
35
+ - method (str): The encryption method.
36
+ """
37
+ self.key = key
38
+ self.iv = iv
39
+ if "0x" in str(iv):
40
+ self.iv = bytes.fromhex(iv.replace("0x", ""))
41
+ self.method = method
42
+
43
+ # Precreate cipher based on encryption method
44
+ if self.method == "AES":
45
+ self.cipher = AES.new(self.key, AES.MODE_ECB)
46
+ elif self.method == "AES-128":
47
+ self.cipher = AES.new(self.key[:16], AES.MODE_CBC, iv=self.iv)
48
+ elif self.method == "AES-128-CTR":
49
+ self.cipher = AES.new(self.key[:16], AES.MODE_CTR, nonce=self.iv)
50
+ else:
51
+ raise ValueError("Invalid or unsupported method")
52
+
53
+ def decrypt(self, ciphertext: bytes) -> bytes:
54
+ """
55
+ Decrypt the ciphertext using the specified encryption method.
56
+
57
+ Parameters:
58
+ - ciphertext (bytes): The encrypted content to decrypt.
59
+
60
+ Returns:
61
+ bytes: The decrypted content.
62
+ """
63
+ start = time.perf_counter_ns()
64
+
65
+ # Decrypt based on encryption method
66
+ if self.method in {"AES", "AES-128"}:
67
+ decrypted_data = self.cipher.decrypt(ciphertext)
68
+ decrypted_content = unpad(decrypted_data, AES.block_size)
69
+
70
+ elif self.method == "AES-128-CTR":
71
+ decrypted_content = self.cipher.decrypt(ciphertext)
72
+ else:
73
+ raise ValueError("Invalid or unsupported method")
74
+
75
+ end = time.perf_counter_ns()
76
+
77
+ # Calculate elapsed time with high precision
78
+ elapsed_nanoseconds = end - start
79
+ elapsed_milliseconds = elapsed_nanoseconds / 1_000_000
80
+ elapsed_seconds = elapsed_nanoseconds / 1_000_000_000
81
+
82
+ # Print performance metrics
83
+ logging.info(f"[Crypto Decryption Performance]")
84
+ logging.info(f"Method: {self.method}")
85
+ logging.info(f"Decryption Time: {elapsed_milliseconds:.4f} ms ({elapsed_seconds:.6f} s)")
86
+ logging.info(f"Decrypted Content Length: {len(decrypted_content)} bytes")
87
+
88
+ return decrypted_content
89
+
90
+
91
+ else:
92
+
93
+ # Check if openssl command is available
94
+ try:
95
+ openssl_available = subprocess.run(["openssl", "version"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0
96
+ console.print("[cyan]Decrypy use: OPENSSL")
97
+ except:
98
+ openssl_available = False
99
+
100
+ if not openssl_available:
101
+ console.log("[red]Neither python library: pycryptodomex nor openssl software is installed. Please install either one of them. Read readme.md [Requirement].")
102
+ sys.exit(0)
103
+
104
+ class M3U8_Decryption:
105
+ """
106
+ Class for decrypting M3U8 playlist content using OpenSSL when the Crypto module is not available.
107
+ """
108
+ def __init__(self, key: bytes, iv: bytes, method: str) -> None:
109
+ """
110
+ Initialize the M3U8_Decryption object.
111
+
112
+ Parameters:
113
+ - key (bytes): The encryption key.
114
+ - iv (bytes): The initialization vector (IV).
115
+ - method (str): The encryption method.
116
+ """
117
+ self.key = key
118
+ self.iv = iv
119
+ if "0x" in str(iv):
120
+ self.iv = bytes.fromhex(iv.replace("0x", ""))
121
+ self.method = method
122
+ logging.info(f"Decrypt add: ('key': {self.key}, 'iv': {self.iv}, 'method': {self.method})")
123
+
124
+ def decrypt(self, ciphertext: bytes) -> bytes:
125
+ """
126
+ Decrypt the ciphertext using the specified encryption method.
127
+
128
+ Parameters:
129
+ - ciphertext (bytes): The encrypted content to decrypt.
130
+
131
+ Returns:
132
+ bytes: The decrypted content.
133
+ """
134
+ start = time.perf_counter_ns()
135
+
136
+ # Construct OpenSSL command based on encryption method
137
+ if self.method == "AES":
138
+ openssl_cmd = f'openssl enc -d -aes-256-ecb -K {self.key.hex()} -nosalt'
139
+ elif self.method == "AES-128":
140
+ openssl_cmd = f'openssl enc -d -aes-128-cbc -K {self.key[:16].hex()} -iv {self.iv.hex()}'
141
+ elif self.method == "AES-128-CTR":
142
+ openssl_cmd = f'openssl enc -d -aes-128-ctr -K {self.key[:16].hex()} -iv {self.iv.hex()}'
143
+ else:
144
+ raise ValueError("Invalid or unsupported method")
145
+
146
+ try:
147
+ decrypted_content = subprocess.check_output(openssl_cmd.split(), input=ciphertext, stderr=subprocess.STDOUT)
148
+ except subprocess.CalledProcessError as e:
149
+ raise ValueError(f"Decryption failed: {e.output.decode()}")
150
+
151
+ end = time.perf_counter_ns()
152
+
153
+ # Calculate elapsed time with high precision
154
+ elapsed_nanoseconds = end - start
155
+ elapsed_milliseconds = elapsed_nanoseconds / 1_000_000
156
+ elapsed_seconds = elapsed_nanoseconds / 1_000_000_000
157
+
158
+ # Print performance metrics
159
+ logging.info(f"[OpenSSL Decryption Performance]")
160
+ logging.info(f"Method: {self.method}")
161
+ logging.info(f"Decryption Time: {elapsed_milliseconds:.4f} ms ({elapsed_seconds:.6f} s)")
162
+ logging.info(f"Decrypted Content Length: {len(decrypted_content)} bytes")
163
+
164
+ return decrypted_content
@@ -0,0 +1,176 @@
1
+ # 20.02.24
2
+
3
+ import os
4
+ import time
5
+ import logging
6
+ import threading
7
+ from collections import deque
8
+
9
+
10
+ # External libraries
11
+ import psutil
12
+ from tqdm import tqdm
13
+
14
+
15
+ # Internal utilities
16
+ from StreamingCommunity.Util.color import Colors
17
+ from StreamingCommunity.Util.os import internet_manager
18
+ from StreamingCommunity.Util._jsonConfig import config_manager
19
+
20
+
21
+ # Variable
22
+ TQDM_USE_LARGE_BAR = config_manager.get_int('M3U8_DOWNLOAD', 'tqdm_use_large_bar')
23
+
24
+
25
+ class M3U8_Ts_Estimator:
26
+ def __init__(self, total_segments: int):
27
+ """
28
+ Initialize the M3U8_Ts_Estimator object.
29
+
30
+ Parameters:
31
+ - total_segments (int): Length of total segments to download.
32
+ """
33
+ self.ts_file_sizes = []
34
+ self.now_downloaded_size = 0
35
+ self.total_segments = total_segments
36
+ self.lock = threading.Lock()
37
+ self.speed = {"upload": "N/A", "download": "N/A"} # Default to N/A
38
+ self.speed_thread = threading.Thread(target=self.capture_speed)
39
+ self.speed_thread.daemon = True
40
+ self.speed_thread.start()
41
+
42
+ def add_ts_file(self, size: int, size_download: int, duration: float):
43
+ """
44
+ Add a file size to the list of file sizes.
45
+
46
+ Parameters:
47
+ - size (int): The size of the ts file to be added.
48
+ - size_download (int): Single size of the ts file.
49
+ - duration (float): Time to download segment file.
50
+ """
51
+ if size <= 0 or size_download <= 0 or duration <= 0:
52
+ logging.error("Invalid input values: size=%d, size_download=%d, duration=%f", size, size_download, duration)
53
+ return
54
+
55
+ # Add total size bytes
56
+ self.ts_file_sizes.append(size)
57
+ self.now_downloaded_size += size_download
58
+
59
+ def capture_speed(self, interval: float = 1):
60
+ """
61
+ Capture the internet speed periodically and store the values.
62
+ """
63
+ def get_network_io():
64
+ """Get network I/O counters, handle missing psutil gracefully."""
65
+ try:
66
+ io_counters = psutil.net_io_counters()
67
+ return io_counters
68
+
69
+ except Exception as e:
70
+ logging.warning(f"Unable to access network I/O counters: {e}")
71
+ return None
72
+
73
+ while True:
74
+ old_value = get_network_io()
75
+
76
+ if old_value is None: # If psutil is not available, continue with default values
77
+ time.sleep(interval)
78
+ continue
79
+
80
+ time.sleep(interval)
81
+ new_value = get_network_io()
82
+
83
+ if new_value is None: # Handle again if psutil fails in the next call
84
+ time.sleep(interval)
85
+ continue
86
+
87
+ with self.lock:
88
+ upload_speed = (new_value.bytes_sent - old_value.bytes_sent) / interval
89
+ download_speed = (new_value.bytes_recv - old_value.bytes_recv) / interval
90
+
91
+ self.speed = {
92
+ "upload": internet_manager.format_transfer_speed(upload_speed),
93
+ "download": internet_manager.format_transfer_speed(download_speed)
94
+ }
95
+
96
+ def get_average_speed(self) -> float:
97
+ """
98
+ Calculate the average internet speed.
99
+
100
+ Returns:
101
+ float: The average internet speed in Mbps.
102
+ """
103
+ with self.lock:
104
+ return self.speed['download'].split(" ")
105
+
106
+ def calculate_total_size(self) -> str:
107
+ """
108
+ Calculate the total size of the files.
109
+
110
+ Returns:
111
+ str: The mean size of the files in a human-readable format.
112
+ """
113
+ try:
114
+ if len(self.ts_file_sizes) == 0:
115
+ raise ValueError("No file sizes available to calculate total size.")
116
+
117
+ total_size = sum(self.ts_file_sizes)
118
+ mean_size = total_size / len(self.ts_file_sizes)
119
+
120
+ # Return formatted mean size
121
+ return internet_manager.format_file_size(mean_size)
122
+
123
+ except ZeroDivisionError as e:
124
+ logging.error("Division by zero error occurred: %s", e)
125
+ return "0B"
126
+
127
+ except Exception as e:
128
+ logging.error("An unexpected error occurred: %s", e)
129
+ return "Error"
130
+
131
+ def get_downloaded_size(self) -> str:
132
+ """
133
+ Get the total downloaded size formatted as a human-readable string.
134
+
135
+ Returns:
136
+ str: The total downloaded size as a human-readable string.
137
+ """
138
+ return internet_manager.format_file_size(self.now_downloaded_size)
139
+
140
+ def update_progress_bar(self, total_downloaded: int, duration: float, progress_counter: tqdm) -> None:
141
+ """
142
+ Updates the progress bar with information about the TS segment download.
143
+
144
+ Parameters:
145
+ total_downloaded (int): The length of the content of the downloaded TS segment.
146
+ duration (float): The duration of the segment download in seconds.
147
+ progress_counter (tqdm): The tqdm object representing the progress bar.
148
+ """
149
+ # Add the size of the downloaded segment to the estimator
150
+ self.add_ts_file(total_downloaded * self.total_segments, total_downloaded, duration)
151
+
152
+ # Get downloaded size and total estimated size
153
+ downloaded_file_size_str = self.get_downloaded_size()
154
+ file_total_size = self.calculate_total_size()
155
+
156
+ # Fix parameter for prefix
157
+ number_file_downloaded = downloaded_file_size_str.split(' ')[0]
158
+ number_file_total_size = file_total_size.split(' ')[0]
159
+ units_file_downloaded = downloaded_file_size_str.split(' ')[1]
160
+ units_file_total_size = file_total_size.split(' ')[1]
161
+
162
+ average_internet_speed = self.get_average_speed()[0]
163
+ average_internet_unit = self.get_average_speed()[1]
164
+
165
+ # Update the progress bar's postfix
166
+ if TQDM_USE_LARGE_BAR:
167
+ progress_counter.set_postfix_str(
168
+ f"{Colors.WHITE}[ {Colors.GREEN}{number_file_downloaded} {Colors.WHITE}< {Colors.GREEN}{number_file_total_size} {Colors.RED}{units_file_total_size} "
169
+ f"{Colors.WHITE}| {Colors.CYAN}{average_internet_speed} {Colors.RED}{average_internet_unit}"
170
+ )
171
+ else:
172
+ progress_counter.set_postfix_str(
173
+ f"{Colors.WHITE}[ {Colors.GREEN}{number_file_downloaded}{Colors.RED} {units_file_downloaded} "
174
+ f"{Colors.WHITE}| {Colors.CYAN}{average_internet_speed} {Colors.RED}{average_internet_unit}"
175
+ )
176
+