higher timeout
Build and Push Docker Images / build-and-push (push) Successful in 17s

This commit is contained in:
2025-04-16 21:40:28 +02:00
parent 18e9109297
commit 9d2c87f574
+7 -2
View File
@@ -14,6 +14,8 @@ SOURCE_URL = base64.b64decode(ENCODED_SOURCE_URL).decode('utf-8') if ENCODED_SOU
PORT = int(os.environ.get('PORT', 8000)) PORT = int(os.environ.get('PORT', 8000))
M3U8_DIR = '/m3u8' M3U8_DIR = '/m3u8'
LOCAL_FILE_PATH = os.path.join(M3U8_DIR, 'playlist.m3u8') LOCAL_FILE_PATH = os.path.join(M3U8_DIR, 'playlist.m3u8')
# Set a long timeout (10 minutes) for downloading large M3U8 files
DOWNLOAD_TIMEOUT = 600 # seconds
app = Flask(__name__) app = Flask(__name__)
@@ -23,8 +25,8 @@ def download_m3u8():
# Ensure the directory exists # Ensure the directory exists
os.makedirs(M3U8_DIR, exist_ok=True) os.makedirs(M3U8_DIR, exist_ok=True)
print(f"{datetime.now()} - Downloading M3U8 from source") print(f"{datetime.now()} - Downloading M3U8 from source (timeout: {DOWNLOAD_TIMEOUT}s)")
response = requests.get(SOURCE_URL, timeout=30) response = requests.get(SOURCE_URL, timeout=DOWNLOAD_TIMEOUT)
if response.status_code == 200: if response.status_code == 200:
with open(LOCAL_FILE_PATH, 'wb') as f: with open(LOCAL_FILE_PATH, 'wb') as f:
@@ -34,6 +36,9 @@ def download_m3u8():
else: else:
print(f"{datetime.now()} - Failed to download M3U8. Status code: {response.status_code}") print(f"{datetime.now()} - Failed to download M3U8. Status code: {response.status_code}")
return False return False
except requests.exceptions.Timeout:
print(f"{datetime.now()} - Timeout error: The request took longer than {DOWNLOAD_TIMEOUT} seconds")
return False
except Exception as e: except Exception as e:
print(f"{datetime.now()} - Error downloading M3U8: {str(e)}") print(f"{datetime.now()} - Error downloading M3U8: {str(e)}")
return False return False