mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-22 10:46:19 +01:00
api/instagram: fix module not using graphql api
This commit is contained in:
parent
6abccd9743
commit
b31c126cec
1 changed files with 7 additions and 6 deletions
|
@ -266,6 +266,7 @@ export default function(obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getPost(id, alwaysProxy) {
|
async function getPost(id, alwaysProxy) {
|
||||||
|
const hasData = (data) => data && data.gql_data !== null;
|
||||||
let data, result;
|
let data, result;
|
||||||
try {
|
try {
|
||||||
const cookie = getCookie('instagram');
|
const cookie = getCookie('instagram');
|
||||||
|
@ -282,16 +283,16 @@ export default function(obj) {
|
||||||
if (media_id && token) data = await requestMobileApi(media_id, { token });
|
if (media_id && token) data = await requestMobileApi(media_id, { token });
|
||||||
|
|
||||||
// mobile api (no cookie, cookie)
|
// mobile api (no cookie, cookie)
|
||||||
if (media_id && !data) data = await requestMobileApi(media_id);
|
if (media_id && !hasData(data)) data = await requestMobileApi(media_id);
|
||||||
if (media_id && cookie && !data) data = await requestMobileApi(media_id, { cookie });
|
if (media_id && cookie && !hasData(data)) data = await requestMobileApi(media_id, { cookie });
|
||||||
|
|
||||||
// html embed (no cookie, cookie)
|
// html embed (no cookie, cookie)
|
||||||
if (!data) data = await requestHTML(id);
|
if (!hasData(data)) data = await requestHTML(id);
|
||||||
if (!data && cookie) data = await requestHTML(id, cookie);
|
if (!hasData(data) && cookie) data = await requestHTML(id, cookie);
|
||||||
|
|
||||||
// web app graphql api (no cookie, cookie)
|
// web app graphql api (no cookie, cookie)
|
||||||
if (!data) data = await requestGQL(id);
|
if (!hasData(data)) data = await requestGQL(id);
|
||||||
if (!data && cookie) data = await requestGQL(id, cookie);
|
if (!hasData(data) && cookie) data = await requestGQL(id, cookie);
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
if (!data) return { error: "fetch.fail" };
|
if (!data) return { error: "fetch.fail" };
|
||||||
|
|
Loading…
Reference in a new issue