try:
	import requests  ,re, os , sys , random , uuid , user_agent , json,secrets,secrets
	from uuid import uuid4
	from secrets import *
	from user_agent import generate_user_agent
	import requests
	import names
	import uuid,string
	import instaloader
	import hashlib
	import urllib
	import mechanize
	import json
	import secrets
	import smtplib
    
	
except ImportError:
	os.system('pip install requests')

	
	
uid = str(uuid4)
class salammzere3:
	
	def Instalogin(email,password):
		
		UrlSalam = 'https://www.instagram.com/accounts/login/ajax/'
		
		HeadSalam = {

    'accept':'*/*',
    'accept-encoding':'gzip, deflate, br',
    'accept-language':'ar-AE,ar;q=0.9,en-US;q=0.8,en;q=0.7',
    'content-length':'317',
    'content-type':'application/x-www-form-urlencoded',
    'cookie':'mid=YdduAwAEAAH5tvQgBxaWFmtCauW1; ig_did=3B9E189F-664C-4C27-BAD4-A4DC839FFFFA; ig_nrcb=1; shbid="15789\0545722116218\0541674148260:01f7b34891a790ddc3b2f8f61b0c76d2e539c3efaedb09b6812283940bfcc6739f7a6930"; shbts="1642612260\0545722116218\0541674148260:01f74a3f9c5b7857cd36ad8a36a61bbe4bcc22061a61a730590ea1f665bd85916ae193b4"; csrftoken=qMiGRabzXyZlJPciGxtTKQAJZkCv0Rhi',
    'origin':'https://www.instagram.com',
    'referer':'https://www.instagram.com/',
    'sec-fetch-dest':'empty',
    'sec-fetch-mode':'cors',
    'sec-fetch-site':'same-origin',
    'user-agent':generate_user_agent(),
    'x-asbd-id':'198387',
    'x-csrftoken':'qMiGRabzXyZlJPciGxtTKQAJZkCv0Rhi',
    'x-ig-app-id':'936619743392459',
    'x-ig-www-claim':'0',
    'x-instagram-ajax':'9e76603e49dc',
    'x-requested-with':'XMLHttpRequest'}
    
		DatSalam = {
	'username': email,
	'enc_password': '#PWD_INSTAGRAM_BROWSER:0:&:'+ password
	}
		ReqSalam = requests.post(UrlSalam,headers=HeadSalam,data=DatSalam)
		if ('"authenticated":true') in ReqSalam.text:
			
			
			os.system('rm -rf sessionid.txt')
			
			APK = ReqSalam.cookies['sessionid']
			
			f = open('sessionid.txt','a')
			
			f.write(APK+"\n")
			
			f.close()
			
			return {'status':'Success','login':'true','sessionid':str(APK)}
			
		if str('"message":"challenge_required","challenge"') in ReqSalam.text:
			
			return {'status':'challenge_required'}
			
		else:
			
			return {'status':'error_login'}
		


	def gmail(email):
	    url = 'https://android.clients.google.com/setup/checkavail'
	    headers = {
		'Content-Length':'98',
		'Content-Type':'text/plain; charset=UTF-8',
		'Host':'android.clients.google.com',
		'Connection':'Keep-Alive',
		'user-agent':'GoogleLoginService/1.3(m0 JSS15J)',}
	    data = json.dumps({
		'username':str(email),
		'version':'3',
		'firstName':'GDO_0',
		'lastName':'GDOTools' })
	    res = requests.post(url,data=data,headers=headers)
	    if res.json()['status'] == 'SUCCESS':
	           return {'status':'Success','email':True}
	           
	    else:
	           return {'status':'error','email':False}
            
	def instagram(email):
	    headers = {
            # 'Content-Length': '143',
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'Host': 'i.instagram.com',
            'Connection': 'Keep-Alive',
            'User-Agent': 'Instagram 6.12.1 Android (25/7.1.2; 160dpi; 383x681; LENOVO/Android-x86; 4242ED1; x86_64; android_x86_64; en_US)',
            'Accept-Language': 'en-US',
            'X-IG-Connection-Type': 'WIFI',
            'X-IG-Capabilities': 'AQ==',
            # 'Accept-Encoding': 'gzip',
        }

	    data = {
            'ig_sig_key_version': '4',
            "q": f"{email}"
        }

	    response = requests.post('https://i.instagram.com/api/v1/users/lookup/', headers=headers, data=data).text
	    if "ok" in response:
	       return {'email': email,'status':'True'}
	    else:
	        return {'email': email,'status':'False'}
	        
	        
	def tiktok(email):
	    url = "https://www.tiktok.com/passport/web/user/check_email_registered?shark_extra=%7B%22aid%22%3A1459%2C%22app_name%22%3A%22Tik_Tok_Login%22%2C%22app_language%22%3A%22en%22%2C%22device_platform%22%3A%22web_mobile%22%2C%22region%22%3A%22SA%22%2C%22os%22%3A%22ios%22%2C%22referer%22%3A%22https%3A%2F%2Fwww.tiktok.com%2Fprofile%22%2C%22root_referer%22%3A%22https%3A%2F%2Fwww.google.com%22%2C%22cookie_enabled%22%3Atrue%2C%22screen_width%22%3A390%2C%22screen_height%22%3A844%2C%22browser_language%22%3A%22en-us%22%2C%22browser_platform%22%3A%22iPhone%22%2C%22browser_name%22%3A%22Mozilla%22%2C%22browser_version%22%3A%225.0%20%28iPhone%3B%20CPU%20iPhone%20OS%2014_4%20like%20Mac%20OS%20X%29%20AppleWebKit%2F605.1.15%20%28KHTML%2C%20like%20Gecko%29%20Version%2F14.0.3%20Mobile%2F15E148%20Safari%2F604.1%22%2C%22browser_online%22%3Atrue%2C%22timezone_name%22%3A%22Asia%2FRiyadh%22%2C%22is_page_visible%22%3Atrue%2C%22focus_state%22%3Atrue%2C%22is_fullscreen%22%3Afalse%2C%22history_len%22%3A17%2C%22battery_info%22%3A%7B%7D%7D&msToken=vPgBDLGXZNEf56bl_V4J6muu5nAYCQi5dA6zj49IuWrw2DwDUZELsX2wz2_2ZYtzkbUF9UyblyjQTsIDI5cclvJQ6sZA-lHqzKS1gLIJD9M6LDBgII0nxKqCfwwVstZxhpppXA==&X-Bogus=DFSzsIVLC8A-dJf6SXgssmuyRsO1&_signature=_02B4Z6wo00001dTdX3QAAIDBDn9.7WbolA3U3FvAABfU8c"
	    data = f"email={email}&aid=1459&language=en&account_sdk_source=web&region=SA"
	    hed = {
		"User-Agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1"}
		
	    r = requests.post(url,headers=hed,data=data)
	    if '{"is_registered":1}' in r.text:
	        return {"status":"register","email":email}
		    
	    elif '{"is_registered":0}' in r.text:
	        return {"status":"not_register","email":email}
		    
	    else:
	        return {"status":"error","email":email}



	def logintiktok(email,password):
	    url = 'https://api2.musical.ly/passport/user/login/?mix_mode=1&username=1&email=&mobile=&account=&password=hg&captcha=&ts=&app_type=normal&app_language=en&manifest_version_code=2018073102&_rticket=1633593458298&iid=7011916372695598854&channel=googleplay&language=en&fp=&device_type=SM-G955F&resolution=1440*2792&openudid=91cac57ba8ef12b6&update_version_code=2018073102&sys_region=AS&os_api=28&is_my_cn=0&timezone_name=Asia/Muscat&dpi=560&carrier_region=OM&ac=wifi&device_id=6785177577851504133&mcc_mnc=42203&timezone_offset=14400&os_version=9&version_code=800&carrier_region_v2=422&app_name=musical_ly&version_name=8.0.0&device_brand=samsung&ssmix=a&build_number=8.0.0&device_platform=android&region=US&aid=&as=&cp=Qm&mas='
	    headers = \
            {'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
            'accept-encoding': 'gzip, deflate, br', 'accept-language': 'en-US,en;q=0.9,ar;q=0.8',
            'cookie': 'csrftoken=' + str(secrets.token_hex(8) * 2) + '; sessionid=' + str(secrets.token_hex(8) * 2) + ';',
            'User-Agent': 'Connectionzucom.zhiliaoapp.musically/2018073102 (Linux; U; Android 9; en_AS; SM-G955F; Build/PPR1.180610.011; Cronet/58.0.2991.0)z',
            'Host': 'api2.musical.ly', 'Connection': 'keep-alive'}
	    data = {"email": str(email), "password": str(password)}
	    res = requests.post(url, headers=headers, data=data)
	    if ("user_id") in res.text:
	        sessionid = str(res.json()['data']['session_key'])
	        return {'username': str(email), 'password': str(password), 'status': 'True', 'SessionId': sessionid}
	        
	    elif ("Incorrect account or password") in res.text:
	       return {'username': str(email), 'password': str(password), 'status' :'Error Password Or Username'}
	    else:
	        return {'username': str(email), 'password': str(password), 'status' :'False'}
	        
	  
	  
	def hotmail(email):
	    url = "https://odc.officeapps.live.com/odc/emailhrd/getidp?hm=0&emailAddress=" + str(email) + "&_=1604288577990"
	    headers = {
    	    "Accept": "*/*",
            "Content-Type": "application/x-www-form-urlencoded",
            "User-Agent": str(generate_user_agent()),
            "Connection": "close",
            "Host": "odc.officeapps.live.com",
            "Accept-Encoding": "gzip, deflate",
            "Referer": "https://odc.officeapps.live.com/odc/v2.0/hrd?rs=ar-sa&Ver=16&app=23&p=6&hm=0",
            "Accept-Language": "ar,en-US;q=0.9,en;q=0.8",
            "canary": "BCfKjqOECfmW44Z3Ca7vFrgp9j3V8GQHKh6NnEESrE13SEY/4jyexVZ4Yi8CjAmQtj2uPFZjPt1jjwp8O5MXQ5GelodAON4Jo11skSWTQRzz6nMVUHqa8t1kVadhXFeFk5AsckPKs8yXhk7k4Sdb5jUSpgjQtU2Ydt1wgf3HEwB1VQr+iShzRD0R6C0zHNwmHRnIatjfk0QJpOFHl2zH3uGtioL4SSusd2CO8l4XcCClKmeHJS8U3uyIMJQ8L+tb:2:3c",
            "uaid": "d06e1498e7ed4def9078bd46883f187b",
            "Cookie": "xid=d491738a-bb3d-4bd6-b6ba-f22f032d6e67&&RD00155D6F8815&354"}
	    res = requests.post(url, data="", headers=headers).text
	    if ("Neither") in res:
	        return {'status': 'Success', 'email': 'True'}
	    else:
	        return {'email': email,'status':'False'}

	    
	    
	    
	def Send_Reset(email):
	    uidd = str(uuid4)
	    
	    url = 'https://i.instagram.com/api/v1/accounts/send_password_reset/'
	    headers = {
    "Content-Length": "325",
    "Content-Type": "application/x-www-form-urlencoded; charset\u003dUTF-8",
    "Host": "i.instagram.com",
    "Connection": "Keep-Alive",
    "User-Agent": "Instagram 6.12.1 Android (30/11; 280dpi; 720x1339; samsung; SM-A115F; a11q; qcom; ar_AE)",
    "Cookie": "mid\u003dYuNHpwABAAHN0phpxYgGf2YLosTU; csrftoken\u003dupWgl5AujnKWZVrYTSGeHBdxN3XyBQC9",
    "Cookie2": "$Version\u003d1",
    "Accept-Language": "ar-AE, en-US",
    "X-IG-Connection-Type": "WIFI",
    "X-IG-Capabilities": "AQ\u003d\u003d",
    "Accept-Encoding": "gzip"}
    
	    data = {
'ig_sig_key_version':'4',
'user_email':email,
'device_id':uidd}
	    req = requests.post(url,headers=headers,data=data).text
	    if 'ok' in req:
	        return {'status': 'Success', 'email': email}
	        
	    else:
	        return {'status': 'error', 'email': email}
	        
	        
