mirror of
https://github.com/wukko/cobalt.git
synced 2025-02-13 14:16:25 +01:00
api/snapchat: allow profile params to be missing
fixes broken story extraction
This commit is contained in:
parent
a0f227d68b
commit
09706160a9
2 changed files with 3 additions and 4 deletions
|
@ -40,9 +40,9 @@ async function getStory(username, storyId, alwaysProxy) {
|
|||
const nextDataString = html.match(NEXT_DATA_REGEX)?.[1];
|
||||
if (nextDataString) {
|
||||
const data = JSON.parse(nextDataString);
|
||||
const storyIdParam = data.query.profileParams[1];
|
||||
const storyIdParam = data?.query?.profileParams?.[1];
|
||||
|
||||
if (storyIdParam && data.props.pageProps.story) {
|
||||
if (storyIdParam && data?.props?.pageProps?.story) {
|
||||
const story = data.props.pageProps.story.snapList.find((snap) => snap.snapId.value === storyIdParam);
|
||||
if (story) {
|
||||
if (story.snapMediaType === 0) {
|
||||
|
@ -61,7 +61,7 @@ async function getStory(username, storyId, alwaysProxy) {
|
|||
}
|
||||
}
|
||||
|
||||
const defaultStory = data.props.pageProps.curatedHighlights[0];
|
||||
const defaultStory = data?.props?.pageProps?.curatedHighlights?.[0];
|
||||
if (defaultStory) {
|
||||
return {
|
||||
picker: defaultStory.snapList.map(snap => {
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
{
|
||||
"name": "story",
|
||||
"url": "https://www.snapchat.com/add/bazerkmakane",
|
||||
"canFail": true,
|
||||
"params": {},
|
||||
"expected": {
|
||||
"code": 200,
|
||||
|
|
Loading…
Reference in a new issue