from phub import bot
from telethon import events, Button
from pornhub_api import PornhubApi
from youtube_dl import YoutubeDL
opts = {
            "format": "best",
            "addmetadata": True,
            "key": "FFmpegMetadata",
            "prefer_ffmpeg": True,
            "geo_bypass": True,
            "nocheckcertificate": True,
            "progress_hooks": [lambda d: download_progress_hook(d, message, client)],
            "postprocessors": [
                {"key": "FFmpegVideoConvertor", "preferedformat": "mp4"}
            ],
            "outtmpl": "%(id)s.mp4",
            "logtostderr": False,
            "quiet": True,
        }
digits = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣"]


@bot.on(events.NewMessage(pattern="^[!/]start$"))
async def phub_start(e):
 if e.is_group:
  await e.reply("PHUB Bot is Alive.")

@bot.on(events.NewMessage(pattern="^[!/]search ?(.*)"))
async def phub_search(e):
 try:
  q = e.text.split(None, 1)[1]
 except IndexError:
  return await e.reply("The search query was not given!")
 api = PornhubApi()
 gp = api.search.search(
    q,
    ordering="mostviewed",
)
 q_no = -1
 text = ""
 buttons = []
 btn = []
 for v in gp.videos:
    q_no += 1
    if q_no == 5:
      break
    digit = digits[q_no]
    text += f"\n{digit}<b>{v.title}</b>\n  ┗  🔗 <i><a href='{v.url}'>Get Additional Information</a></i>"
    cb_data = str(v.video_id) + "|" + str(e.sender.id)
    btn.append(Button.inline(digit, data="dlvid_{}".format(cb_data)))
    if len(btn) == 3 or q_no == 4:
            buttons.append(btn)
            btn = []
 await e.respond(
        text,
        buttons=buttons,
        file=None,
        parse_mode="html",
        link_preview=False,
    )

@bot.on(events.CallbackQuery(pattern="dlvid(\_(.*))"))
async def dl_vid_cb(e):
 video_id = e.pattern.match.group(1).decode().split("_", 1)[1]
 print("#")

@bot.on(events.NewMessage(pattern="^[!/](dl|download|phub) ?(.*)"))
async def dl_phub(e):
 try:
   link = e.text.split(" ", 1)[1]
 except:
   return
 try:
   with YoutubeDL({}) as ytdl:
        ytdl_data = ytdl.extract_info(url, download=True) 
 except:
   return 
 async with bot.action(e.chat_id, 'video'):
   await event.respond(file=f"{ytdl_data['id']}.mp4")
 

d869ba10192d0dc30ead16944028616d48d51a18
<mask token>

<mask token>


@bot.on(events.NewMessage(pattern='^[!/]start$'))
async def phub_start(e):
    if e.is_group:
        await e.reply('PHUB Bot is Alive.')


@bot.on(events.NewMessage(pattern='^[!/]search ?(.*)'))
async def phub_search(e):
    try:
        q = e.text.split(None, 1)[1]
    except IndexError:
        return await e.reply('The search query was not given!')
    api = PornhubApi()
    gp = api.search.search(q, ordering='mostviewed')
    q_no = -1
    text = ''
    buttons = []
    btn = []
    for v in gp.videos:
        q_no += 1
        if q_no == 5:
            break
        digit = digits[q_no]
        text += f"""
{digit}<b>{v.title}</b>
  ┗  🔗 <i><a href='{v.url}'>Get Additional Information</a></i>"""
        cb_data = str(v.video_id) + '|' + str(e.sender.id)
        btn.append(Button.inline(digit, data='dlvid_{}'.format(cb_data)))
        if len(btn) == 3 or q_no == 4:
            buttons.append(btn)
            btn = []
    await e.respond(text, buttons=buttons, file=None, parse_mode='html',
        link_preview=False)


@bot.on(events.CallbackQuery(pattern='dlvid(\\_(.*))'))
async def dl_vid_cb(e):
    video_id = e.pattern.match.group(1).decode().split('_', 1)[1]
    print('#')


