mirror of
https://gitlab.com/moepoi/HanimeTV.git
synced 2024-11-14 02:56:16 +01:00
Added login
This commit is contained in:
parent
2798a36217
commit
af8881bf0a
1 changed files with 21 additions and 17 deletions
|
@ -17,28 +17,32 @@ class HanimeTV:
|
||||||
if email is None and password is None:
|
if email is None and password is None:
|
||||||
self.session = ''
|
self.session = ''
|
||||||
else:
|
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:
|
try:
|
||||||
self.session = json.loads(req.text)["session_token"]
|
login = self.login(email, password)
|
||||||
|
self.session = login["session_token"]
|
||||||
except:
|
except:
|
||||||
print ("Invalid Credential")
|
print ("Invalid Credential")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
def login(self, email, password):
|
||||||
|
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)
|
||||||
|
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://thorin-us-east-1.searchly.com/hentai_videos/hentai_video/_search?from=0&size=48"
|
||||||
token = "cHVibGljOmlscXd3a2s3Znpxb3Bzand3MXVkcm1yZHQwdDlnb2Mz"
|
token = "cHVibGljOmlscXd3a2s3Znpxb3Bzand3MXVkcm1yZHQwdDlnb2Mz"
|
||||||
|
|
Loading…
Reference in a new issue