def phub(): if not is_request_valid(request): abort(400) api = PornhubApi() if request.form['text'] is not None: search = request.form['text'] else: search = "t**s" results = api.search.search(q=search, ordering="featured", thumbsize="large_hd") vid = random.choice(results.videos) thumbnail = random.choice(vid.thumbs) # If we got back both the title, image url, and video url, then we are good to go if vid is not None: if vid.title is not None and thumbnail.src is not None and vid.url is not None: resp = True else: resp = False # If the response was valid then create an slack block API response with the image, title, and a link to the video if resp is True: rDict = { "blocks": [{ "type": "image", "image_url": str(thumbnail.src), "alt_text": vid.title }, { "type": "context", "elements": [{ "type": "mrkdwn", "text": "{title} | {url}".format(title=vid.title, url=str(vid.url)) }] }], "response_type": "in_channel" } # otherwise respond with an error message else: rDict = { "blocks": [{ "type": "section", "text": { "type": "plain_text", "text": "Something went wrong!" } }] } # print("test: [{}]".format(rDict)) return rDict
async def inline_id_handler(event: events.InlineQuery.Event): builder = event.builder if event.query.user_id != bot.uid: resultm = builder.article( title="- Not Allowded -", text= f"You Can't Use This Bot. \nDeploy Friday To Get Your Own Assistant, Repo Link [Here](https://github.com/StarkGang/FridayUserbot)", ) await event.answer([resultm]) return results = [] input_str = event.pattern_match.group(1) api = PornhubApi() data = api.search.search(input_str, ordering="mostviewed") ok = 1 oik = "" for vid in data.videos: if ok <= 5: lul_m = ( f"**P**N-HUB SEARCH** \n**Video title :** `{vid.title}` \n**Video link :** `https://www.pornhub.com/view_video.php?viewkey={vid.video_id}`" ) results.append(await event.builder.article( title=vid.title, text=lul_m, buttons=[ Button.switch_inline("Search Again", query="ph ", same_peer=True) ], )) else: pass await event.answer(results)
async def inline_id_handler(event: events.InlineQuery.Event): builder = event.builder if event.query.user_id != bot.uid: resultm = builder.article( title="- NIKAL LAWDE -", text= f"You Can't Use This Bot. \nDeploy LEGEND BOTTo Get Your Own BOT Repo Link HERE", ) await event.answer([resultm]) return results = [] input_str = event.pattern_match.group(1) api = PornhubApi() data = api.search.search(input_str, ordering="mostviewed") ok = 1 oik = "" for vid in data.videos: if ok <= 5: lul_m = ( f"P**N-HUB SEARCH \nVideo title : {vid.title} \nVideo link : https://www.pornhub.com/view_video.php?viewkey={vid.video_id}" ) results.append(await event.builder.article( title=vid.title, text=lul_m, buttons=[ Button.switch_inline("Search Again", query="ph ", same_peer=True) ], )) else: pass await event.answer(results)
async def _(event): if event.fwd_from: return input_str = event.pattern_match.group(1) api = PornhubApi() data = api.search.search( input_str, ordering="mostviewed" ) ok = 1 oik = "" for vid in data.videos: if ok<=5: oik +=(f""" Video title:- {vid.title} Video link:- https://www.pornhub.com/view_video.php?viewkey={vid.video_id} """) ok = ok+1 else: pass oiko = "<b>Links Generated Successfully</b>"+"\n"+"Search Query:- "+input_str+"\n"+oik await borg.send_message( event.chat_id, oiko, parse_mode="HTML", ) await event.delete()
async def inline_id_handler(event: events.InlineQuery.Event): builder = event.builder o = await all_pro_s(Config, client1, client2, client3) if event.query.user_id not in o: resultm = builder.article( title="- Not Allowded -", text= f"You Can't Use This Bot. \nDeploy WhiteEyeUserBot To Get Your Own Assistant, Deploy Link [Here](https://whiteeye-org.github.io/WhiteEyeUserBot/)", ) await event.answer([resultm]) return results = [] input_str = event.pattern_match.group(1) api = PornhubApi() data = api.search.search(input_str, ordering="mostviewed") ok = 1 for vid in data.videos: if ok <= 5: lul_m = f"**P**N-HUB SEARCH** \n**Video title :** `{vid.title}` \n**Video link :** `https://www.pornhub.com/view_video.php?viewkey={vid.video_id}`" results.append(await event.builder.article( title=vid.title, text=lul_m, buttons=[ Button.switch_inline("Search Again", query="ph ", same_peer=True) ], )) else: pass await event.answer(results)
def download_search() -> None: """ Download movies from pornhub """ logger = logging.getLogger(__name__) api = PornhubApi() limit = ConfigPornhubSearch.limit page = 1 counter = 0 errors = 0 exceptions = [] except_urls = [] while True: kwargs = {} if ConfigPornhubSearch.use_ordering: kwargs["ordering"] = ConfigPornhubSearch.ordering if ConfigPornhubSearch.use_period: kwargs["period"] = ConfigPornhubSearch.period if ConfigPornhubSearch.use_tags: kwargs["tags"] = ConfigPornhubSearch.tags try: data = api.search.search( ConfigPornhubSearch.query, page=page, **kwargs, ) except ValueError as e: code: int = get_code(e) if code == 2001: # no videos found (end of results) break raise e urls = [video.url for video in data.videos] if limit is not None: urls = list(islice(urls, 0, limit - counter)) for url in urls: logger.info(f"doing item [{counter}]") # pylint: disable=broad-except # noinspection PyBroadException try: youtube_dl_download_url(url) except Exception as e: errors += 1 exceptions.append(e) except_urls.append(url) counter += 1 page += 1 if counter == limit: break if errors > 0: logger.info(f"number of errors [{errors}]") logger.info(f"except_urls [{except_urls}]")
def download() -> None: """ Download movies from pornhub """ logger = logging.getLogger(__name__) api = PornhubApi() limit = ConfigPornhubSearch.limit page = 1 counter = 0 errors = 0 exceptions = [] except_urls = [] while True: kwargs = dict() if ConfigPornhubSearch.use_ordering: kwargs["ordering"] = ConfigPornhubSearch.ordering if ConfigPornhubSearch.use_period: kwargs["period"] = ConfigPornhubSearch.period if ConfigPornhubSearch.use_tags: kwargs["tags"] = ConfigPornhubSearch.tags try: data = api.search.search( ConfigPornhubSearch.query, page=page, **kwargs, ) except ValueError as e: code = e.args[0]["code"] if code == "2001": # no videos found (end of results) break else: raise e urls = [video.url for video in data.videos] if limit is not None: urls = list(islice(urls, 0, limit - counter)) for url in urls: logger.info("doing item [{}]".format(counter)) # noinspection PyBroadException try: youtube_dl_download_url(url, ConfigDownload.folder) except Exception as e: errors += 1 exceptions.append(e) except_urls.append(url) counter += 1 page += 1 if counter == limit: break if errors > 0: logger.info("number of errors [{}]".format(errors)) logger.info("except_urls [{}]".format(except_urls))
def get_pornhub(count: int) -> pd.DataFrame: """PornHUB APIからビデオ情報を取得する Args: count (int): 取得件数 Returns: pd.DataFrame: API取得したビデオ情報を返却 """ from pornhub_api import PornhubApi from pornhub_api.backends.aiohttp import AioHttpBackend api = PornhubApi() category = "japanese" data = api.search.search( # "japanese", period="day", category=[category] # tags=["japanese"], # ordering="rating" ) THUMBNAIL_URL = "https://ci.phncdn.com/" video_list: list[str] = [] for video in data.videos[:count]: data = { "title": video.title, "publish_date": video.publish_date, "views": video.views, "rating": float(video.rating), "duration": video.duration, "url": "https://www.pornhub.com/view_video.php?" + video.url.query, "image1": THUMBNAIL_URL + video.thumbs[0].src.path, "image2": THUMBNAIL_URL + video.thumbs[2].src.path, "image3": THUMBNAIL_URL + video.thumbs[4].src.path, "image4": THUMBNAIL_URL + video.thumbs[6].src.path, "image5": THUMBNAIL_URL + video.thumbs[8].src.path, "image6": THUMBNAIL_URL + video.thumbs[10].src.path, "image7": THUMBNAIL_URL + video.thumbs[12].src.path, "image8": THUMBNAIL_URL + video.thumbs[14].src.path, } video_list.append(data) video_list_df = pd.DataFrame(video_list) # 辞書のリストからDF生成 video_list_df = video_list_df.sort_values(["rating", "views"], ascending=False) logger.info(f"pornhub video category: {category}") return video_list_df
def search(key): api = PornhubApi() search = api.search.search(key) videos = search.videos PornHubVideoGroupInfo = jclass("com.epiphany.callshow.model.PornHubVideoGroupInfo") PornHubVideoInfo = jclass("com.epiphany.callshow.model.PornHubVideoInfo") groupInfo = PornHubVideoGroupInfo() for i in videos: info = PornHubVideoInfo() info.setTitle(i.title) info.setDuration(i.duration) info.setVideo_id(i.video_id) videoPath = i.url.scheme + "://" + i.url.host + i.url.path + "?" + i.url.query info.setVideoRealPath(videoPath) # download_pornhub.logPrintMsg(videoPath) imagePath = i.default_thumb.scheme + "://" + i.default_thumb.host + i.default_thumb.path info.setImagePath(imagePath) groupInfo.addItem(info) return groupInfo
async def inline_id_handler(event: events.InlineQuery.Event): event.builder results = [] input_str = event.pattern_match.group(1) api = PornhubApi() data = api.search.search(input_str, ordering="mostviewed") ok = 1 for vid in data.videos: if ok <= 5: lul_m = f"**P**N-HUB SEARCH** \n**Video title :** `{vid.title}` \n**Video link :** `https://www.pornhub.com/view_video.php?viewkey={vid.video_id}`" results.append(await event.builder.article( title=vid.title, text=lul_m, buttons=[ Button.switch_inline("Search Again", query="ph ", same_peer=True) ], )) else: pass await event.answer(results)
def pornhub_stars_all_detailed(): api = PornhubApi() print_stars_all_detailed(api)
def pornhub_stars_all_detailed(): """ print stars all detailed """ api = PornhubApi() print_stars_all_detailed(api)
async def __call__(self): def video_embed(video) -> Embed: embed = Embed(title=video.title) embed.add_field(name="Video ID", value=video.video_id) embed.add_field(name="Views", value=video.views) embed.add_field(name="Rating", value=video.rating) embed.add_field( name="Pornstars", value=", ".join( [pornstar.pornstar_name for pornstar in video.pornstars] ) if video.pornstars != [] else "None listed", ) embed.add_field( name="Publish Date", value=video.publish_date.strftime("%m/%d/%Y") ) embed.add_field(name="Duration", value=video.duration) embed.add_field( name="Tags", value=", ".join( [tag.tag_name for tag in video.tags] if video.tags != [] else "None listed" ), inline=False, ) embed.set_thumbnail( url=f"{video.default_thumb.scheme}://{video.default_thumb.host}/{video.default_thumb.path}" ) embed.url = f"{video.url.scheme}://{video.url.host}{video.url.path}?viewkey={video.video_id}" return embed try: data = PornhubApi().search.search(self.query).videos[0:10] embeds = list(map(video_embed, data)) for index, item in enumerate(embeds): item.set_footer( text=f"Page {index+1}/{len(embeds)}\nRequested by: {str(self.ctx.author)}" ) # sets the reactions for the search result if len(embeds) > 1: buttons = [[ {Button(style=ButtonStyle.grey, label="◀️", custom_id="◀️"): None}, {Button(style=ButtonStyle.red, label="🗑️", custom_id="🗑️"): None}, {Button(style=ButtonStyle.grey, label="▶️", custom_id="▶️"): None} ]] else: buttons = [[ Button(style=ButtonStyle.red, label="🗑️", custom_id="🗑️") ]] await Sudo.multi_page_system(self.bot, self.ctx, self.message, tuple(embeds), buttons) return except TimeoutError: raise except (CancelledError, discord_error.NotFound): pass except Exception as e: await self.message.delete() await error_handler(self.bot, self.ctx, e, self.query) finally: await self.message.clear_reactions() return
async def api(): backend = AioHttpBackend() yield PornhubApi(backend=backend) await backend.close()
from pornhub_api import PornhubApi import asyncio from pornhub_api.backends.aiohttp import AioHttpBackend api = PornhubApi() def getEroVideo(words): data = api.search.search( words, ordering="mostviewed", period="weekly", tags=["japanese"], ) videos = data.videos return videos
def api(): return PornhubApi()