Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import gradio as gr
|
|
8 |
import requests
|
9 |
from urllib.parse import urlparse
|
10 |
from ftplib import FTP
|
|
|
11 |
|
12 |
logging.basicConfig(level=logging.INFO)
|
13 |
|
@@ -38,6 +39,17 @@ def upload_to_ftp(server, port, username, password, source_file, destination_fil
|
|
38 |
with open(source_file, 'rb') as f:
|
39 |
ftp.storbinary(f'STOR {destination_file}', f)
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
def get_output_path(input_path, temp_dir, res):
|
42 |
"""Returns the path to the output file, creating it if necessary."""
|
43 |
output_path = temp_dir / (Path(input_path).stem + f"_{res}.m3u8")
|
|
|
8 |
import requests
|
9 |
from urllib.parse import urlparse
|
10 |
from ftplib import FTP
|
11 |
+
import paramiko
|
12 |
|
13 |
logging.basicConfig(level=logging.INFO)
|
14 |
|
|
|
39 |
with open(source_file, 'rb') as f:
|
40 |
ftp.storbinary(f'STOR {destination_file}', f)
|
41 |
|
42 |
+
def upload_to_sftp(server, port, username, password, source_file, destination_file):
|
43 |
+
"""Uploads a file to an SFTP server."""
|
44 |
+
transport = paramiko.Transport((server, int(port)))
|
45 |
+
transport.connect(username=username, password=password)
|
46 |
+
|
47 |
+
sftp = paramiko.SFTPClient.from_transport(transport)
|
48 |
+
sftp.put(source_file, destination_file)
|
49 |
+
|
50 |
+
sftp.close()
|
51 |
+
transport.close()
|
52 |
+
|
53 |
def get_output_path(input_path, temp_dir, res):
|
54 |
"""Returns the path to the output file, creating it if necessary."""
|
55 |
output_path = temp_dir / (Path(input_path).stem + f"_{res}.m3u8")
|