mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-17 05:39:57 +00:00
2534931b60
Signed-off-by: Damir Modyarov <otomir@yandex.ru> Co-authored-by: wukko <me@wukko.me>
32 lines
830 B
JavaScript
32 lines
830 B
JavaScript
import { genericUserAgent } from "../config.js";
|
|
import { cookie as tiktokCookie } from "../processing/services/tiktok.js";
|
|
|
|
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'
|
|
},
|
|
tiktok: {
|
|
cookie: tiktokCookie
|
|
}
|
|
}
|
|
|
|
export function closeResponse(res) {
|
|
if (!res.headersSent) res.sendStatus(500);
|
|
return res.destroy();
|
|
}
|
|
|
|
export function getHeaders(service) {
|
|
// Converting all header values to strings
|
|
return Object.entries({ ...defaultHeaders, ...serviceHeaders[service] })
|
|
.reduce((p, [key, val]) => ({ ...p, [key]: String(val) }), {})
|
|
} |