Skip to content
This repository was archived by the owner on Sep 29, 2021. It is now read-only.

Commit 56adbdc

Browse files
adekmaulanaKenHV
authored andcommitted
scrapers: carbon: fix after carbon.sh updated their site
Change-Id: Ib58b34b6028ea5c49040e9795b4cc7c213bb3d6b Conflicts: userbot/modules/scrapers.py Co-authored-by: KenHV <[email protected]> Signed-off-by: MoveAngel <[email protected]>
1 parent a7925df commit 56adbdc

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

userbot/modules/scrapers.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from urbandict import define
2929
from wikipedia import summary
3030
from wikipedia.exceptions import DisambiguationError, PageError
31+
from youtube_search import YoutubeSearch
3132
from youtube_dl import YoutubeDL
3233
from youtube_dl.utils import (
3334
ContentTooShortError,
@@ -39,8 +40,7 @@
3940
UnavailableVideoError,
4041
XAttrMetadataError,
4142
)
42-
from youtube_search import YoutubeSearch
43-
43+
from asyncio import sleep
4444
from userbot import BOTLOG, BOTLOG_CHATID, CMD_HELP, TEMP_DOWNLOAD_DIRECTORY, WOLFRAM_ID
4545
from userbot.events import register
4646
from userbot.utils import chrome, googleimagesdownload, progress
@@ -77,7 +77,18 @@ async def carbon_api(e):
7777
url = CARBON.format(code=code, lang=CARBONLANG)
7878
driver = await chrome()
7979
driver.get(url)
80-
await e.edit("`Processing...\n50%`")
80+
await e.edit("`Processing..\n50%`")
81+
download_path = './'
82+
driver.command_executor._commands["send_command"] = (
83+
"POST", '/session/$sessionId/chromium/send_command')
84+
params = {
85+
'cmd': 'Page.setDownloadBehavior',
86+
'params': {
87+
'behavior': 'allow',
88+
'downloadPath': download_path
89+
}
90+
}
91+
driver.execute("send_command", params)
8192
driver.find_element_by_xpath("//button[@id='export-menu']").click()
8293
driver.find_element_by_xpath("//button[contains(text(),'4x')]").click()
8394
driver.find_element_by_xpath("//button[contains(text(),'PNG')]").click()

0 commit comments

Comments
 (0)