2024-04-27 11:59:27 +01:00
|
|
|
import { genericUserAgent } from "../config.js";
|
2024-05-21 21:41:43 +01:00
|
|
|
import { cookie as tiktokCookie } from "../processing/services/tiktok.js";
|
2024-04-27 11:59:27 +01:00
|
|
|
|
|
|
|
const defaultHeaders = {
|
|
|
|
'user-agent': genericUserAgent
|
|
|
|
}
|
|
|
|
|
|
|
|
const serviceHeaders = {
|
|
|
|
bilibili: {
|
|
|
|
referer: 'https://www.bilibili.com/'
|
|
|
|
},
|
|
|
|
youtube: {
|
|
|
|
accept: '*/*',
|
|
|
|
origin: 'https://www.youtube.com',
|
|
|
|
referer: 'https://www.youtube.com',
|
|
|
|
DNT: '?1'
|
2024-05-21 21:41:43 +01:00
|
|
|
},
|
|
|
|
tiktok: {
|
|
|
|
cookie: tiktokCookie
|
2024-04-27 11:59:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-21 20:20:54 +01:00
|
|
|
export function closeResponse(res) {
|
|
|
|
if (!res.headersSent) res.sendStatus(500);
|
|
|
|
return res.destroy();
|
|
|
|
}
|
|
|
|
|
2024-04-27 11:59:27 +01:00
|
|
|
export function getHeaders(service) {
|
2024-05-21 21:41:43 +01:00
|
|
|
// Converting all header values to strings
|
|
|
|
return Object.entries({ ...defaultHeaders, ...serviceHeaders[service] })
|
|
|
|
.reduce((p, [key, val]) => ({ ...p, [key]: String(val) }), {})
|
2024-04-27 11:59:27 +01:00
|
|
|
}
|