Update app.py
Browse files
app.py
CHANGED
|
@@ -35,10 +35,10 @@ def decrypt_encrypt_ajax_response(obj):
|
|
| 35 |
|
| 36 |
def pad(data):
|
| 37 |
padding_length = 16 - (len(data) % 16)
|
| 38 |
-
return data + (
|
| 39 |
|
| 40 |
def unpad(s):
|
| 41 |
-
return s[:-
|
| 42 |
|
| 43 |
try:
|
| 44 |
cipher = AES.new(keys['second_key'], AES.MODE_CBC, keys['iv'])
|
|
@@ -48,11 +48,13 @@ def decrypt_encrypt_ajax_response(obj):
|
|
| 48 |
st.write(f"Encrypted data length: {len(encrypted_data)}")
|
| 49 |
st.write(f"Encrypted data: {encrypted_data[:20]}...") # Show first 20 bytes
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
| 56 |
|
| 57 |
# Print debug information
|
| 58 |
st.write(f"Decrypted data length: {len(decrypted)}")
|
|
@@ -157,8 +159,13 @@ def get_m3u8(iframe_url):
|
|
| 157 |
st.write("Encrypted response received successfully")
|
| 158 |
st.write(f"Response content: {encrypted_response.text[:100]}...") # Show first 100 characters
|
| 159 |
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
if isinstance(response_data, dict) and 'data' in response_data:
|
| 163 |
decrypted_response = decrypt_encrypt_ajax_response(response_data)
|
| 164 |
return {
|
|
@@ -168,6 +175,7 @@ def get_m3u8(iframe_url):
|
|
| 168 |
}
|
| 169 |
else:
|
| 170 |
st.error("Invalid response format from encrypt-ajax.php")
|
|
|
|
| 171 |
return {'sources': [], 'sources_bk': []}
|
| 172 |
else:
|
| 173 |
st.error(f"Failed to fetch streaming data. Status code: {encrypted_response.status_code}")
|
|
|
|
| 35 |
|
| 36 |
def pad(data):
|
| 37 |
padding_length = 16 - (len(data) % 16)
|
| 38 |
+
return data + bytes([padding_length] * padding_length)
|
| 39 |
|
| 40 |
def unpad(s):
|
| 41 |
+
return s[:-s[-1]]
|
| 42 |
|
| 43 |
try:
|
| 44 |
cipher = AES.new(keys['second_key'], AES.MODE_CBC, keys['iv'])
|
|
|
|
| 48 |
st.write(f"Encrypted data length: {len(encrypted_data)}")
|
| 49 |
st.write(f"Encrypted data: {encrypted_data[:20]}...") # Show first 20 bytes
|
| 50 |
|
| 51 |
+
# Ensure the data is padded correctly
|
| 52 |
+
if len(encrypted_data) % 16 != 0:
|
| 53 |
+
encrypted_data = pad(encrypted_data)
|
| 54 |
|
| 55 |
+
st.write(f"Padded data length: {len(encrypted_data)}")
|
| 56 |
+
|
| 57 |
+
decrypted = cipher.decrypt(encrypted_data)
|
| 58 |
|
| 59 |
# Print debug information
|
| 60 |
st.write(f"Decrypted data length: {len(decrypted)}")
|
|
|
|
| 159 |
st.write("Encrypted response received successfully")
|
| 160 |
st.write(f"Response content: {encrypted_response.text[:100]}...") # Show first 100 characters
|
| 161 |
|
| 162 |
+
try:
|
| 163 |
+
response_data = encrypted_response.json()
|
| 164 |
+
except json.JSONDecodeError:
|
| 165 |
+
st.error("Failed to decode JSON response")
|
| 166 |
+
st.write(f"Full response: {encrypted_response.text}")
|
| 167 |
+
return {'sources': [], 'sources_bk': []}
|
| 168 |
+
|
| 169 |
if isinstance(response_data, dict) and 'data' in response_data:
|
| 170 |
decrypted_response = decrypt_encrypt_ajax_response(response_data)
|
| 171 |
return {
|
|
|
|
| 175 |
}
|
| 176 |
else:
|
| 177 |
st.error("Invalid response format from encrypt-ajax.php")
|
| 178 |
+
st.write(f"Response data: {response_data}")
|
| 179 |
return {'sources': [], 'sources_bk': []}
|
| 180 |
else:
|
| 181 |
st.error(f"Failed to fetch streaming data. Status code: {encrypted_response.status_code}")
|