forked from monlor/docker-xiaoya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fix_media.sh
62 lines (53 loc) · 1.85 KB
/
fix_media.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
echo "等待emby.js创建完成..."
while ! test -f /etc/nginx/http.d/emby.js; do
sleep 2
done
sed -i '/async function fetchXYApi/{:a;N;$!ba;d}' /etc/nginx/http.d/emby.js
cat >> /etc/nginx/http.d/emby.js <<-\EOF
async function fetchXYApi(xyurl) {
xyurl = xyurl.replace(/ /g, '%20');
try {
const res = await ngx.fetch(xyurl, { headers: { 'Content-Type': 'application/json;charset=utf-8', "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.6045.160 Safari/537.36" }, max_response_body_size: 365535} );
if (res.status == 302) {
if (res.statusText == "Found") {
return res.headers.Location;
}
return (`error: xy_api return 304 destination is null`);
}
else {
return res.text();
}
}
catch (error) {
return (`error: xy_api fetch aliyun direct link failed, ${error}`);
}
}
export default { redirect2Pan };
EOF
echo "等待jellyfin.js创建完成..."
while ! test -f /etc/nginx/http.d/jellyfin.js; do
sleep 2
done
sed -i '/async function fetchXYApi/{:a;N;$!ba;d}' /etc/nginx/http.d/jellyfin.js
cat >> /etc/nginx/http.d/jellyfin.js <<-\EOF
async function fetchXYApi(xyurl) {
xyurl = xyurl.replace(/ /g, '%20');
try {
const res = await ngx.fetch(xyurl, { headers: { 'Content-Type': 'application/json;charset=utf-8' }, max_response_body_size: 365535} );
if (res.status == 302) {
if (res.statusText == "Found") {
return res.headers.Location;
}
return (`error: xy_api return 304 destination is null`);
}
else {
return res.text();
}
}
catch (error) {
return (`error: xy_api fetch aliyun direct link failed, ${error}`);
}
}
export default { redirect2Pan };
EOF