fix screenshot

This commit is contained in:
Soso Playz 2021-08-09 16:07:45 +03:00
parent e12be86164
commit 64dd1ef758
1 changed files with 25 additions and 9 deletions

34
bot.py
View File

@ -1915,7 +1915,7 @@ async def ffmpeg2(ctx, ext, *, args):
os.remove(urlllname)
os.remove(fileout)
"""
@bot.command()
async def screenshot(ctx, url):
url2 = f"https://api.apiflash.com/v1/urltoimage?access_key=84f448c81a3f4ddbacf188aca585a4f6&url={url}"
@ -1925,7 +1925,7 @@ async def screenshot(ctx, url):
await ctx.send(f"An error occured while connecting to `{url}`")
else:
await ctx.send(url2)
"""
@bot.command()
async def twerkradio(ctx, loop: int = 1):
@ -2249,26 +2249,42 @@ async def dumpy(ctx, lines : int = 10):
@bot.command()
async def screenshot(ctx, url):
msg = await ctx.send(f"Processing request for {url} <a:load:769818027956895744>")
msg = await ctx.send(f"Processing request for `{url}` <a:load:769818027956895744>")
try:
mobile_emulation = {
"deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 },
"userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19"}
"deviceMetrics": { "width": 375, "height": 812, "pixelRatio": 3.0 },
"userAgent": "Mozilla/5.0 (Linux; Android 9; Samsung Galaxy Note 9 Build/SM-N960N) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/5.2 Chrome/71.0.3578.99 Mobile Safari/604.1"}
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
driver = webdriver.Chrome(chrome_options = chrome_options)
driver = webdriver.Chrome(options = chrome_options)
driver.set_page_load_timeout(25)
driver.get(url)
driver.save_screenshot("ytdl/screenshot.png")
driver.quit()
except Exception as x:
await ctx.channel.send(f"error...\n`{x}`")
msg.delete()
await ctx.channel.send(f"{ctx.author.mention}", file=discord.File("ytdl/screenshot.png"))
await ctx.send(f"<:error:871854416238612520> `{x}`")
return
await msg.delete()
channel = ctx.channel
msg = await ctx.channel.send(f"{ctx.author.mention}", file=discord.File("ytdl/screenshot.png"))
#
await msg.add_reaction('🗑️')
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) == '🗑️'
try:
reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await ctx.send('sex!')
else:
await msg.delete()
os.system(f'rm ytdl/screenshot.png')
"""
if number == None:
z = int(idd)