This commit is contained in:
@@ -2,12 +2,15 @@ import os
|
|||||||
import requests
|
import requests
|
||||||
import schedule
|
import schedule
|
||||||
import time
|
import time
|
||||||
|
import base64
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from flask import Flask, Response
|
from flask import Flask, Response
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
SOURCE_URL = os.environ.get('SOURCE_URL', 'http://example.com/source.m3u8')
|
ENCODED_SOURCE_URL = os.environ.get('ENCODED_SOURCE_URL', '')
|
||||||
|
# Fallback to a direct URL if no encoded URL is provided
|
||||||
|
SOURCE_URL = base64.b64decode(ENCODED_SOURCE_URL).decode('utf-8') if ENCODED_SOURCE_URL else os.environ.get('SOURCE_URL', 'http://example.com/source.m3u8')
|
||||||
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')
|
||||||
@@ -20,7 +23,7 @@ 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_URL}")
|
print(f"{datetime.now()} - Downloading M3U8 from source")
|
||||||
response = requests.get(SOURCE_URL, timeout=30)
|
response = requests.get(SOURCE_URL, timeout=30)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
@@ -63,6 +66,8 @@ def schedule_downloads():
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main function to start the application"""
|
"""Main function to start the application"""
|
||||||
|
print(f"{datetime.now()} - Starting IPTV Filter service")
|
||||||
|
|
||||||
# Initial download
|
# Initial download
|
||||||
if not download_m3u8():
|
if not download_m3u8():
|
||||||
print("Initial download failed. Retrying in 30 seconds...")
|
print("Initial download failed. Retrying in 30 seconds...")
|
||||||
|
|||||||
Reference in New Issue
Block a user