Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Commit

Permalink
non-numeric values detection for highlight/story
Browse files Browse the repository at this point in the history
  • Loading branch information
AppleGamer22 committed Dec 1, 2020
1 parent 35236c0 commit 905f34f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/commands/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export default class Highlight extends Command {
* @returns URL string array
*/
export async function detectFiles(browser: Browser, page: Page, highlight: string, item: number): Promise<ScrapePayload | undefined> {
if (isNaN(item)) {
await browser.close();
alert(`item provided is not a number: ${item}`, "danger");
}
try {
await page.goto(`https://www.instagram.com/stories/highlights/${highlight}`, {waitUntil: "domcontentloaded"});
await page.waitForSelector("body", {visible: true});
Expand Down
12 changes: 10 additions & 2 deletions src/commands/story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export default class Story extends Command {
}
await browser.close();
} else return alert("Please provide a POST argument!", "danger");
} catch (error) { alert(error.message, "danger"); }
} catch (error) {
alert(error.message, "danger");
}
}
}
}
Expand All @@ -58,6 +60,10 @@ export default class Story extends Command {
* @returns URL string array
*/
export async function detectFiles(browser: Browser, page: Page, user: string, item: number): Promise<ScrapePayload | undefined> {
if (isNaN(item)) {
await browser.close();
alert(`item provided is not a number: ${item}`, "danger");
}
try {
await page.goto(`https://www.instagram.com/${user}`);
await page.goto(`https://www.instagram.com/stories/${user}`, {waitUntil: "domcontentloaded"});
Expand Down Expand Up @@ -87,5 +93,7 @@ export async function detectFiles(browser: Browser, page: Page, user: string, it
const videoURL = (await page.$$eval("div.qbCDp > video > source", sources => sources.map(source => source.getAttribute("src"))))[0];
if (videoURL) urls.push(videoURL);
return { username, urls };
} catch (error) { alert(error.message, "danger"); }
} catch (error) {
alert(error.message, "danger");
}
}

0 comments on commit 905f34f

Please sign in to comment.