async def glitch(event):
    if event.fwd_from:
        return
    await event.get_reply_message()
    okbruh = await event.edit("`Gli, Glitchiiingggg.....`")
    photolove = await convert_to_image(event, friday)
    pathsn = f"./whiteeyez/@WhiteEyeDevs.gif"
    glitch_imgs = glitcher.glitch_image(photolove,
                                        2,
                                        gif=True,
                                        color_offset=True)
    glitch_imgs[0].save(
        pathsn,
        format="GIF",
        append_images=glitch_imgs[1:],
        save_all=True,
        duration=DURATION,
        loop=LOOP,
    )
    c_time = time.time()
    optimize(pathsn)
    stark_m = await uf(
        file_name="*****@*****.**",
        client=borg,
        file=open(pathsn, "rb"),
        progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
            progress(d, t, event, c_time, "Uploading..", pathsn)),
    )
    await borg.send_file(event.chat_id,
                         stark_m,
                         caption="Powered By @WhiteEyeDevs")
    await okbruh.delete()
    for starky in (pathsn, photolove):
        if starky and os.path.exists(starky):
            os.remove(starky)
async def flip(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.edit("Reply To Any Video.")
        return
    await event.edit("Ah, Shit. Here it Starts.")
    kk = await event.get_reply_message()
    if not kk.video or kk.video_note:
        await event.edit("`Oho, Reply To Video Only`")
        return
    hmm = await event.client.download_media(kk.media)
    c_time = time.time()
    cmd = f'ffmpeg -i {hmm} -vf "transpose=2,transpose=2" [email protected]'
    await runcmd(cmd)
    filem = "[email protected]"
    if not os.path.exists(filem):
        await event.edit("**Process, Failed !**")
        return
    final_file = await uf(
        file_name=filem,
        client=bot,
        file=open(filem, "rb"),
        progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
            progress(d, t, event, c_time, "Uploading Flipped video..", filem)),
    )
    await event.delete()
    await borg.send_file(
        event.chat_id,
        final_file,
        caption="**Video Flipped** - Powered By @WhiteEyeDevs",
    )
    for files in (filem, hmm):
        if files and os.path.exists(files):
            os.remove(files)
async def audio_extract(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.edit("Reply To Any Video.")
        return
    await event.edit("Ah, Shit. Here it Starts.")
    kk = await event.get_reply_message()
    if not kk.video or kk.video_note:
        await event.edit("`Oho, Reply To Video Only`")
        return
    hmm = await event.client.download_media(kk.media)
    try:
        thumb = await event.client.download_media(kk.media, thumb=-1)
    except:
        thumb = "./resources/20201201_001148.jpg"
    name_out = str(
        kk.media.document.attributes[1].file_name.split(".")[0]) + str(".mp3")
    c_time = time.time()
    cmd = f"ffmpeg -i {hmm} -map 0:a {name_out}"
    await runcmd(cmd)
    filem = name_out
    if not os.path.exists(filem):
        await event.edit("**Process, Failed !**")
        return
    final_file = await uf(
        file_name=filem,
        client=bot,
        file=open(filem, "rb"),
        progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
            progress(d, t, event, c_time, "Uploading Audio From The video..",
                     filem)),
    )
    await event.delete()
    await borg.send_file(
        event.chat_id,
        final_file,
        thumb=thumb,
        caption="**Audio Extarcted** - Powered By @WhiteEyeDevs",
    )
    for files in (filem, hmm):
        if files and os.path.exists(files):
            os.remove(files)
async def convert_to_note(event):
    if event.fwd_from:
        return
    if not event.reply_to_msg_id:
        await event.edit("Reply To Any Video.")
        return
    await event.edit("Ah, Shit. Here it Starts.")
    kk = await event.get_reply_message()
    if not (kk.video or kk.video_note or kk.gif or kk.video_note):
        await event.edit("`Oho, Reply To Video Only.`")
        return
    hmm = await event.client.download_media(kk.media)
    try:
        thumb = await event.client.download_media(kk.media, thumb=-1)
    except:
        thumb = "./resources/20201201_001148.jpg"
    c_time = time.time()
    filem = "[email protected]"
    await crop_vid(hmm, filem)
    if not os.path.exists(filem):
        await event.edit("**Process, Failed !**")
        return
    final_file = await uf(
        file_name=filem,
        client=bot,
        file=open(filem, "rb"),
        progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
            progress(d, t, event, c_time, "Uploading Round / Video Note.",
                     filem)),
    )
    await event.delete()
    await borg.send_file(event.chat_id,
                         final_file,
                         thumb=thumb,
                         video_note=True)
    for files in (filem, hmm):
        if files and os.path.exists(files):
            os.remove(files)
示例#5
0
async def _(event):
    if event.fwd_from:
        return
    urlissed = event.pattern_match.group(1)
    myself_stark = await edit_or_reply(
        event, f"`Getting {urlissed} From Youtube Servers. Please Wait.`")
    search = SearchVideos(f"{urlissed}", offset=1, mode="dict", max_results=1)
    mi = search.result()
    mio = mi["search_result"]
    mo = mio[0]["link"]
    thum = mio[0]["title"]
    WhiteEyez = mio[0]["id"]
    thums = mio[0]["channel"]
    kekme = f"https://img.youtube.com/vi/{WhiteEyez}/hqdefault.jpg"
    await asyncio.sleep(0.6)
    if not os.path.isdir("./music/"):
        os.makedirs("./music/")
    path = Config.TMP_DOWNLOAD_DIRECTORY
    url = mo
    sedlyf = wget.download(kekme, out=path)
    opts = {
        "format":
        "bestaudio",
        "addmetadata":
        True,
        "key":
        "FFmpegMetadata",
        "writethumbnail":
        True,
        "prefer_ffmpeg":
        True,
        "geo_bypass":
        True,
        "nocheckcertificate":
        True,
        "postprocessors": [{
            "key": "FFmpegExtractAudio",
            "preferredcodec": "mp3",
            "preferredquality": "480",
        }],
        "outtmpl":
        "%(title)s.mp3",
        "quiet":
        True,
        "logtostderr":
        False,
    }
    try:
        with YoutubeDL(opts) as ytdl:
            ytdl_data = ytdl.extract_info(url)
    except Exception as e:
        await event.edit(f"**Failed To Download** \n**Error :** `{str(e)}`")
        return
    c_time = time.time()
    file_stark = f"{ytdl_data['title']}.mp3"
    lol_m = await upload_file(
        file_name=file_stark,
        client=borg,
        file=open(file_stark, "rb"),
        progress_callback=lambda d, t: asyncio.get_event_loop().create_task(
            progress(d, t, event, c_time, "Uploading Your Song!", file_stark)),
    )
    capy = f"**Song Name ➠** `{thum}` \n**Requested For ➠** `{urlissed}` \n**Channel ➠** `{thums}` \n**Link ➠** `{mo}`"
    await event.delete()
    await borg.send_file(
        event.chat_id,
        lol_m,
        force_document=False,
        allow_cache=False,
        caption=capy,
        thumb=sedlyf,
        attributes=[
            DocumentAttributeAudio(
                duration=int(ytdl_data["duration"]),
                title=str(ytdl_data["title"]),
                performer=str(ytdl_data["uploader"]),
            )
        ],
        supports_streaming=True,
    )
    for files in (sedlyf, file_stark):
        if files and os.path.exists(files):
            os.remove(files)