Skip to content

Commit

Permalink
fixes with browser
Browse files Browse the repository at this point in the history
  • Loading branch information
lluisd committed Feb 5, 2024
1 parent d88c38b commit 5ea1e91
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions handlers/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ class Stream {
parse_mode: 'Markdown'
}

await bot.sendMessage(config.telegram.chatId, text, options).then((msg) => {
TwitchService.saveLastMessage(msg)
TwitchService.saveTitle(result.title)
})
const msg = await bot.sendMessage(config.telegram.chatId, text, options)
try {
await bot.pinChatMessage(config.telegram.chatId, result.messageId)
} catch {}
await TwitchService.saveLastMessage(msg)
await TwitchService.saveTitle(result.title)

} else if (result && result.type === 'finished' && result.messageId) {
await bot.deleteMessage(config.telegram.chatId, result.messageId)
await TwitchService.deleteLastMessage()
Expand Down
6 changes: 4 additions & 2 deletions services/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ async function getScreenshot() {
const browser = await puppeteer.connect({ browserWSEndpoint: `wss://${config.browserlessUrl}` })
const page = await browser.newPage()

const session = await page.target().createCDPSession()
await session.send("Page.enable")
await page.setViewport({ width: 1920, height: 1080 })
await page.goto("https://www.twitch.tv/" + config.twitch.channels, { waitUntil: 'networkidle0' })

await page.$eval('button[data-a-target="consent-banner-accept"]', el => el.click())
await page.$eval('button[data-a-target="content-classification-gate-overlay-start-watching-button"]', el => el.click())

await page.waitForSelector('div.persistent-player')
await page.$eval('.video-player__default-player', el => el.remove())
const svgImage = await page.$('div.persistent-player')
Expand Down

0 comments on commit 5ea1e91

Please sign in to comment.