mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-08 12:35:27 +00:00
Only 4 workers.
This commit is contained in:
parent
a030a2ef3b
commit
37e75370b0
@ -206,47 +206,4 @@ class VideoSource:
|
||||
new_url = m._replace(query=new_query) # Replace the old query string with the new one
|
||||
final_url = urlunparse(new_url) # Construct the final URL from the modified parts
|
||||
|
||||
if "canPlayFHD" in current_params and self.window_video.quality == "1080":
|
||||
return final_url
|
||||
else:
|
||||
console.log("[red]Rebuild master playlist.")
|
||||
return self.re_build_master()
|
||||
|
||||
def re_build_master(self) -> str:
|
||||
"""
|
||||
Rebuild the master playlist.
|
||||
|
||||
Returns:
|
||||
str: The rebuilt master playlist text, or an empty string if there's an error.
|
||||
"""
|
||||
try:
|
||||
index_resolution = None
|
||||
master_url = f'https://vixcloud.co/playlist/{self.window_video.id}'
|
||||
index_url = f'https://vixcloud.co/playlist/{self.window_video.id}?type=video&rendition={self.window_video.quality}p'
|
||||
|
||||
try:
|
||||
# Fetch the master playlist text
|
||||
master_text = requests.get(master_url).text
|
||||
except requests.RequestException as e:
|
||||
logging.error(f"Error fetching master playlist from URL: {master_url}, error: {e}")
|
||||
return ""
|
||||
|
||||
# Find the resolution in the index URL
|
||||
for resolution in [(7680, 4320), (3840, 2160), (2560, 1440), (1920, 1080), (1280, 720), (640, 480)]:
|
||||
if str(resolution[1]) in index_url:
|
||||
index_resolution = resolution
|
||||
break
|
||||
|
||||
# Add resolution and index URL to the master playlist text
|
||||
if index_resolution:
|
||||
master_text += f'\n#EXT-X-STREAM-INF:BANDWIDTH=2150000,CODECS="avc1.640028,mp4a.40.2",RESOLUTION={index_resolution[0]}x{index_resolution[1]},SUBTITLES="subs"\n'
|
||||
master_text += index_url
|
||||
|
||||
else:
|
||||
logging.warning(f"No matching resolution found in index URL: {index_url}")
|
||||
|
||||
return master_text
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Unexpected error in re_build_master: {e}")
|
||||
sys.exit(0)
|
||||
|
@ -239,47 +239,4 @@ class VideoSource:
|
||||
new_url = m._replace(query=new_query) # Replace the old query string with the new one
|
||||
final_url = urlunparse(new_url) # Construct the final URL from the modified parts
|
||||
|
||||
if "canPlayFHD" in current_params and self.window_video.quality == "1080":
|
||||
return final_url
|
||||
else:
|
||||
console.log("[red]Rebuild master playlist.")
|
||||
return self.re_build_master()
|
||||
|
||||
def re_build_master(self) -> str:
|
||||
"""
|
||||
Rebuild the master playlist.
|
||||
|
||||
Returns:
|
||||
str: The rebuilt master playlist text, or an empty string if there's an error.
|
||||
"""
|
||||
try:
|
||||
index_resolution = None
|
||||
master_url = f'https://vixcloud.co/playlist/{self.window_video.id}'
|
||||
index_url = f'https://vixcloud.co/playlist/{self.window_video.id}?type=video&rendition={self.window_video.quality}p'
|
||||
|
||||
try:
|
||||
# Fetch the master playlist text
|
||||
master_text = requests.get(master_url).text
|
||||
except requests.RequestException as e:
|
||||
logging.error(f"Error fetching master playlist from URL: {master_url}, error: {e}")
|
||||
return ""
|
||||
|
||||
# Find the resolution in the index URL
|
||||
for resolution in [(7680, 4320), (3840, 2160), (2560, 1440), (1920, 1080), (1280, 720), (640, 480)]:
|
||||
if str(resolution[1]) in index_url:
|
||||
index_resolution = resolution
|
||||
break
|
||||
|
||||
# Add resolution and index URL to the master playlist text
|
||||
if index_resolution:
|
||||
master_text += f'\n#EXT-X-STREAM-INF:BANDWIDTH=2150000,CODECS="avc1.640028,mp4a.40.2",RESOLUTION={index_resolution[0]}x{index_resolution[1]},SUBTITLES="subs"\n'
|
||||
master_text += index_url
|
||||
|
||||
else:
|
||||
logging.warning(f"No matching resolution found in index URL: {index_url}")
|
||||
|
||||
return master_text
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Unexpected error in re_build_master: {e}")
|
||||
sys.exit(0)
|
||||
|
@ -3,8 +3,3 @@
|
||||
STREAMING_FOLDER = "streamingcommunity"
|
||||
MOVIE_FOLDER = "Movie"
|
||||
SERIES_FOLDER = "Serie"
|
||||
|
||||
SERVER_IP = ['57.129.7.85', '57.129.7.188', '57.129.7.174', '57.129.4.77', '57.129.16.196', '57.129.16.156', '57.129.16.139', '57.129.16.135', '57.129.13.175',
|
||||
'57.129.13.157', '51.38.112.237', '51.195.107.7', '51.195.107.230', '162.19.255.78', '162.19.255.36', '162.19.255.224', '162.19.255.223', '162.19.254.244',
|
||||
'162.19.254.232', '162.19.254.230', '162.19.253.242', '162.19.249.48', '162.19.245.142', '162.19.231.20', '162.19.229.177', '162.19.228.128', '162.19.228.127',
|
||||
'162.19.228.105', '141.95.1.32', '141.95.1.196', '141.95.1.102', '141.95.0.50', '141.95.0.248', '135.125.237.84', '135.125.233.236']
|
@ -18,7 +18,7 @@ from .Core.Vix_player.player import VideoSource
|
||||
|
||||
# Config
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
from .costant import STREAMING_FOLDER, MOVIE_FOLDER, SERVER_IP
|
||||
from .costant import STREAMING_FOLDER, MOVIE_FOLDER
|
||||
|
||||
|
||||
# Variable
|
||||
@ -59,4 +59,4 @@ def download_film(id_film: str, title_name: str, domain: str):
|
||||
Downloader(
|
||||
m3u8_playlist = master_playlist,
|
||||
output_filename = os.path.join(mp4_path, mp4_format)
|
||||
).start(SERVER_IP)
|
||||
).start()
|
@ -20,7 +20,7 @@ from .Core.Util import manage_selection, map_episode_title
|
||||
|
||||
# Config
|
||||
ROOT_PATH = config_manager.get('DEFAULT', 'root_path')
|
||||
from .costant import STREAMING_FOLDER, SERIES_FOLDER, SERVER_IP
|
||||
from .costant import STREAMING_FOLDER, SERIES_FOLDER
|
||||
|
||||
|
||||
# Variable
|
||||
@ -96,7 +96,7 @@ def donwload_video(tv_name: str, index_season_selected: int, index_episode_selec
|
||||
Downloader(
|
||||
m3u8_playlist = master_playlist,
|
||||
output_filename = os.path.join(mp4_path, mp4_name)
|
||||
).start(SERVER_IP)
|
||||
).start()
|
||||
|
||||
|
||||
def donwload_episode(tv_name: str, index_season_selected: int, donwload_all: bool = False) -> None:
|
||||
|
@ -109,6 +109,34 @@ class M3U8_Segments:
|
||||
logging.info(f"Key: ('hex': {hex_content}, 'byte': {byte_content})")
|
||||
return byte_content
|
||||
|
||||
def __test_ip(self):
|
||||
"""
|
||||
Tests each proxy IP by sending a request to a corresponding segment URL.
|
||||
"""
|
||||
|
||||
failed_ips = []
|
||||
|
||||
for i in range(len(self.fake_proxy_ip)):
|
||||
url_to_test = self.segments[i]
|
||||
|
||||
try:
|
||||
|
||||
# Attempt to send a GET request to the URL
|
||||
requests.get(url_to_test, verify=self.verify_ssl)
|
||||
except:
|
||||
|
||||
# Log the error and add the IP to the list of failed IPs
|
||||
logging.error(f"Failed to make request using IP in this request: {url_to_test}")
|
||||
failed_ips.append(i)
|
||||
|
||||
# Remove the failed IPs from the fake_proxy_ip list
|
||||
self.fake_proxy_ip = [ip for j, ip in enumerate(self.fake_proxy_ip) if j not in failed_ips]
|
||||
|
||||
# Exit the program if 50% requests failed
|
||||
if len(failed_ips) / 2 > len(self.fake_proxy_ip):
|
||||
logging.error("All requests with ip failed. Exiting the program.")
|
||||
sys.exit(0)
|
||||
|
||||
def parse_data(self, m3u8_content: str) -> None:
|
||||
"""
|
||||
Parses the M3U8 content to extract segment information.
|
||||
@ -156,6 +184,9 @@ class M3U8_Segments:
|
||||
|
||||
self.segments[i] = self.__gen_proxy__(segment_url, self.segments.index(segment_url))
|
||||
|
||||
# Test new url with ip
|
||||
self.__test_ip()
|
||||
|
||||
# Save new playlist of segment
|
||||
path_m3u8_file = os.path.join(self.tmp_folder, "playlist_fix.m3u8")
|
||||
with open(path_m3u8_file, "w") as file:
|
||||
|
@ -17,7 +17,7 @@
|
||||
"segments": { "user-agent": ""}
|
||||
},
|
||||
"M3U8_DOWNLOAD": {
|
||||
"tdqm_workers": 30,
|
||||
"tdqm_workers": 4,
|
||||
"tqdm_use_large_bar": true,
|
||||
"download_video": true,
|
||||
"download_audio": true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user