class info_insta:


    def followers(user: str) -> str:
        s = instaloader.Instaloader()
        info = instaloader.Profile.from_username(s.context, user)
        try:
            followers = info.followers
            return str(followers)

        except:
            return False

    def following(user: str) -> str:
        s = instaloader.Instaloader()
        profile = instaloader.Profile.from_username(s.context, user)
        try:
            following = info.followees
            return str(following)

        except:
            return False

    def posts(user: str) -> str:
        s = instaloader.Instaloader()
        info = instaloader.Profile.from_username(s.context, user)
        try:
            posts = info.mediacount
            return str(posts)

        except:
            return False

    def id(user: str) -> str:
    	url = "https://i.instagram.com/api/v1/users/lookup/"
    	headers = {'Host': 'i.instagram.com',
                'Connection':'keep-alive',
                'X-IG-Connection-Type': 'WIFI',
                'X-IG-Capabilities': '3Ro=',
                'Accept-Language': 'en-US',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                'User-Agent': 'Instagram 9.7.0 Android (28/9; 420dpi; 1080x2131; samsung; SM-A505F; a50; exynos9610; en_US)',
                'Accept-Encoding': 'gzip, deflatet'}
    	data = 'signed_body=acd10e3607b478b845184ff7af8d796aec14425d5f00276567ea0876b1ff2630.%7B%22_csrftoken%22%3A%22rZj5Y3kci0OWbO8AMUi0mWwcBnUgnJDY%22%2C%22q%22%3A%22'+str(user)+'%22%2C%22_uid%22%3A%226758469524%22%2C%22guid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%2C%22device_id%22%3A%22android-1a9898fad127fa2a%22%2C%22_uuid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%7D&ig_sig_key_version=4' ;      	res = requests.post(url,headers=headers,data=data).json()
    	try:
    		id = res['user']['pk']
    		return id
    	
    	except KeyError:
    		return False

    def name(user: str) -> str:
    	url = "https://i.instagram.com/api/v1/users/lookup/"
    	headers = {'Host': 'i.instagram.com',
                'Connection':'keep-alive',
                'X-IG-Connection-Type': 'WIFI',
                'X-IG-Capabilities': '3Ro=',
                'Accept-Language': 'en-US',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                'User-Agent': 'Instagram 9.7.0 Android (28/9; 420dpi; 1080x2131; samsung; SM-A505F; a50; exynos9610; en_US)',
                'Accept-Encoding': 'gzip, deflatet'}
    	data = 'signed_body=acd10e3607b478b845184ff7af8d796aec14425d5f00276567ea0876b1ff2630.%7B%22_csrftoken%22%3A%22rZj5Y3kci0OWbO8AMUi0mWwcBnUgnJDY%22%2C%22q%22%3A%22'+str(user)+'%22%2C%22_uid%22%3A%226758469524%22%2C%22guid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%2C%22device_id%22%3A%22android-1a9898fad127fa2a%22%2C%22_uuid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%7D&ig_sig_key_version=4' ;      	res = requests.post(url,headers=headers,data=data).json()
    	try:
    		id = res['user']['full_name']
    		return id
    	
    	except KeyError:
    		return False
    
    
    def profile(user: str) -> str:
    	url = "https://i.instagram.com/api/v1/users/lookup/"
    	headers = {'Host': 'i.instagram.com',
                'Connection':'keep-alive',
                'X-IG-Connection-Type': 'WIFI',
                'X-IG-Capabilities': '3Ro=',
                'Accept-Language': 'en-US',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                'User-Agent': 'Instagram 9.7.0 Android (28/9; 420dpi; 1080x2131; samsung; SM-A505F; a50; exynos9610; en_US)',
                'Accept-Encoding': 'gzip, deflatet'}
    	data = 'signed_body=acd10e3607b478b845184ff7af8d796aec14425d5f00276567ea0876b1ff2630.%7B%22_csrftoken%22%3A%22rZj5Y3kci0OWbO8AMUi0mWwcBnUgnJDY%22%2C%22q%22%3A%22'+str(user)+'%22%2C%22_uid%22%3A%226758469524%22%2C%22guid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%2C%22device_id%22%3A%22android-1a9898fad127fa2a%22%2C%22_uuid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%7D&ig_sig_key_version=4' ;      	res = requests.post(url,headers=headers,data=data).json()
    	try:
    		profile = res['user']['profile_pic_url']
    		return profile
    	
    	except KeyError:
    		return False

    def date(user: str) -> str:
        url = "https://i.instagram.com/api/v1/users/lookup/"
        headers = {'Host': 'i.instagram.com',
                'Connection':'keep-alive',
                'X-IG-Connection-Type': 'WIFI',
                'X-IG-Capabilities': '3Ro=',
                'Accept-Language': 'en-US',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                'User-Agent': 'Instagram 9.7.0 Android (28/9; 420dpi; 1080x2131; samsung; SM-A505F; a50; exynos9610; en_US)',
                'Accept-Encoding': 'gzip, deflatet'}
        data = 'signed_body=acd10e3607b478b845184ff7af8d796aec14425d5f00276567ea0876b1ff2630.%7B%22_csrftoken%22%3A%22rZj5Y3kci0OWbO8AMUi0mWwcBnUgnJDY%22%2C%22q%22%3A%22'+user+'%22%2C%22_uid%22%3A%226758469524%22%2C%22guid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%2C%22device_id%22%3A%22android-1a9898fad127fa2a%22%2C%22_uuid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%7D&ig_sig_key_version=4' ;             res = requests.post(url,headers=headers,data=data).json()
        try:
        	pk = res['user']['pk']
        	get = "https://o7aa.pythonanywhere.com/?id="+str(pk)
        	head = {
            'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
            'Accept-Encoding': 'gzip, deflate, br',
            'Accept-Language': 'en-US,en;q=0.9,ar;q=0.8',
            'Connection': 'keep-alive',
            'Host': 'o7aa.pythonanywhere.com',
            'User-Agent': str(generate_user_agent())}
        	res = requests.get(get, headers=head).json()
        	return str(res["data"])

        except:
        	return False

    def bio(user: str) -> str:
        s = instaloader.Instaloader()
        info = instaloader.Profile.from_username(s.context, user)
        try:
            bio = info.biography
            return str(bio)

        except:
            return False

    def private(user: str) -> str:
        url = "https://i.instagram.com/api/v1/users/lookup/"
        headers = {'Host': 'i.instagram.com',
                'Connection':'keep-alive',
                'X-IG-Connection-Type': 'WIFI',
                'X-IG-Capabilities': '3Ro=',
                'Accept-Language': 'en-US',
                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
                'User-Agent': 'Instagram 9.7.0 Android (28/9; 420dpi; 1080x2131; samsung; SM-A505F; a50; exynos9610; en_US)',
                'Accept-Encoding': 'gzip, deflatet'}
        data = 'signed_body=acd10e3607b478b845184ff7af8d796aec14425d5f00276567ea0876b1ff2630.%7B%22_csrftoken%22%3A%22rZj5Y3kci0OWbO8AMUi0mWwcBnUgnJDY%22%2C%22q%22%3A%22'+user+'%22%2C%22_uid%22%3A%226758469524%22%2C%22guid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%2C%22device_id%22%3A%22android-1a9898fad127fa2a%22%2C%22_uuid%22%3A%22a475d908-a663-4895-ac60-c0ab0853d6df%22%7D&ig_sig_key_version=4' ;             res = requests.post(url,headers=headers,data=data).json()
        try:
            private = str(res['graphql']['user']['is_private'])
            return private

        except:
            return False


