mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-28 09:28:29 +00:00
fixed more errors with instagram
This commit is contained in:
parent
55aab2aff2
commit
f3a57b33d5
@ -136,21 +136,26 @@ export default function instagram(obj) {
|
||||
}
|
||||
|
||||
async function requestHTML(id, cookie) {
|
||||
try {
|
||||
const data = await fetch(`https://www.instagram.com/p/${id}/embed/captioned/`, {
|
||||
headers: {
|
||||
...embedHeaders,
|
||||
cookie
|
||||
},
|
||||
dispatcher
|
||||
}).then(r => r.text()).catch(() => {});
|
||||
}).then(r => r.text()).catch(() => {
|
||||
});
|
||||
|
||||
let embedData = JSON.parse(data?.match(/"init",\[\],\[(.*?)\]\],/)[1]);
|
||||
|
||||
if (!embedData || !embedData?.contextJSON) return false;
|
||||
|
||||
embedData = JSON.parse(embedData.contextJSON);
|
||||
|
||||
return embedData;
|
||||
}catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function getGQLParams(id, cookie) {
|
||||
@ -213,6 +218,7 @@ export default function instagram(obj) {
|
||||
}
|
||||
|
||||
async function requestGQL(id, cookie) {
|
||||
try{
|
||||
const { headers, body } = await getGQLParams(id, cookie);
|
||||
|
||||
const req = await fetch('https://www.instagram.com/graphql/query', {
|
||||
@ -246,6 +252,10 @@ export default function instagram(obj) {
|
||||
.catch(() => null)
|
||||
};
|
||||
}
|
||||
catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function getErrorContext(id) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user