-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.py
32 lines (22 loc) · 980 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import requests
from flask import Flask, request, redirect
from flask_cors import CORS
from urllib import parse
from config import *
app = Flask(__name__)
CORS(app, resources=r"/*")
@app.route("/emby/videos/<item_id>/<file_name>", methods=["GET", "POST"])
def stream(item_id, file_name):
MediaSourceId = request.args.get("MediaSourceId")
info_url = f"{CONFIG_EMBY_URL}emby/Items?Fields=Path&Ids={MediaSourceId}&api_key={CONFIG_EMBY_KEY}"
print("请求地址 >> ", info_url)
info_json = requests.get(url=info_url).json()
index_url = str(info_json["Items"][0]["Path"])
for i in CONFIG_DIRECT_LIST:
# print(info_json["Items"][0]["Path"], i["from"], i["to"])
index_url = CONFIG_DIRECT_HOST + i["to"] + parse.quote(index_url.replace(i["from"], ""))
index_url = index_url.replace("%2F", "/")
print("直链 >> ", index_url)
return redirect(index_url)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=10000)