mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-06 19:45:24 +00:00
Fix download json config
This commit is contained in:
parent
d03ece1cf2
commit
8cd4108f97
@ -131,6 +131,7 @@ class M3U8_Segments:
|
|||||||
# Convert the content of the response to hexadecimal and then to bytes
|
# Convert the content of the response to hexadecimal and then to bytes
|
||||||
hex_content = binascii.hexlify(response.content).decode('utf-8')
|
hex_content = binascii.hexlify(response.content).decode('utf-8')
|
||||||
byte_content = bytes.fromhex(hex_content)
|
byte_content = bytes.fromhex(hex_content)
|
||||||
|
logging.info(f"URI: Hex content: {hex_content}, Byte content: {byte_content}")
|
||||||
|
|
||||||
#console.print(f"[cyan]Find key: [red]{hex_content}")
|
#console.print(f"[cyan]Find key: [red]{hex_content}")
|
||||||
return byte_content
|
return byte_content
|
||||||
@ -160,6 +161,7 @@ class M3U8_Segments:
|
|||||||
|
|
||||||
iv = m3u8_parser.keys.get('iv')
|
iv = m3u8_parser.keys.get('iv')
|
||||||
method = m3u8_parser.keys.get('method')
|
method = m3u8_parser.keys.get('method')
|
||||||
|
logging.info(f"M3U8_Decryption - IV: {iv}, method: {method}")
|
||||||
|
|
||||||
# Create a decryption object with the key and set the method
|
# Create a decryption object with the key and set the method
|
||||||
self.decryption = M3U8_Decryption(key, iv, method)
|
self.decryption = M3U8_Decryption(key, iv, method)
|
||||||
@ -308,7 +310,9 @@ class M3U8_Segments:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Decryption failed for segment {index}: {str(e)}")
|
logging.error(f"Decryption failed for segment {index}: {str(e)}")
|
||||||
raise
|
self.interrupt_flag.set() # Interrupt the download process
|
||||||
|
self.stop_event.set() # Trigger the stopping event for all threads
|
||||||
|
break # Stop the current task immediately
|
||||||
|
|
||||||
# Update progress and queue
|
# Update progress and queue
|
||||||
self.class_ts_estimator.update_progress_bar(content_size, duration, progress_bar)
|
self.class_ts_estimator.update_progress_bar(content_size, duration, progress_bar)
|
||||||
@ -537,11 +541,15 @@ class M3U8_Segments:
|
|||||||
progress_bar.close()
|
progress_bar.close()
|
||||||
|
|
||||||
# Final verification
|
# Final verification
|
||||||
|
try:
|
||||||
final_completion = (len(self.downloaded_segments) / total_segments) * 100
|
final_completion = (len(self.downloaded_segments) / total_segments) * 100
|
||||||
if final_completion < 99.9: # Less than 99.9% complete
|
if final_completion < 99.9: # Less than 99.9% complete
|
||||||
missing = set(range(total_segments)) - self.downloaded_segments
|
missing = set(range(total_segments)) - self.downloaded_segments
|
||||||
raise Exception(f"Download incomplete ({final_completion:.1f}%). Missing segments: {sorted(missing)}")
|
raise Exception(f"Download incomplete ({final_completion:.1f}%). Missing segments: {sorted(missing)}")
|
||||||
|
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# Verify output file
|
# Verify output file
|
||||||
if not os.path.exists(self.tmp_file_path):
|
if not os.path.exists(self.tmp_file_path):
|
||||||
raise Exception("Output file missing")
|
raise Exception("Output file missing")
|
||||||
|
@ -61,6 +61,7 @@ if crypto_installed:
|
|||||||
bytes: The decrypted content.
|
bytes: The decrypted content.
|
||||||
"""
|
"""
|
||||||
start = time.perf_counter_ns()
|
start = time.perf_counter_ns()
|
||||||
|
#logging.info(f"Ciphertext: {ciphertext}")
|
||||||
|
|
||||||
# Decrypt based on encryption method
|
# Decrypt based on encryption method
|
||||||
if self.method in {"AES", "AES-128"}:
|
if self.method in {"AES", "AES-128"}:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# 29.01.24
|
# 29.01.24
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import json
|
import json
|
||||||
import httpx
|
import httpx
|
||||||
import logging
|
import logging
|
||||||
@ -31,25 +32,46 @@ class ConfigManager:
|
|||||||
|
|
||||||
# Download config.json
|
# Download config.json
|
||||||
else:
|
else:
|
||||||
logging.info("Configuration file does not exist. Downloading...")
|
self.download_requirements(
|
||||||
url = "https://raw.githubusercontent.com/Lovi-0/StreamingCommunity/refs/heads/main/config.json"
|
'https://raw.githubusercontent.com/Lovi-0/StreamingCommunity/refs/heads/main/config.json',
|
||||||
|
self.file_path
|
||||||
|
)
|
||||||
|
|
||||||
with httpx.Client() as client:
|
with open(self.file_path, 'r') as f:
|
||||||
response = client.get(url)
|
self.config = json.loads(f)
|
||||||
|
|
||||||
if response.status_code == 200:
|
|
||||||
with open(self.file_path, 'w') as f:
|
|
||||||
f.write(response.text)
|
|
||||||
|
|
||||||
self.config = json.loads(response.text)
|
|
||||||
logging.info("Configuration file downloaded and saved.")
|
logging.info("Configuration file downloaded and saved.")
|
||||||
|
|
||||||
else:
|
logging.info("Configuration file does not exist. Downloading...")
|
||||||
logging.error(f"Failed to download configuration file. Status code: {response.status_code}")
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error reading configuration file: {e}")
|
logging.error(f"Error reading configuration file: {e}")
|
||||||
|
|
||||||
|
def download_requirements(self, url: str, filename: str):
|
||||||
|
"""
|
||||||
|
Download the requirements.txt file from the specified URL if not found locally using requests.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
url (str): The URL to download the requirements file from.
|
||||||
|
filename (str): The local filename to save the requirements file as.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
import requests
|
||||||
|
|
||||||
|
logging.info(f"{filename} not found locally. Downloading from {url}...")
|
||||||
|
response = requests.get(url)
|
||||||
|
|
||||||
|
if response.status_code == 200:
|
||||||
|
with open(filename, 'wb') as f:
|
||||||
|
f.write(response.content)
|
||||||
|
|
||||||
|
else:
|
||||||
|
logging.error(f"Failed to download {filename}. HTTP Status code: {response.status_code}")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"Failed to download {filename}: {e}")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
def read_key(self, section: str, key: str, data_type: type = str) -> Any:
|
def read_key(self, section: str, key: str, data_type: type = str) -> Any:
|
||||||
"""Read a key from the configuration file.
|
"""Read a key from the configuration file.
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
"user": "admin",
|
"user": "admin",
|
||||||
"pass": "adminadmin"
|
"pass": "adminadmin"
|
||||||
},
|
},
|
||||||
"add_siteName": true,
|
"add_siteName": false,
|
||||||
"disable_searchDomain": true,
|
"disable_searchDomain": false,
|
||||||
"not_close": false
|
"not_close": false
|
||||||
},
|
},
|
||||||
"REQUESTS": {
|
"REQUESTS": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user