You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
730 B
23 lines
730 B
import { httpProxy } from "utils/proxy/http";
|
|
import { formatApiCall } from "utils/proxy/api-helpers";
|
|
|
|
export async function fetchJackettCookie(widget, loginURL) {
|
|
const url = new URL(formatApiCall(loginURL, widget));
|
|
const loginData = `password=${encodeURIComponent(widget.password)}`;
|
|
const [status, , , , params] = await httpProxy(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
},
|
|
body: loginData,
|
|
});
|
|
|
|
if (status === 200 && params && params.headers && params.headers.Cookie) {
|
|
const cookieValue = params.headers.Cookie;
|
|
return cookieValue;
|
|
} else {
|
|
logger.error("Failed to fetch Jackett cookie, status: %d", status);
|
|
return null;
|
|
}
|
|
}
|