mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-05 02:55:25 +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
|
||||
hex_content = binascii.hexlify(response.content).decode('utf-8')
|
||||
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}")
|
||||
return byte_content
|
||||
@ -160,6 +161,7 @@ class M3U8_Segments:
|
||||
|
||||
iv = m3u8_parser.keys.get('iv')
|
||||
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
|
||||
self.decryption = M3U8_Decryption(key, iv, method)
|
||||
@ -308,7 +310,9 @@ class M3U8_Segments:
|
||||
|
||||
except Exception as 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
|
||||
self.class_ts_estimator.update_progress_bar(content_size, duration, progress_bar)
|
||||
@ -537,10 +541,14 @@ class M3U8_Segments:
|
||||
progress_bar.close()
|
||||
|
||||
# Final verification
|
||||
final_completion = (len(self.downloaded_segments) / total_segments) * 100
|
||||
if final_completion < 99.9: # Less than 99.9% complete
|
||||
missing = set(range(total_segments)) - self.downloaded_segments
|
||||
raise Exception(f"Download incomplete ({final_completion:.1f}%). Missing segments: {sorted(missing)}")
|
||||
try:
|
||||
final_completion = (len(self.downloaded_segments) / total_segments) * 100
|
||||
if final_completion < 99.9: # Less than 99.9% complete
|
||||
missing = set(range(total_segments)) - self.downloaded_segments
|
||||
raise Exception(f"Download incomplete ({final_completion:.1f}%). Missing segments: {sorted(missing)}")
|
||||
|
||||
except:
|
||||
pass
|
||||
|
||||
# Verify output file
|
||||
if not os.path.exists(self.tmp_file_path):
|
||||
|
@ -61,6 +61,7 @@ if crypto_installed:
|
||||
bytes: The decrypted content.
|
||||
"""
|
||||
start = time.perf_counter_ns()
|
||||
#logging.info(f"Ciphertext: {ciphertext}")
|
||||
|
||||
# Decrypt based on encryption method
|
||||
if self.method in {"AES", "AES-128"}:
|
||||
|
@ -1,6 +1,7 @@
|
||||
# 29.01.24
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import httpx
|
||||
import logging
|
||||
@ -31,25 +32,46 @@ class ConfigManager:
|
||||
|
||||
# Download config.json
|
||||
else:
|
||||
logging.info("Configuration file does not exist. Downloading...")
|
||||
url = "https://raw.githubusercontent.com/Lovi-0/StreamingCommunity/refs/heads/main/config.json"
|
||||
self.download_requirements(
|
||||
'https://raw.githubusercontent.com/Lovi-0/StreamingCommunity/refs/heads/main/config.json',
|
||||
self.file_path
|
||||
)
|
||||
|
||||
with httpx.Client() as client:
|
||||
response = client.get(url)
|
||||
|
||||
if response.status_code == 200:
|
||||
with open(self.file_path, 'w') as f:
|
||||
f.write(response.text)
|
||||
with open(self.file_path, 'r') as f:
|
||||
self.config = json.loads(f)
|
||||
logging.info("Configuration file downloaded and saved.")
|
||||
|
||||
self.config = json.loads(response.text)
|
||||
logging.info("Configuration file downloaded and saved.")
|
||||
|
||||
else:
|
||||
logging.error(f"Failed to download configuration file. Status code: {response.status_code}")
|
||||
|
||||
logging.info("Configuration file does not exist. Downloading...")
|
||||
|
||||
except Exception as 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:
|
||||
"""Read a key from the configuration file.
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
"user": "admin",
|
||||
"pass": "adminadmin"
|
||||
},
|
||||
"add_siteName": true,
|
||||
"disable_searchDomain": true,
|
||||
"add_siteName": false,
|
||||
"disable_searchDomain": false,
|
||||
"not_close": false
|
||||
},
|
||||
"REQUESTS": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user