fix screenshot
This commit is contained in:
parent
e12be86164
commit
64dd1ef758
34
bot.py
34
bot.py
|
@ -1915,7 +1915,7 @@ async def ffmpeg2(ctx, ext, *, args):
|
||||||
os.remove(urlllname)
|
os.remove(urlllname)
|
||||||
os.remove(fileout)
|
os.remove(fileout)
|
||||||
|
|
||||||
|
"""
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def screenshot(ctx, url):
|
async def screenshot(ctx, url):
|
||||||
url2 = f"https://api.apiflash.com/v1/urltoimage?access_key=84f448c81a3f4ddbacf188aca585a4f6&url={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}`")
|
await ctx.send(f"An error occured while connecting to `{url}`")
|
||||||
else:
|
else:
|
||||||
await ctx.send(url2)
|
await ctx.send(url2)
|
||||||
|
"""
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def twerkradio(ctx, loop: int = 1):
|
async def twerkradio(ctx, loop: int = 1):
|
||||||
|
@ -2249,26 +2249,42 @@ async def dumpy(ctx, lines : int = 10):
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
async def screenshot(ctx, url):
|
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:
|
try:
|
||||||
mobile_emulation = {
|
mobile_emulation = {
|
||||||
"deviceMetrics": { "width": 360, "height": 640, "pixelRatio": 3.0 },
|
"deviceMetrics": { "width": 375, "height": 812, "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"}
|
"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 = Options()
|
||||||
chrome_options.add_argument("--headless")
|
chrome_options.add_argument("--headless")
|
||||||
chrome_options.add_argument("--disable-gpu")
|
chrome_options.add_argument("--disable-gpu")
|
||||||
|
|
||||||
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
|
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.get(url)
|
||||||
driver.save_screenshot("ytdl/screenshot.png")
|
driver.save_screenshot("ytdl/screenshot.png")
|
||||||
driver.quit()
|
driver.quit()
|
||||||
except Exception as x:
|
except Exception as x:
|
||||||
await ctx.channel.send(f"error...\n`{x}`")
|
await ctx.send(f"<:error:871854416238612520> `{x}`")
|
||||||
msg.delete()
|
return
|
||||||
await ctx.channel.send(f"{ctx.author.mention}", file=discord.File("ytdl/screenshot.png"))
|
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:
|
if number == None:
|
||||||
z = int(idd)
|
z = int(idd)
|
||||||
|
|
Loading…
Reference in New Issue