mirror of
https://gitlab.com/moepoi/HanimeTV.git
synced 2024-11-25 00:09:15 +01:00
Update script and add some new features
- Replace get with info - Added storyboards - Added download (STILL NOT WORKING)
This commit is contained in:
parent
34e654d3ae
commit
6fb05b4adf
1 changed files with 70 additions and 62 deletions
132
HTV/hanime.py
132
HTV/hanime.py
|
@ -13,7 +13,7 @@ License MIT
|
||||||
|
|
||||||
class HanimeTV:
|
class HanimeTV:
|
||||||
def __init__(self, email=None, password=None):
|
def __init__(self, email=None, password=None):
|
||||||
self.host = "https://hanime.tv"
|
self.host = "https://members.hanime.tv"
|
||||||
if email is None and password is None:
|
if email is None and password is None:
|
||||||
self.session = ''
|
self.session = ''
|
||||||
else:
|
else:
|
||||||
|
@ -24,10 +24,25 @@ class HanimeTV:
|
||||||
print ("Invalid Credential")
|
print ("Invalid Credential")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def login(self, email, password):
|
def pre_session(captcha_token):
|
||||||
url = "{}/api/v3/sessions".format(self.host)
|
url = self.host + "/api/v1/pre-session"
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0',
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
|
||||||
|
'Accept': 'application/json, text/plain, */*',
|
||||||
|
'Accept-Language': 'en-US,en;q=0.5',
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
"captcha_token": captcha_token
|
||||||
|
}
|
||||||
|
req = requests.post(url, headers=headers, json=data)
|
||||||
|
return json.loads(req.text)
|
||||||
|
|
||||||
|
def login(self, email, password):
|
||||||
|
url = self.host + "/api/v3/sessions"
|
||||||
|
captcha_token = "???" # NEED CAPTCHA TOKEN
|
||||||
|
pre_session = self.pre_session(captcha_token)
|
||||||
|
headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
|
||||||
'Accept': 'application/json, text/plain, */*',
|
'Accept': 'application/json, text/plain, */*',
|
||||||
'Accept-Language': 'en-US,en;q=0.5',
|
'Accept-Language': 'en-US,en;q=0.5',
|
||||||
'Referer': '{}/'.format(self.host),
|
'Referer': '{}/'.format(self.host),
|
||||||
|
@ -38,82 +53,42 @@ class HanimeTV:
|
||||||
}
|
}
|
||||||
data = {
|
data = {
|
||||||
"email": str(email),
|
"email": str(email),
|
||||||
"password": str(password)
|
"password": str(password),
|
||||||
|
"now": pre_session["now"],
|
||||||
|
"sign_in_token": pre_session["sign_in_token"]
|
||||||
}
|
}
|
||||||
req = requests.post(url, headers=headers, json=data)
|
req = requests.post(url, headers=headers, json=data)
|
||||||
return json.loads(req.text)
|
return json.loads(req.text)
|
||||||
|
|
||||||
def search(self, query):
|
def search(self, query):
|
||||||
url = "https://thorin-us-east-1.searchly.com/hentai_videos/hentai_video/_search?from=0&size=48"
|
url = "https://search.hanime.tv/"
|
||||||
token = "cHVibGljOmlscXd3a2s3Znpxb3Bzand3MXVkcm1yZHQwdDlnb2Mz"
|
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0',
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
|
||||||
'Accept': '*/*',
|
'Accept': 'application/json, text/plain, */*',
|
||||||
'Accept-Language': 'en-US,en;q=0.5',
|
'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',
|
'content-type': 'application/json',
|
||||||
'Origin': self.host,
|
'Origin': self.host,
|
||||||
'Connection': 'keep-alive',
|
'Connection': 'keep-alive',
|
||||||
'TE': 'Trailers'
|
'TE': 'Trailers'
|
||||||
}
|
}
|
||||||
data = {
|
data = {
|
||||||
"query": {
|
"search_text": str(query),
|
||||||
"bool": {
|
"tags": [],
|
||||||
"filter": {
|
"tags_mode": "OR",
|
||||||
"bool": {
|
"brands": [],
|
||||||
"minimum_should_match": 0,
|
"blacklist": [],
|
||||||
"must": [
|
"order_by": "created_at_unix",
|
||||||
{
|
"ordering": "desc",
|
||||||
"bool": {
|
"page": 0
|
||||||
"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)
|
req = requests.post(url, headers=headers, json=data)
|
||||||
return json.loads(req.text)
|
return json.loads(req.text)
|
||||||
|
|
||||||
def get(self, url):
|
def info(self, url):
|
||||||
query = url.replace("https://hanime.tv/hentai-videos/","")
|
query = url.split("/")[4]
|
||||||
url = "https://hanime.tv/api/v5/videos_manifests/" + query
|
url = self.host + "/api/v5/hentai-videos/" + query
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0',
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
|
||||||
'Accept': 'application/json, text/plain, */*',
|
'Accept': 'application/json, text/plain, */*',
|
||||||
'Accept-Language': 'en-US,en;q=0.5',
|
'Accept-Language': 'en-US,en;q=0.5',
|
||||||
'Referer': '{}/hentai-videos/{}'.format(self.host, query),
|
'Referer': '{}/hentai-videos/{}'.format(self.host, query),
|
||||||
|
@ -124,3 +99,36 @@ class HanimeTV:
|
||||||
}
|
}
|
||||||
req = requests.get(url, headers=headers)
|
req = requests.get(url, headers=headers)
|
||||||
return json.loads(req.text)
|
return json.loads(req.text)
|
||||||
|
|
||||||
|
def storyboards(self, url):
|
||||||
|
hid = self.info(url)["hentai_video"]["id"]
|
||||||
|
url = self.host + "/api/v1/hentai_video_storyboards?hv_id={}".format(str(hid))
|
||||||
|
headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
|
||||||
|
'Accept': 'application/json, text/plain, */*',
|
||||||
|
'Accept-Language': 'en-US,en;q=0.5',
|
||||||
|
'X-Session-Token': self.session,
|
||||||
|
'Connection': 'keep-alive',
|
||||||
|
'TE': 'Trailers'
|
||||||
|
}
|
||||||
|
req = requests.get(url, headers=headers)
|
||||||
|
return json.loads(req.text)
|
||||||
|
|
||||||
|
def download(self, url):
|
||||||
|
url = self.host + "/api/v1/downloads/" + url.split("/")[4]
|
||||||
|
captcha_token = "???" # NEED CAPTCHA TOKEN
|
||||||
|
headers = {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0',
|
||||||
|
'Accept': 'application/json, text/plain, */*',
|
||||||
|
'Accept-Language': 'en-US,en;q=0.5',
|
||||||
|
'X-Directive': 'api',
|
||||||
|
'X-Session-Token': self.session,
|
||||||
|
'Connection': 'keep-alive',
|
||||||
|
'TE': 'Trailers'
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
"auth_kind": "recaptcha",
|
||||||
|
"auth": captcha_token
|
||||||
|
}
|
||||||
|
req = requests.post(url, headers=headers, json=data)
|
||||||
|
return json.loads(req.text)
|
Loading…
Reference in a new issue