class session_insta:
    
    def login(session: str) -> str:
        url = "https://i.instagram.com/api/v1/accounts/current_user/?edit=true"
        headers = {
            'X-IG-Connection-Type': 'WIFI',
            'X-IG-Capabilities': '3brTBw==',
            'User-Agent': 'Instagram 9.7.0 Android (28/9; 420dpi; 1080x2131; samsung; SM-A505F; a50; exynos9610; en_US)',
            'Accept-Language': 'en-US',
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'Accept-Encoding': 'gzip, deflate',
            'Host': 'i.instagram.com',
            'Connection': 'keep-alive',
            'Accept': '*/*'}
        cookies = {"sessionid": str(session)}
        res = requests.get(url, headers=headers, cookies=cookies).json()
        if str('message') in res:
            return {'status': 'error', 'login': 'error_session'}

        else:
            username = res['user']['username']
            id = res['user']['pk']
            full_name = res['user']['full_name']
            profile = res['user']['profile_pic_url']
            private = res['user']['is_private']
            following = info_insta.following(username)
            followers = info_insta.followers(username)
            date = info_insta.date(username)
            return {'status':'Success','username':str(username),'id':str(id),'name':str(full_name),'following':str(following),'followers':str(followers),'date':str(date),'private':str(private),'profile':str(profile),'sessionid':str(session)}


