mirror of
https://github.com/wahyd4/ai-projects.git
synced 2026-08-08 20:56:10 +10:00
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from flask import Flask, jsonify
|
|
from flask_cors import CORS
|
|
|
|
app = Flask(__name__)
|
|
CORS(app, resources={r"/*": {"origins": "*"}}) # 允许所有来源,仅用于开发环境
|
|
|
|
channels = [
|
|
{"id": 1, "name": "BBC News", "url": "https://cdn4.skygo.mn/live/disk1/BBC_News/HLSv3-FTA/BBC_News.m3u8"},
|
|
{"id": 2, "name": "CCTV5", "url": "https://node1.olelive.com:6443/live/CCTV5HD/hls.m3u8"},
|
|
{"id": 3, "name": "CNN", "url": "https://turnerlive.warnermediacdn.com/hls/live/586495/cnngo/cnn_slate/VIDEO_3_1464000.m3u8"},
|
|
{"id": 4, "name": "Bloomberg", "url": "https://liveprodusphoenixeast.akamaized.net/USPhx-HD/Channel-TX-USPhx-AWS-virginia-1/Source-USPhx-16k-1-s6lk2-BP-07-02-81ykIWnsMsg_live.m3u8"},
|
|
]
|
|
|
|
@app.route('/api/channels', methods=['GET'])
|
|
def get_channels():
|
|
return jsonify(channels)
|
|
|
|
@app.route('/api/stream/<int:channel_id>', methods=['GET'])
|
|
def get_stream_url(channel_id):
|
|
channel = next((c for c in channels if c['id'] == channel_id), None)
|
|
if channel:
|
|
return jsonify({'streamUrl': channel['url']})
|
|
return jsonify({'error': 'Channel not found'}), 404
|
|
|
|
if __name__ == '__main__':
|
|
app.run(debug=True)
|