api/snapchat: allow profile params to be missing

fixes broken story extraction
This commit is contained in:
wukko 2025-02-10 00:33:23 +06:00
parent a0f227d68b
commit 09706160a9
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
2 changed files with 3 additions and 4 deletions

View file

@ -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 => {

View file

@ -20,7 +20,6 @@
{
"name": "story",
"url": "https://www.snapchat.com/add/bazerkmakane",
"canFail": true,
"params": {},
"expected": {
"code": 200,