Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ import requests
|
|
4 |
import time
|
5 |
import asyncio
|
6 |
from typing import Dict
|
|
|
|
|
7 |
|
8 |
app = FastAPI()
|
9 |
|
@@ -436,7 +438,7 @@ HTML_CONTENT = """
|
|
436 |
align-items: flex-start;
|
437 |
}
|
438 |
|
439 |
-
|
440 |
margin-top: 10px;
|
441 |
flex-wrap: wrap;
|
442 |
}
|
@@ -445,7 +447,7 @@ HTML_CONTENT = """
|
|
445 |
font-size: 0.9rem;
|
446 |
}
|
447 |
|
448 |
-
|
449 |
padding: 15px;
|
450 |
}
|
451 |
|
@@ -789,11 +791,28 @@ HTML_CONTENT = """
|
|
789 |
actionsContainer.appendChild(embedBtn);
|
790 |
}
|
791 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
792 |
historyItem.appendChild(actionsContainer);
|
793 |
historyList.appendChild(historyItem);
|
794 |
});
|
795 |
historyModal.style.display = "block";
|
796 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
797 |
</script>
|
798 |
</body>
|
799 |
</html>
|
@@ -888,6 +907,11 @@ async def embed_video(url: str, thumbnail: str):
|
|
888 |
'''
|
889 |
return HTMLResponse(content=html)
|
890 |
|
|
|
|
|
|
|
|
|
|
|
891 |
async def get_cookies() -> Dict[str, str]:
|
892 |
try:
|
893 |
response = requests.get('https://replicate.com/levelsio/neon-tokyo', headers={
|
@@ -939,6 +963,11 @@ async def retry_upload(upload_url: str, file_content: bytes, content_type: str,
|
|
939 |
print(f"Error during upload: {e}")
|
940 |
|
941 |
await asyncio.sleep(delay)
|
942 |
-
delay = min(delay * 2, 60)
|
943 |
|
944 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import time
|
5 |
import asyncio
|
6 |
from typing import Dict
|
7 |
+
import base64
|
8 |
+
import hashlib
|
9 |
|
10 |
app = FastAPI()
|
11 |
|
|
|
438 |
align-items: flex-start;
|
439 |
}
|
440 |
|
441 |
+
.history-item-actions {
|
442 |
margin-top: 10px;
|
443 |
flex-wrap: wrap;
|
444 |
}
|
|
|
447 |
font-size: 0.9rem;
|
448 |
}
|
449 |
|
450 |
+
.drop-zone {
|
451 |
padding: 15px;
|
452 |
}
|
453 |
|
|
|
791 |
actionsContainer.appendChild(embedBtn);
|
792 |
}
|
793 |
|
794 |
+
const encryptBtn = document.createElement('button');
|
795 |
+
encryptBtn.textContent = 'Encrypt';
|
796 |
+
encryptBtn.className = 'small-btn';
|
797 |
+
encryptBtn.onclick = () => {
|
798 |
+
const encryptedUrl = encryptUrl(item.url);
|
799 |
+
navigator.clipboard.writeText(window.location.origin + '/encrypted/' + encryptedUrl).then(() => {
|
800 |
+
alert('Encrypted link copied to clipboard!');
|
801 |
+
});
|
802 |
+
};
|
803 |
+
actionsContainer.appendChild(encryptBtn);
|
804 |
+
|
805 |
historyItem.appendChild(actionsContainer);
|
806 |
historyList.appendChild(historyItem);
|
807 |
});
|
808 |
historyModal.style.display = "block";
|
809 |
}
|
810 |
+
|
811 |
+
function encryptUrl(url) {
|
812 |
+
const key = 'your-secret-key'; // Replace with a secure key
|
813 |
+
const encodedUrl = btoa(url);
|
814 |
+
return encodedUrl.split('').reverse().join('');
|
815 |
+
}
|
816 |
</script>
|
817 |
</body>
|
818 |
</html>
|
|
|
907 |
'''
|
908 |
return HTMLResponse(content=html)
|
909 |
|
910 |
+
@app.get("/encrypted/{encrypted_url}")
|
911 |
+
async def handle_encrypted_url(encrypted_url: str, request: Request):
|
912 |
+
decrypted_url = decrypt_url(encrypted_url)
|
913 |
+
return await handle_video_stream(decrypted_url.split('/pbxt/')[1], request)
|
914 |
+
|
915 |
async def get_cookies() -> Dict[str, str]:
|
916 |
try:
|
917 |
response = requests.get('https://replicate.com/levelsio/neon-tokyo', headers={
|
|
|
963 |
print(f"Error during upload: {e}")
|
964 |
|
965 |
await asyncio.sleep(delay)
|
966 |
+
delay = min(delay * 2, 60)
|
967 |
|
968 |
+
return False
|
969 |
+
|
970 |
+
def decrypt_url(encrypted_url: str) -> str:
|
971 |
+
key = '875843758RR'
|
972 |
+
decoded_url = base64.b64decode(encrypted_url[::-1]).decode('utf-8')
|
973 |
+
return decoded_url
|