mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
fix(tuna-obs): partially fix #1596
This commit is contained in:
@ -26,6 +26,7 @@ export default createPlugin({
|
|||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
backend: {
|
backend: {
|
||||||
|
liteMode: false,
|
||||||
data: {
|
data: {
|
||||||
cover: '',
|
cover: '',
|
||||||
cover_url: '',
|
cover_url: '',
|
||||||
@ -51,18 +52,28 @@ export default createPlugin({
|
|||||||
const url = `http://127.0.0.1:${port}/`;
|
const url = `http://127.0.0.1:${port}/`;
|
||||||
net
|
net
|
||||||
.fetch(url, {
|
.fetch(url, {
|
||||||
method: 'POST',
|
method: this.liteMode ? 'OPTIONS' : 'POST',
|
||||||
headers,
|
headers,
|
||||||
keepalive: true,
|
keepalive: true,
|
||||||
body: JSON.stringify({ data }),
|
body: this.liteMode ? undefined : JSON.stringify({ data }),
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
if (this.liteMode) {
|
||||||
|
this.liteMode = false;
|
||||||
|
console.debug(
|
||||||
|
`obs-tuna webserver at port ${port} is now accessible. disable lite mode`,
|
||||||
|
);
|
||||||
|
post(data);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((error: { code: number; errno: number }) => {
|
.catch((error: { code: number; errno: number }) => {
|
||||||
if (is.dev()) {
|
if (!this.liteMode && is.dev()) {
|
||||||
console.debug(
|
console.debug(
|
||||||
`Error: '${
|
`Error: '${
|
||||||
error.code || error.errno
|
error.code || error.errno
|
||||||
}' - when trying to access obs-tuna webserver at port ${port}`,
|
}' - when trying to access obs-tuna webserver at port ${port}. enable lite mode`,
|
||||||
);
|
);
|
||||||
|
this.liteMode = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user