mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-12 13:17:45 +02:00
add cookie support
usage: - create cookies.json file somewhere, preferrably outside cobalt directory - in docker, you can bind mount it (`volumes` in composefile) - if you don't want cobalt to update the cookies, set it to `:ro` (cobalt will print a warning about this, ignore it) - set COOKIE_PATH to the absolute path of this file - enjoy? usage in services: probably the simplest api ever - import { getCookie, updateCookie } from '../../cookie/manager.js'; - const cookie = getCookie('<service_name>'); - add this to headers - `headers: { cookie }` - after fetch is done, save potential cookie updates: updateCookie(cookie, fetch.headers) - see instagram.js for example usage
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { createStream } from "../../stream/manage.js";
|
||||
import { genericUserAgent } from "../../config.js";
|
||||
import { getCookie, updateCookie } from '../../cookie/manager.js';
|
||||
|
||||
export default async function(obj) {
|
||||
let data;
|
||||
@ -14,6 +15,8 @@ export default async function(obj) {
|
||||
shortcode: obj.id
|
||||
}))
|
||||
|
||||
const cookie = getCookie('instagram');
|
||||
|
||||
data = await fetch(url, {
|
||||
headers: {
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
|
||||
@ -25,9 +28,11 @@ export default async function(obj) {
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'upgrade-insecure-requests': '1',
|
||||
'accept-encoding': 'gzip, deflate, br',
|
||||
'accept-language': 'en-US,en;q=0.9,en;q=0.8'
|
||||
'accept-language': 'en-US,en;q=0.9,en;q=0.8',
|
||||
cookie
|
||||
}
|
||||
})
|
||||
updateCookie(cookie, data.headers);
|
||||
data = (await data.json()).data;
|
||||
} catch (e) {
|
||||
data = false;
|
||||
|
Reference in New Issue
Block a user