Added login

This commit is contained in:
Moe Poi ~ 2019-01-12 00:50:43 +07:00
parent 2798a36217
commit af8881bf0a

View file

@ -17,6 +17,14 @@ class HanimeTV:
if email is None and password is None: if email is None and password is None:
self.session = '' self.session = ''
else: else:
try:
login = self.login(email, password)
self.session = login["session_token"]
except:
print ("Invalid Credential")
sys.exit()
def login(self, email, password):
url = "{}/api/v3/sessions".format(self.host) url = "{}/api/v3/sessions".format(self.host)
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:65.0) Gecko/20100101 Firefox/65.0',
@ -33,11 +41,7 @@ class HanimeTV:
"password": str(password) "password": str(password)
} }
req = requests.post(url, headers=headers, json=data) req = requests.post(url, headers=headers, json=data)
try: return json.loads(req.text)
self.session = json.loads(req.text)["session_token"]
except:
print ("Invalid Credential")
sys.exit()
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"