@bot.on(events.NewMessage(pattern='^[!/](dl|download|phub) ?(.*)'))
async def dl_phub(e):
    try:
        link = e.text.split(' ', 1)[1]
    except:
        return
    try:
        with YoutubeDL({}) as ytdl:
            ytdl_data = ytdl.extract_info(url, download=True)
    except:
        return
    async with bot.action(e.chat_id, 'video'):
        await event.respond(file=f"{ytdl_data['id']}.mp4")

<mask token>
opts = {'format': 'best', 'addmetadata': True, 'key': 'FFmpegMetadata',
    'prefer_ffmpeg': True, 'geo_bypass': True, 'nocheckcertificate': True,
    'progress_hooks': [lambda d: download_progress_hook(d, message, client)
    ], 'postprocessors': [{'key': 'FFmpegVideoConvertor', 'preferedformat':
    'mp4'}], 'outtmpl': '%(id)s.mp4', 'logtostderr': False, 'quiet': True}
digits = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣']


@bot.on(events.NewMessage(pattern='^[!/]start$'))
async def phub_start(e):
    if e.is_group:
        await e.reply('PHUB Bot is Alive.')


@bot.on(events.NewMessage(pattern='^[!/]search ?(.*)'))
async def phub_search(e):
    try:
        q = e.text.split(None, 1)[1]
    except IndexError:
        return await e.reply('The search query was not given!')
    api = PornhubApi()
    gp = api.search.search(q, ordering='mostviewed')
    q_no = -1
    text = ''
    buttons = []
    btn = []
    for v in gp.videos:
        q_no += 1
        if q_no == 5:
            break
        digit = digits[q_no]
        text += f"""
{digit}<b>{v.title}</b>
  ┗  🔗 <i><a href='{v.url}'>Get Additional Information</a></i>"""
        cb_data = str(v.video_id) + '|' + str(e.sender.id)
        btn.append(Button.inline(digit, data='dlvid_{}'.format(cb_data)))
        if len(btn) == 3 or q_no == 4:
            buttons.append(btn)
            btn = []
    await e.respond(text, buttons=buttons, file=None, parse_mode='html',
        link_preview=False)


@bot.on(events.CallbackQuery(pattern='dlvid(\\_(.*))'))
async def dl_vid_cb(e):
    video_id = e.pattern.match.group(1).decode().split('_', 1)[1]
    print('#')


@bot.on(events.NewMessage(pattern='^[!/](dl|download|phub) ?(.*)'))
async def dl_phub(e):
    try:
        link = e.text.split(' ', 1)[1]
    except:
        return
    try:
        with YoutubeDL({}) as ytdl:
            ytdl_data = ytdl.extract_info(url, download=True)
    except:
        return
    async with bot.action(e.chat_id, 'video'):
        await event.respond(file=f"{ytdl_data['id']}.mp4")

from phub import bot
from telethon import events, Button
from pornhub_api import PornhubApi
from youtube_dl import YoutubeDL
opts = {'format': 'best', 'addmetadata': True, 'key': 'FFmpegMetadata',
    'prefer_ffmpeg': True, 'geo_bypass': True, 'nocheckcertificate': True,
    'progress_hooks': [lambda d: download_progress_hook(d, message, client)
    ], 'postprocessors': [{'key': 'FFmpegVideoConvertor', 'preferedformat':
    'mp4'}], 'outtmpl': '%(id)s.mp4', 'logtostderr': False, 'quiet': True}
digits = ['1️⃣', '2️⃣', '3️⃣', '4️⃣', '5️⃣']


@bot.on(events.NewMessage(pattern='^[!/]start$'))
async def phub_start(e):
    if e.is_group:
        await e.reply('PHUB Bot is Alive.')


