Nekopoi / nekopoi.py
GilbertClaus's picture
Update nekopoi.py
af993e0 verified
import cloudscraper
from curl_cffi import requests
from bs4 import BeautifulSoup
from urllib.parse import urlparse
from others import *
scraper = cloudscraper.create_scraper()
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def info_nekopoi(soup):
# Get title
title = soup.find('title').text
# Get thumbnail_url
thumbnail_url = soup.select_one('div.imgdesc img')['src']
# Get producers
producers_element = soup.find_all('li')
for li in producers_element:
if li.find('b', string='Produser'):
producers = li.text.split(': ')[1]
# Get genre
genres = []
genre_elements = soup.find_all('li')
for li in genre_elements:
if li.find('b', string='Genres'):
genres.extend([a.text for a in li.find_all('a', rel='tag')])
genre = ', '.join(genres)
# Get sinopsis
sinopsis_element = soup.select_one('span.desc')
sinopsis = sinopsis_element.find('p').text
return title, thumbnail_url, producers, genre, sinopsis
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def episode_nekopoi(resolusi, soup):
judul = soup.find('title').text.replace('[NEW Release] ','')
if 'Episode' in judul:
episode = judul.split('Episode')[1].split()[0]
if len(episode) == 1:
episode = '0' + episode
else:
episode = ''
if "PV" in judul:
episode = episode + " PV"
link_info = soup.find('div', class_='name', string=lambda t: t and f'[{resolusi}p]' in t)
if link_info:
link_eps = link_info.find_next('a', string=lambda x: x and ('Mirror [ouo]' in x or 'MC [ouo]' in x or 'Mirror[ouo]' in x or 'MC[ouo]' in x))['href']
else:
link_eps = ''
return judul, episode, link_eps
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def get_genre():
url = 'https://nekopoi.care/genre-list/'
genres = []
response = scraper.get(url)
html = response.text
soup = BeautifulSoup(html, 'html.parser')
links = soup.find_all('a')
for link in links:
href = link.get('href')
if href and 'https://nekopoi.care/genres/' in href:
genre = href.split('/')[-2].replace('-',' ').title()
genres.append(genre)
return genres
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def info_series(resolution, series):
episode = []
for url in series:
response = scraper.get(url)
html = response.text
soup = BeautifulSoup(html, 'html.parser')
links = soup.find_all('a')
episode_links = []
for link in links:
href = link.get('href')
if href and 'https://nekopoi.care/' in href and ('episode' in href and 'subtitle-indonesia' in href) and 'pv' not in href:
if link.parent.get('class') != ['latestnow']:
episode_links.append(href)
episode.append(episode_links)
info = ""
for i, url in enumerate(series):
response = scraper.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# Get the variables
title, thumbnail, producers, genre, sinopsis = info_nekopoi(soup)
info += f"Judul : {title.replace(' – NekoPoi','')}\n"
info += f"Thumbnail : {thumbnail}\n"
info += f"Producer : {producers}\n"
info += f"Genre : {genre}\n"
info += f"Sinopsis : \n"
info += f"{sinopsis}\n"
info += "==================================================================================\n"
for url in episode[i]:
response = scraper.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
# Get the variables
judul, eps, link = episode_nekopoi(resolution, soup)
if link != '':
link = ouo_bypass(link)
link = mirrored(link)
info += f"Link Episode {eps} : {link}\n"
info += "==================================================================================\n"
return info
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def judul(cari, resolution, halaman):
search = 'https://nekopoi.care/search/' + cari.replace(' ', '+') + '/page/{}/'
# Create an empty list to store the series links
series = []
# Iterate over the pages
for page in range(1, halaman+1):
# Set the URL of the current page
url = search.format(page)
# Send a GET request to the website and get the HTML response
response = scraper.get(url)
html = response.text
# Parse the HTML using BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
# Find all links in the HTML
links = soup.find_all('a')
# Iterate over the links
for link in links:
# Get the href attribute of the link
href = link.get('href')
# Check if the href attribute
if href and 'https://nekopoi.care/hentai/' in href:
# Add the link to the list of series links
series.append(href)
# Reverse the order of the series links in the list
# series.reverse()
info = info_series(resolution, series)
lokasi_file = simpan_txt(cari, info)
return info, lokasi_file
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def beranda(resolution):
url = 'https://nekopoi.care/'
series = []
response = scraper.get(url)
html = response.text
soup = BeautifulSoup(html, 'html.parser')
links = soup.find_all('a')
h1 = soup.find('h1')
for a in h1.find_all_next('a', href=True):
if 'https://nekopoi.care/hentai/' in a['href']:
series.append(a['href'])
if len(series) == 5:
break
info = info_series(resolution, series)
lokasi_file = simpan_txt('Beranda', info)
return info, lokasi_file
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def acak(resolution):
url = 'https://nekopoi.care/random'
series = []
response = scraper.get(url)
series.append(response.url)
info = info_series(resolution, series)
lokasi_file = simpan_txt('Acak', info)
return info, lokasi_file
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def genre(cari, resolution, halaman):
search = 'https://nekopoi.care/genres/' + cari.lower().replace(' ', '-') + '/page/{}/'
# Create an empty list to store the series links
series = []
# Iterate over the pages
for page in range(1, halaman+1):
# Set the URL of the current page
url = search.format(page)
# Send a GET request to the website and get the HTML response
response = scraper.get(url)
html = response.text
# Parse the HTML using BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
# Find all links in the HTML
links = soup.find_all('a')
# Iterate over the links
for link in links:
# Get the href attribute of the link
href = link.get('href')
# Check if the href attribute
if href and 'https://nekopoi.care/hentai/' in href:
# Add the link to the list of series links
series.append(href)
# Reverse the order of the series links in the list
# series.reverse()
info = info_series(resolution, series)
lokasi_file = simpan_txt(cari, info)
return info, lokasi_file
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def bulk_nekopoi(cari, resolution, halaman, choice):
info = ""
# Create an empty list to store the series links
links_list = []
if 'https://nekopoi.care' in cari:
links_list.append(cari)
else:
search = 'https://nekopoi.care/search/' + cari.replace(' ', '+') + '/page/{}/'
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Iterate over the pages
for page in range(1, halaman+1):
# Set the URL of the current page
url = search.format(page)
# Send a GET request to the website and get the HTML response
response = scraper.get(url)
html = response.text
# Parse the HTML using BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
# Find all links in the HTML
links = soup.find_all('a')
# Iterate over the links
for link in links:
# Get the href attribute of the link
href = link.get('href')
# Check if the href attribute
if 'new-release' in choice or 'uncensored' in choice:
if href and 'https://nekopoi.care/' in href and ('episode' in href and 'subtitle-indonesia' in href) and not ('jadwal' in href or 'genres' in href or 'list' in href or 'category' in href or 'search' in href) :
# Check if the link is already in the list of links
if href not in links_list:
# Add the link to the list of links
links_list.append(href)
elif '2d' in choice or '3d' in choice:
if href and 'https://nekopoi.care/' in href and ('2d' in href or '3d' in href) and not ('jadwal' in href or 'genres' in href or 'list' in href or 'category' in href or 'search' in href) :
# Check if the link is already in the list of links
if href not in links_list:
# Add the link to the list of links
links_list.append(href)
elif 'jav' in choice:
if href and 'https://nekopoi.care/' in href and ('jav' in href) and not ('jadwal' in href or 'genres' in href or 'list' in href or 'category' in href or 'search' in href) :
# Check if the link is already in the list of links
if href not in links_list:
# Add the link to the list of links
links_list.append(href)
x = 0
# Iterate over the links
for url in links_list:
# Send a GET request to the website and get the HTML response
response = scraper.get(url)
html = response.text
# Parse the HTML using BeautifulSoup
soup = BeautifulSoup(html, 'html.parser')
# Dapatkan variabel
judul, eps, link = episode_nekopoi(resolution, soup)
if link != '':
link = ouo_bypass(link)
link = mirrored(link)
info += f"Judul : {judul.replace(' – NekoPoi','')}\n"
info += f"Link : {link}\n"
x += 1
if x % 10 == 0:
info += "==================================================================================\n"
info += "==================================================================================\n"
lokasi_file = simpan_txt(cari, info)
return info, lokasi_file
# -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------