diff --git a/HTV/__init__.py b/HTV/__init__.py new file mode 100644 index 0000000..7398b68 --- /dev/null +++ b/HTV/__init__.py @@ -0,0 +1 @@ +from .hanime import HanimeTV \ No newline at end of file diff --git a/HTV/hanime.py b/HTV/hanime.py new file mode 100644 index 0000000..4b338a2 --- /dev/null +++ b/HTV/hanime.py @@ -0,0 +1,122 @@ +import requests +import sys + +try: + import ujson as json +except: + import json + +''' +Author : Moe Poi +License MIT +''' + +class HanimeTV: + def __init__(self, email=None, password=None): + self.host = "https://hanime.tv" + if email is None and password is None: + self.session = '' + else: + url = "{}/api/v3/sessions".format(self.host) + headers = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'en-US,en;q=0.5', + 'Referer': '{}/'.format(self.host), + 'Content-Type': 'application/json;charset=utf-8', + 'X-Directive': 'api', + 'Connection': 'keep-alive', + 'TE': 'Trailers' + } + data = { + "email": str(email), + "password": str(password) + } + req = requests.post(url, headers=headers, json=data) + try: + self.session = json.loads(req.text)["session_token"] + except: + print ("Invalid Credential") + sys.exit() + + def search(self, query): + url = "https://thorin-us-east-1.searchly.com/hentai_videos/hentai_video/_search?from=0&size=48" + token = "cHVibGljOmlscXd3a2s3Znpxb3Bzand3MXVkcm1yZHQwdDlnb2Mz" + headers = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0', + 'Accept': '*/*', + 'Accept-Language': 'en-US,en;q=0.5', + 'Referer': '{}/search?q={}'.format(self.host, str(query)), + 'Authorization': 'Basic {}'.format(str(token)), + 'content-type': 'application/json', + 'Origin': self.host, + 'Connection': 'keep-alive', + 'TE': 'Trailers' + } + data = { + "query": { + "bool": { + "filter": { + "bool": { + "minimum_should_match": 0, + "must": [ + { + "bool": { + "must": [] + } + } + ], + "must_not": None, + "should": [] + } + }, + "minimum_should_match": 1, + "should": [ + { + "wildcard": { + "name": { + "boost": 10, + "wildcard": "*{}*".format(str(query)) + } + } + }, + { + "match": { + "titles": "{}".format(str(query)) + } + }, + { + "wildcard": { + "tags_string": "{}*".format(str(query)) + } + } + ] + } + }, + "sort": [ + "_score", + { + "created_at_unix": { + "order": "desc" + } + } + ] + } + req = requests.post(url, headers=headers, json=data) + return json.loads(req.text) + + def get(self, url): + query = url.replace("https://hanime.tv/hentai-videos/","") + url = "https://hanime.tv/api/v5/videos_manifests/" + query + headers = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0', + 'Accept': 'application/json, text/plain, */*', + 'Accept-Language': 'en-US,en;q=0.5', + 'Referer': '{}/hentai-videos/{}'.format(self.host, query), + 'X-Directive': 'api', + 'X-Session-Token': self.session, + 'Connection': 'keep-alive', + 'TE': 'Trailers' + } + req = requests.get(url, headers=headers) + return json.loads(req.text) \ No newline at end of file diff --git a/HTV/requirements.txt b/HTV/requirements.txt new file mode 100644 index 0000000..2e521bc --- /dev/null +++ b/HTV/requirements.txt @@ -0,0 +1,2 @@ +requests +ujson \ No newline at end of file diff --git a/example.py b/example.py new file mode 100644 index 0000000..0db84a5 --- /dev/null +++ b/example.py @@ -0,0 +1,12 @@ +from HTV import HanimeTV + +# hentai = HanimeTV(email="EMAIL", password="PASS") +hentai = HanimeTV() + +# SEARCH +search = hentai.search("Imouto Paradise") +print (search) + +# GET INFO & DATA +get = hentai.get("https://hanime.tv/hentai-videos/imouto-paradise-1-ep-1") +print (get) \ No newline at end of file