@bot.on(events.NewMessage(pattern='^[!/]search ?(.*)'))
async def phub_search(e):
    try:
        q = e.text.split(None, 1)[1]
    except IndexError:
        return await e.reply('The search query was not given!')
    api = PornhubApi()
    gp = api.search.search(q, ordering='mostviewed')
    q_no = -1
    text = ''
    buttons = []
    btn = []
    for v in gp.videos:
        q_no += 1
        if q_no == 5:
            break
        digit = digits[q_no]
        text += f"""
{digit}<b>{v.title}</b>
  ┗  🔗 <i><a href='{v.url}'>Get Additional Information</a></i>"""
        cb_data = str(v.video_id) + '|' + str(e.sender.id)
        btn.append(Button.inline(digit, data='dlvid_{}'.format(cb_data)))
        if len(btn) == 3 or q_no == 4:
            buttons.append(btn)
            btn = []
    await e.respond(text, buttons=buttons, file=None, parse_mode='html',
        link_preview=False)


@bot.on(events.CallbackQuery(pattern='dlvid(\\_(.*))'))
async def dl_vid_cb(e):
    video_id = e.pattern.match.group(1).decode().split('_', 1)[1]
    print('#')


@bot.on(events.NewMessage(pattern='^[!/](dl|download|phub) ?(.*)'))
async def dl_phub(e):
    try:
        link = e.text.split(' ', 1)[1]
    except:
        return
    try:
        with YoutubeDL({}) as ytdl:
            ytdl_data = ytdl.extract_info(url, download=True)
    except:
        return
    async with bot.action(e.chat_id, 'video'):
        await event.respond(file=f"{ytdl_data['id']}.mp4")

from phub import bot
from telethon import events, Button
from pornhub_api import PornhubApi
from youtube_dl import YoutubeDL
opts = {
            "format": "best",
            "addmetadata": True,
            "key": "FFmpegMetadata",
            "prefer_ffmpeg": True,
            "geo_bypass": True,
            "nocheckcertificate": True,
            "progress_hooks": [lambda d: download_progress_hook(d, message, client)],
            "postprocessors": [
                {"key": "FFmpegVideoConvertor", "preferedformat": "mp4"}
            ],
            "outtmpl": "%(id)s.mp4",
            "logtostderr": False,
            "quiet": True,
        }
digits = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣"]


@bot.on(events.NewMessage(pattern="^[!/]start$"))
async def phub_start(e):
 if e.is_group:
  await e.reply("PHUB Bot is Alive.")

@bot.on(events.NewMessage(pattern="^[!/]search ?(.*)"))
async def phub_search(e):
 try:
  q = e.text.split(None, 1)[1]
 except IndexError:
  return await e.reply("The search query was not given!")
 api = PornhubApi()
 gp = api.search.search(
    q,
    ordering="mostviewed",
)
 q_no = -1
 text = ""
 buttons = []
 btn = []
 for v in gp.videos:
    q_no += 1
    if q_no == 5:
      break
    digit = digits[q_no]
    text += f"\n{digit}<b>{v.title}</b>\n  ┗  🔗 <i><a href='{v.url}'>Get Additional Information</a></i>"
    cb_data = str(v.video_id) + "|" + str(e.sender.id)
    btn.append(Button.inline(digit, data="dlvid_{}".format(cb_data)))
    if len(btn) == 3 or q_no == 4:
            buttons.append(btn)
            btn = []
 await e.respond(
        text,
        buttons=buttons,
        file=None,
        parse_mode="html",
        link_preview=False,
    )

@bot.on(events.CallbackQuery(pattern="dlvid(\_(.*))"))
async def dl_vid_cb(e):
 video_id = e.pattern.match.group(1).decode().split("_", 1)[1]
 print("#")

@bot.on(events.NewMessage(pattern="^[!/](dl|download|phub) ?(.*)"))
async def dl_phub(e):
 try:
   link = e.text.split(" ", 1)[1]
 except:
   return
 try:
   with YoutubeDL({}) as ytdl:
        ytdl_data = ytdl.extract_info(url, download=True) 
 except:
   return 
 async with bot.action(e.chat_id, 'video'):
   await event.respond(file=f"{ytdl_data['id']}.mp4")
 
