This commit is contained in:
@@ -9,20 +9,24 @@ from threading import Thread
|
||||
# Configuration
|
||||
SOURCE_URL = os.environ.get('SOURCE_URL', 'http://example.com/source.m3u8')
|
||||
PORT = int(os.environ.get('PORT', 8000))
|
||||
LOCAL_FILE_PATH = 'playlist.m3u8'
|
||||
M3U8_DIR = '/m3u8'
|
||||
LOCAL_FILE_PATH = os.path.join(M3U8_DIR, 'playlist.m3u8')
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
def download_m3u8():
|
||||
"""Download the M3U8 file from the source URL"""
|
||||
try:
|
||||
# Ensure the directory exists
|
||||
os.makedirs(M3U8_DIR, exist_ok=True)
|
||||
|
||||
print(f"{datetime.now()} - Downloading M3U8 from {SOURCE_URL}")
|
||||
response = requests.get(SOURCE_URL, timeout=30)
|
||||
|
||||
if response.status_code == 200:
|
||||
with open(LOCAL_FILE_PATH, 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f"{datetime.now()} - M3U8 file downloaded successfully")
|
||||
print(f"{datetime.now()} - M3U8 file downloaded successfully to {LOCAL_FILE_PATH}")
|
||||
return True
|
||||
else:
|
||||
print(f"{datetime.now()} - Failed to download M3U8. Status code: {response.status_code}")
|
||||
|
||||
Reference in New Issue
Block a user