Skip to content

Commit

Permalink
修复链接处理错误
Browse files Browse the repository at this point in the history
  • Loading branch information
666wcy committed Sep 7, 2021
1 parent b568fea commit 9fb6388
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"redirects" : "True",
"password_key": "True",
"password_value": "xxxx",
"replace_list ": [
"replace_list": [
{"from": "/media/video/","to": "http://xxxx.weinb.top/shi/"},
{"from": "/media/adult/","to": "http://xxxx.weinb.top/adult/emby/"}

Expand Down
16 changes: 9 additions & 7 deletions web.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
jsonFile.close()

try:


main_site = data['main_site']
main_port= data['main_port']
new_port = data['new_port']
Expand All @@ -39,11 +37,11 @@

with open("config.json", "a") as file: # 只需要将之前的”w"改为“a"即可,代表追加内容
file.close()
exit()




replace_list=[]

app = Flask(__name__)

Expand Down Expand Up @@ -80,12 +78,14 @@ def proxy(path):
MediaSourceId = flask.request.args.get('MediaSourceId')
info_url = f"{main_site}emby/Items?Fields=Path&Ids={MediaSourceId}&api_key={api_key}"
info_json = requests.get(url=info_url).json()

index_url = str(info_json['Items'][0]['Path'])
for a in replace_list:
index_url = str(info_json['Items'][0]['Path']).replace(a['from'], a['to'])
print(info_json['Items'][0]['Path'],a['from'], a['to'])
index_url = index_url.replace(a['from'], a['to'])
print(f"处理后的直链:{index_url}")
if redirects=="True":


true_result=requests.get(index_url,allow_redirects=False)

#return redirect(index_url)
Expand All @@ -94,10 +94,12 @@ def proxy(path):
true_result = requests.post(index_url, allow_redirects=False, data=data)

true_url=dict(true_result.headers)['Location']
print(f"重定向后的直链{true_url}")
return redirect(true_url)
else:
true_url=index_url
#print(true_url)
return redirect(true_url)

return redirect(true_url)

elif "Download" in url and "Items" in url:
MediaSourceId = flask.request.args.get('mediaSourceId')
Expand Down

0 comments on commit 9fb6388

Please sign in to comment.