DarKnighTitan

main

Jan 3rd, 2021 (edited)
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 76.67 KB | None | 0 0
  1. #from assets import clear_screen
  2. import time
  3. start_up=time.time()
  4. ##import __main__
  5. ##def load_assets_main(file='',str_code=''):
  6. ##  """ can be used either file dir or string
  7. ##  file: file directory
  8. ##  str_code: string code
  9. ##  """
  10. ##  if str_code=='':
  11. ##      with open(file) as f:
  12. ##          exec(f.read(), __main__.__dict__)
  13. ##  elif file=='':
  14. ##      exec(str_code, __main__.__dict__)
  15. ##  else:
  16. ##      print("load_assets_main function can only have either file directory or string code as Arg")
  17. ##      raise AttributeError
  18.  
  19. from threading import Thread as Process
  20. # ld_assets=Process(target= load_assets_main, args=('assets.py',))
  21. # ld_assets.start()
  22.  
  23. # requirements requests, beautifulsoup4, comtypes, kivy, docutils, pygments, pypiwin32, kivy_deps.sdl2==0.1.*, kivy_deps.glew==0.1.*, pillow
  24.  
  25. cloud_data_link='https://pastebin.com/raw/Sa9hTd0P'
  26.  
  27. ########################################################
  28. parser='html.parser'
  29. img=('jpeg','jpg','png','gif', 'webp', 'bmp', 'tif')
  30. # os_name=os_name()
  31. #headers = {'User-Agent': choice(headers_list)}
  32. who_r_u='https://www.myinstants.com/media/sounds/who_r_u_1.mp3'
  33. yamatte= ['https://www.myinstants.com/media/sounds/yamatte.mp3','https://www.myinstants.com/media/sounds/ara-ara.mp3', 'https://www.myinstants.com/media/sounds/ara-ara2.mp3']
  34. yes= ('y', 'yes', 'yeah', 'sure', 'ok', 'lets go', "let's go", 'start', 'yep', 'yeap', 'well y', 'well yes', 'well yeah', 'well sure', 'well ok', 'well lets go', "well let's go", 'well start', 'well yep', 'well yeap', 'actually y', 'actually yes', 'actually yeah', 'actually sure', 'actually ok', 'actually lets go', "actually let's go", 'actually start', 'actually yep', 'actually yeap')
  35. no = ('n', 'no', 'na', 'nah', 'nope', 'stop', 'quit', 'exit', 'not really', 'no', 'not at all', 'never', 'well n', 'well no', 'well na', 'well nah', 'well nope', 'well stop', 'well quit', 'well exit', 'well not really', 'well no', 'well not at all', 'well never', 'actually n', 'actually no', 'actually na', 'actually nah', 'actually nope', 'actually stop', 'actually quit', 'actually exit', 'actually not really', 'actually no', 'actually not at all', 'actually never')
  36. cond=yes+no
  37. condERR = "Sorry,  I can't understand what you are saying. Just type yes or no.   "
  38. user_list=['bec6113e5eca1d00da8af7027a2b1b070d85b5ea','eb23efbb267893b699389ae74854547979d265bd','a94a8fe5ccb19ba61c4c0873d391e987982fbbd3']
  39. g_mode=False
  40. #########################################################
  41. import time
  42. import Number_sys_conv as Nsys
  43.  
  44. start_up_dt = Nsys.dt_()
  45. from re import search as re_search,compile as re_compile #, sub
  46. import socket
  47. from os import makedirs, remove, rename, system as os_system
  48. from shutil import rmtree as rmdir
  49.  
  50. from subprocess import call as subprocess_call
  51. from sys import exit as sys_exit,executable as sys_executable
  52. from sys import stdout as sys_stdout
  53.  
  54. sys_write=sys_stdout.write
  55.  
  56. from os.path import exists, isdir, isfile
  57. from platform import system as os_name
  58. from threading import Thread as Process, current_thread
  59.  
  60. from random import choice as random_choice, randint
  61. from hashlib import sha1 as hashlib_sha1
  62.  
  63.  
  64. # import pkg_resources
  65.  
  66.  
  67. from bs4 import BeautifulSoup as bs
  68.  
  69. import requests
  70.  
  71.  
  72.  
  73.  
  74. __seq___={
  75. "a": [5, 8, 1, 7, 2, 4, 3, 6],
  76. "b": [7, 2, 1, 6, 3, 8, 4, 5],
  77. "c": [3, 6, 2, 4, 7, 5, 1, 8],
  78. "d": [1, 8, 3, 6, 5, 7, 4, 2],
  79. "e": [2, 7, 8, 5, 4, 1, 3, 6],
  80. "f": [3, 4, 6, 8, 1, 2, 5, 7],
  81. "g": [2, 7, 4, 8, 3, 5, 6, 1],
  82. "h": [8, 6, 1, 5, 4, 2, 7, 3],
  83. "i": [4, 8, 1, 6, 3, 2, 5, 7],
  84. "j": [1, 7, 8, 2, 3, 4, 6, 5],
  85. "k": [1, 8, 3, 6, 2, 4, 7, 5],
  86. "l": [1, 4, 2, 8, 5, 3, 6, 7],
  87. "m": [5, 4, 7, 8, 3, 2, 1, 6],
  88. "n": [8, 2, 1, 4, 5, 6, 3, 7],
  89. "o": [6, 5, 4, 7, 1, 8, 3, 2],
  90. "p": [5, 8, 7, 1, 4, 2, 6, 3],
  91. "q": [2, 6, 4, 8, 1, 7, 3, 5],
  92. "r": [6, 3, 7, 5, 4, 1, 2, 8],
  93. "s": [4, 5, 7, 2, 6, 1, 3, 8],
  94. "t": [7, 3, 6, 5, 2, 1, 8, 4],
  95. "u": [3, 6, 4, 5, 1, 8, 2, 7],
  96. "v": [5, 1, 2, 8, 4, 7, 6, 3],
  97. "w": [6, 4, 2, 1, 7, 3, 5, 8],
  98. "x": [5, 7, 4, 2, 6, 3, 1, 8],
  99. "y": [7, 1, 2, 5, 6, 3, 8, 4],
  100. "z": [4, 8, 2, 1, 5, 7, 3, 6],
  101. "A": [3, 5, 8, 7, 1, 2, 6, 4],
  102. "B": [7, 5, 6, 8, 4, 2, 3, 1],
  103. "C": [7, 2, 1, 6, 5, 3, 8, 4],
  104. "D": [6, 3, 1, 8, 7, 5, 4, 2],
  105. "E": [3, 1, 5, 8, 7, 6, 4, 2],
  106. "F": [8, 3, 1, 5, 7, 4, 2, 6],
  107. "G": [7, 5, 8, 1, 3, 6, 2, 4],
  108. "H": [7, 5, 1, 8, 4, 3, 6, 2],
  109. "I": [7, 2, 3, 1, 6, 5, 4, 8],
  110. "J": [1, 2, 6, 4, 8, 7, 3, 5],
  111. "K": [7, 6, 2, 5, 4, 3, 8, 1],
  112. "L": [2, 8, 5, 3, 7, 6, 1, 4],
  113. "M": [4, 3, 5, 6, 2, 8, 7, 1],
  114. "N": [8, 1, 6, 2, 7, 5, 3, 4],
  115. "O": [4, 8, 3, 6, 1, 5, 2, 7],
  116. "P": [3, 4, 7, 6, 2, 8, 5, 1],
  117. "Q": [4, 5, 8, 3, 6, 1, 2, 7],
  118. "R": [5, 4, 6, 2, 3, 7, 8, 1],
  119. "S": [7, 4, 3, 5, 1, 6, 8, 2],
  120. "T": [7, 4, 1, 5, 3, 8, 2, 6],
  121. "U": [5, 2, 8, 3, 7, 1, 4, 6],
  122. "V": [8, 2, 5, 6, 1, 7, 4, 3],
  123. "W": [7, 5, 1, 4, 3, 6, 8, 2],
  124. "X": [8, 5, 4, 6, 1, 3, 2, 7],
  125. "Y": [6, 5, 7, 4, 8, 2, 1, 3],
  126. "Z": [8, 3, 1, 7, 5, 4, 6, 2],
  127. "1": [2, 6, 7, 8, 4, 3, 1, 5],
  128. "2": [5, 2, 7, 8, 4, 3, 6, 1],
  129. "3": [4, 6, 8, 3, 1, 5, 7, 2],
  130. "4": [5, 1, 6, 3, 8, 7, 4, 2],
  131. "5": [7, 6, 3, 5, 1, 4, 2, 8],
  132. "6": [6, 8, 2, 7, 3, 4, 5, 1],
  133. "7": [7, 3, 5, 4, 6, 8, 1, 2],
  134. "8": [5, 8, 3, 7, 2, 4, 1, 6],
  135. "9": [7, 8, 6, 2, 1, 4, 5, 3],
  136. "0": [4, 8, 1, 3, 5, 2, 6, 7],
  137. "+": [8, 6, 7, 2, 5, 4, 3, 1],
  138. "-": [5, 8, 4, 2, 6, 3, 7, 1],
  139. "*": [4, 8, 7, 5, 2, 1, 3, 6],
  140. "/": [7, 1, 4, 2, 5, 8, 3, 6],
  141. ".": [2, 5, 1, 3, 7, 4, 6, 8],
  142. ",": [3, 7, 1, 4, 8, 2, 6, 5],
  143. "\\": [7, 5, 6, 4, 8, 2, 3, 1],
  144. "<": [3, 8, 4, 7, 6, 2, 5, 1],
  145. ">": [4, 6, 3, 5, 8, 1, 2, 7],
  146. "?": [7, 2, 8, 4, 1, 3, 5, 6],
  147. ";": [4, 6, 7, 2, 1, 3, 8, 5],
  148. "'": [8, 2, 1, 5, 6, 4, 7, 3],
  149. ":": [6, 8, 5, 2, 4, 7, 3, 1],
  150. '\"': [3, 7, 6, 8, 1, 5, 4, 2],
  151. "[": [3, 8, 1, 7, 5, 2, 6, 4],
  152. "]": [7, 2, 5, 6, 4, 3, 1, 8],
  153. "{": [3, 4, 1, 8, 2, 7, 5, 6],
  154. "}": [4, 7, 6, 2, 5, 1, 3, 8],
  155. "|": [6, 1, 3, 2, 5, 4, 7, 8],
  156. "_": [8, 4, 3, 5, 7, 2, 6, 1],
  157. "=": [3, 5, 6, 7, 1, 2, 8, 4],
  158. "`": [1, 3, 8, 6, 2, 7, 5, 4],
  159. "~": [5, 4, 1, 7, 6, 3, 8, 2],
  160. "!": [6, 3, 2, 1, 4, 5, 7, 8],
  161. "@": [3, 4, 5, 8, 7, 1, 2, 6],
  162. "#": [5, 6, 3, 8, 4, 2, 7, 1],
  163. "$": [7, 3, 4, 2, 5, 6, 8, 1],
  164. "%": [4, 6, 1, 3, 7, 2, 8, 5],
  165. "^": [1, 3, 6, 2, 8, 5, 7, 4],
  166. "&": [7, 1, 8, 5, 6, 4, 3, 2],
  167. "(": [3, 1, 5, 2, 8, 4, 6, 7],
  168. ")": [8, 5, 2, 4, 3, 1, 6, 7],
  169. " ": [2, 8, 7, 1, 4, 5, 3, 6],
  170. "’": [6, 5, 7, 3, 4, 8, 1, 2],
  171. "—": [3, 2, 8, 4, 6, 5, 7, 1],
  172. }
  173.  
  174. def __encrypt(text,C):
  175.     i=0
  176.     serial= __seq___[C]
  177.     le=len(text)
  178.  
  179.     while i<le:
  180.         back=text[i:i+8]
  181.         x=0
  182.         #print('len',le)
  183.         for j in serial:
  184.             #print('i+x',i+x,'\tj',j-1)
  185.             text[i+x]=back[j-1]
  186.             x=(x+1)%8
  187.  
  188.         i+=8
  189.     return text
  190.  
  191.  
  192. def encrypt(text, key):
  193.     data_type = type(text)
  194.     if data_type == bytes:
  195.         text+=b" "*((8-len(text)%8)%8)
  196.     else:
  197.         text+=" "*((8-len(text)%8)%8)
  198.     text=list(text)
  199.     for c in key:
  200.         # print(text)
  201.         text=text[2:]+text[:2]
  202.         text= __encrypt(text, c)
  203.         # print(text)
  204.     if data_type == bytes:
  205.         return (bytes(text))
  206.     else:
  207.         return (''.join(text))
  208.  
  209. def __decrypt(text,C):
  210.  
  211.  
  212.     #key=key[::-1]
  213.     serial=__seq___[C]
  214.     i=0
  215.     le=len(text)
  216.     while i<le:
  217.         x=0
  218.         back=text[i:i+8]
  219.         for j in serial:
  220.             text[i+ j-1]=back[x]
  221.             x=(x+1)%8
  222.         i+=8
  223.     return text
  224.  
  225. def decrypt(text, key):
  226.     data_type = type(text)
  227.     if data_type == bytes:
  228.         text+=b" "*((8-len(text)%8)%8)
  229.     else:
  230.         text+=" "*((8-len(text)%8)%8)
  231.     text=list(text)
  232.     key=key[::-1]
  233.     for c in key:
  234.         text=__decrypt(text,c)
  235.         text=text[-2:]+text[:-2]
  236.        
  237.     if data_type == bytes:
  238.         return (bytes(text))
  239.     else:
  240.         return (''.join(text))
  241.  
  242. # print(encrypt(input("X"), input("K")))
  243.  
  244.  
  245.  
  246.  
  247.  
  248. header_list=["Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8)",
  249. # "Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0;  rv:11.0) like Gecko",
  250. 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
  251. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; sv-se) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  252. "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
  253. "Opera/9.80 (Windows NT 6.0; U; pl) Presto/2.7.62 Version/11.01",
  254. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)",
  255. "Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.0)",
  256. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; fr-fr) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  257. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:70.0) Gecko/20190101 Firefox/70.0",
  258. "Opera/9.80 (X11; Linux x86_64; U; Ubuntu/10.10 (maverick); pl) Presto/2.7.62 Version/11.01",
  259. "Mozilla/5.0 (X11; CrOS i686 4319.74.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36",
  260. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; chromeframe/11.0.696.57)",
  261. "Mozilla/5.0 (Windows ME 4.9; rv:35.0) Gecko/20100101 Firefox/35.0",
  262. "Opera/9.80 (Windows NT 6.1; WOW64; U; pt) Presto/2.10.229 Version/11.62",
  263. "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)",
  264. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/75.0",
  265. "Opera/9.80 (X11; Linux i686; U; hu) Presto/2.9.168 Version/11.50",
  266. "Mozilla/5.0 (Windows; U; Windows NT 6.0; ja-JP) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  267. "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  268. "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.2 Safari/537.36",
  269. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1",
  270. "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/29.0",
  271. "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0",
  272. "Opera/9.80 (Windows NT 6.1; U; zh-tw) Presto/2.7.62 Version/11.01",
  273. "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:77.0) Gecko/20100101 Firefox/77.0",
  274. "Mozilla/5.0 (Windows; U; Windows NT 9.1; en-US; rv:12.9.1.11) Gecko/20100821 Firefox/70",
  275. "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5",
  276. "Mozilla/5.0 (Windows NT 4.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36",
  277. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/73.0",
  278. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36",
  279. "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2226.0 Safari/537.36",
  280. "Mozilla/5.0 (X11; OpenBSD amd64; rv:28.0) Gecko/20100101 Firefox/28.0",
  281. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36",
  282. "Opera/9.80 (Windows NT 6.1; U; pl) Presto/2.7.62 Version/11.00",
  283. "Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36",
  284. "Mozilla/5.0 (X11; Linux; rv:74.0) Gecko/20100101 Firefox/74.0",
  285. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36",
  286. "Opera/9.80 (Windows NT 6.0; U; pl) Presto/2.10.229 Version/11.62",
  287. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:10.0) Gecko/20100101 Firefox/62.0",
  288. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1866.237 Safari/537.36",
  289. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36",
  290. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.10; rv:75.0) Gecko/20100101 Firefox/75.0",
  291. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; da-dk) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1",
  292. "Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14",
  293. "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36",
  294. "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 3.0)",
  295. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1",
  296. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1944.0 Safari/537.36",
  297. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36",
  298. "Opera/12.0(Windows NT 5.1;U;en)Presto/22.9.168 Version/12.00",
  299. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36",
  300. "Mozilla/5.0 (X11;  Ubuntu; Linux i686; rv:52.0) Gecko/20100101 Firefox/52.0",
  301. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2762.73 Safari/537.36",
  302. "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/4E423F",
  303. "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1464.0 Safari/537.36",
  304. "Opera/9.80 (Macintosh; Intel Mac OS X 10.14.1) Presto/2.12.388 Version/12.16",
  305. "Mozilla/5.0 (Windows ME 4.9; rv:31.0) Gecko/20100101 Firefox/31.7",
  306. "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36",
  307. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2866.71 Safari/537.36",
  308. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; ja-jp) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  309. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36 Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10",
  310. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2656.18 Safari/537.36",
  311. "Mozilla/5.0 (Windows NT 6.1; rv:68.7) Gecko/20100101 Firefox/68.7",
  312. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.2117.157 Safari/537.36",
  313. "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)",
  314. "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36",
  315. "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36",
  316. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0; chromeframe/11.0.696.57)",
  317. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10",
  318. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET CLR 1.1.4322; .NET4.0C; Tablet PC 2.0)",
  319. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.62 Safari/537.36",
  320. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; de-de) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  321. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36",
  322. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.1; SV1; .NET CLR 2.8.52393; WOW64; en-US)",
  323. "Opera/9.80 (Windows NT 5.1; U; zh-tw) Presto/2.8.131 Version/11.10",
  324. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36",
  325. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; fr-ch) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
  326. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36",
  327. "Mozilla/5.0 (X11; Linux i686; rv:64.0) Gecko/20100101 Firefox/64.0",
  328. "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.66.18) Gecko/20177177 Firefox/45.66.18",
  329. "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)",
  330. "Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_8; zh-cn) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  331. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2224.3 Safari/537.36",
  332. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; ar) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
  333. "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/44.0.2403.155 Safari/537.36",
  334. "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1500.55 Safari/537.36",
  335. "Mozilla/5.0 (compatible; MSIE 7.0; Windows NT 5.0; Trident/4.0; FBSMTWB; .NET CLR 2.0.34861; .NET CLR 3.0.3746.3218; .NET CLR 3.5.33652; msn OptimizedIE8;ENUS)",  
  336. "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja-JP) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
  337. "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8",
  338. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36",
  339. "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",
  340. "Mozilla/5.0 (Windows NT 6.2; rv:20.0) Gecko/20121202 Firefox/26.0",
  341. "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0",
  342. "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:69.2.1) Gecko/20100101 Firefox/69.2",
  343. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20130401 Firefox/31.0",
  344. "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.0; Trident/4.0; InfoPath.1; SV1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 3.0.04506.30)",
  345. "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)",
  346. "Opera/9.80 (Windows NT 5.1; U; cs) Presto/2.7.62 Version/11.01",
  347. "Mozilla/5.0 (Windows; U; Windows NT 6.1; de-DE) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
  348. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36",
  349. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36",
  350. "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727)",
  351. "Mozilla/5.0 (X11; Ubuntu i686; rv:52.0) Gecko/20100101 Firefox/52.0",
  352. "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)",
  353. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; yie8)",
  354. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36",
  355. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.3319.102 Safari/537.36",
  356. "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:71.0) Gecko/20100101 Firefox/71.0",
  357. "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101213 Opera/9.80 (Windows NT 6.1; U; zh-tw) Presto/2.7.62 Version/11.01",
  358. "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:28.0) Gecko/20100101 Firefox/31.0",
  359. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0",
  360. "Mozilla/5.0 (Windows NT 6.1; rv:27.3) Gecko/20130101 Firefox/27.3",
  361. "Mozilla/5.0 (X11; Ubuntu; Linux i686 on x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2820.59 Safari/537.36",
  362. "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.59.12) Gecko/20160044 Firefox/52.59.12",
  363. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; de-de) AppleWebKit/534.15+ (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
  364. "Mozilla/5.0 (X11; Linux x86_64; rv:28.0) Gecko/20100101  Firefox/28.0",
  365. "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1467.0 Safari/537.36",
  366. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:46.0) Gecko/20120121 Firefox/46.0",
  367. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1623.0 Safari/537.36",
  368. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/58.0",
  369. "Mozilla/5.0 (Windows; U; Windows NT 6.0; fr-FR) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5",
  370. "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36",
  371. "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)",
  372. "Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10",
  373. "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
  374. "Opera/9.80 (X11; Linux i686; U; ru) Presto/2.8.131 Version/11.11",
  375. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.2309.372 Safari/537.36",
  376. "Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))",
  377. "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52",
  378. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.10; rv:62.0) Gecko/20100101 Firefox/62.0",
  379. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 4.0; Tablet PC 2.0; InfoPath.3; .NET4.0C; .NET4.0E)",
  380. "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.517 Safari/537.36",
  381. "Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0",
  382. "Opera/9.80 (X11; Linux i686; U; es-ES) Presto/2.8.131 Version/11.11",
  383. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; es-es) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  384. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:77.0) Gecko/20190101 Firefox/77.0",
  385. "Mozilla/5.0 (X11; Ubuntu; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2919.83 Safari/537.36",
  386. "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0",
  387. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
  388. "Opera/9.80 (Windows NT 6.1; U; sv) Presto/2.7.62 Version/11.01",
  389. "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)",
  390. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1664.3 Safari/537.36",
  391. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  392. "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
  393. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; zh-cn) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  394. "Mozilla/5.0 (Windows NT 6.2; Win64; x64; rv:27.0) Gecko/20121011 Firefox/27.0",
  395. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Zune 4.0; InfoPath.3; MS-RTC LM 8; .NET4.0C; .NET4.0E)",
  396. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0",
  397. "Mozilla/5.0 (Windows; U; Windows NT 6.1; fr-FR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27",
  398. "Mozilla/5.0 (Android 2.2; Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
  399. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.10; rv:62.0) Gecko/20100101 Firefox/49.0",
  400. "Mozilla/5.0 (X11; OpenBSD i386) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36",
  401. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.13; ko; rv:1.9.1b2) Gecko/20081201 Firefox/60.0",
  402. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) chromeframe/10.0.648.205",
  403. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; chromeframe/12.0.742.112)",
  404. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; FunWebProducts)",
  405. "Mozilla/5.0 (Windows NT 5.0; Windows NT 5.1; Windows NT 6.0; Windows NT 6.1; Linux; es-VE; rv:52.9.0) Gecko/20100101 Firefox/52.9.0",
  406. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36",
  407. "Mozilla/5.0 (Windows; U; Windows NT 6.0; tr-TR) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.2 Safari/533.18.5",
  408. "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/5.0)",
  409. "Mozilla/5.0 (X11; Linux ppc64le; rv:75.0) Gecko/20100101 Firefox/75.0",
  410. "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2225.0 Safari/537.36",
  411. "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0",
  412. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)",
  413. "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko",
  414. "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36"]
  415.  
  416.  
  417.  
  418.  
  419. process_id= randint(2003,9999)
  420.  
  421.  
  422. os_name=os_name()
  423.  
  424.  
  425. if os_name=='Windows':
  426.     import mplay4
  427.  
  428.  
  429.  
  430.  
  431. user_device_name = socket.gethostname()
  432.  
  433. # print(user_device_name)
  434.  
  435.  
  436.  
  437. def load_assets_main(file='',str_code=''):
  438.     """ can be used either file dir or string
  439.     file: file directory
  440.     str_code: string code
  441.     """
  442.     if str_code=='':
  443.         with open(file) as f:
  444.             exec(f.read(), __main__.__dict__)
  445.     elif file=='':
  446.         exec(str_code, __main__.__dict__)
  447.     else:
  448.         print("load_assets_main function can only have either file directory or string code as Arg")
  449.         raise AttributeError
  450.  
  451. #==================================================#
  452.  
  453. #                ERROR CLASS                       #
  454.  
  455. class LeachUnknownError(Exception):
  456.     pass
  457.  
  458. class LeachKnownError(Exception):
  459.     pass
  460.  
  461. class LeachPermissionError(Exception):
  462.     pass
  463.  
  464.  
  465. class LeachNetworkError(Exception):
  466.  
  467.     pass
  468.  
  469.  
  470. class LeachCorruptionError(Exception):
  471.     pass
  472.  
  473.  
  474.  
  475.  
  476. #def clear_screen():    #func_code= 00000
  477. #   if os_name=="Windows":
  478. #       os_system('cls')
  479. #   else:
  480. #       os_system('clear')
  481.  
  482.  
  483. def remove_non_ascii(text, f_code):    #func_code= 00001
  484.     """removes ascii charecters from a string"""
  485.     try:
  486.         return ''.join([i if ord(i) < 128 else '' for i in text])
  487.     except Exception as e:
  488.         print("Failed to remove non-ascii charecters from string.\nError code: 00001x",f_code,'\nPlease inform the author.')
  489.         leach_logger('00001||'+e.__class__.__name__+'||'+Nsys.dt_()+'||'+f_code+'||'+text)
  490.  
  491.  
  492.  
  493. def header_():    #func_code=00002
  494.     """returns a random header for requests lib"""
  495.     return( {'User-Agent':random_choice(header_list)})
  496.  
  497.  
  498. # def install(pack, alias=0):    #func_code=00003 // not required
  499.  
  500.  
  501. # def install_req(pkz):     #func_code=00004      // not required
  502.  
  503.  
  504.  
  505. def loc(x, os_name='Linux'):    #func_code=00005
  506.     """to fix dir problem based on os
  507.     x: directory
  508.     os_name: Os name *Linux"""
  509.     if os_name == 'Windows':
  510.         return x.replace('/', '\\')
  511.     else:
  512.         return x.replace('\\', '/')
  513.  
  514.  
  515. def writer(fname, mode, data, dir=0, f_code='', encoding='utf-8'):    #func_code=00006
  516.     """Writing on a file
  517.         fname: filename,
  518.         mode: write mode (w,wb,a,ab),
  519.         data: data to write,
  520.         dir: directory of the file, empty for current dir *0
  521.         func_code: (str) code of the running func *empty string"""
  522.     #func_code='00006'
  523.     try:
  524.         if dir == 0:
  525.             if 'b' not in mode:
  526.                 with open(fname, mode, encoding=encoding) as file:
  527.                     file.write(data)
  528.             else:
  529.                 with open(fname, mode) as file:
  530.                     file.write(data)
  531.         else:
  532.             locs=loc(dir)
  533.             if isdir(locs):
  534.                 if locs.endswith('/'):
  535.                     if 'b' not in mode:
  536.                         with open(loc(locs + fname), mode, encoding=encoding) as f:
  537.                             f.write(data)
  538.                     else:
  539.                         with open(loc(locs + fname), mode) as f:
  540.                             f.write(data)
  541.                 else:
  542.                     if 'b' not in mode:
  543.                         with open(loc(locs + '/' + fname), mode, encoding=encoding) as f:
  544.                             f.write(data)
  545.                     else:
  546.                         with open(loc(locs + '/' + fname), mode) as f:
  547.                             f.write(data)
  548.             else:
  549.                 try:
  550.                     makedirs(locs)
  551.                 except FileExistsError: pass
  552.                 writer(fname, mode, data, locs, f_code)
  553.     except Exception as e:
  554.         if e.__class__.__name__== "PermissionError":
  555.             print(e.__class__.__name__,"occured while writing", fname, 'in', 'current directory' if dir==0 else dir,'\nPlease inform the author. Error code: 00006x'+f_code)
  556.             leach_logger('00006||'+"PermissionError"+'||%s||%s||%s||%s||%s'%(Nsys.compressed_dt(),f_code, fname, mode, dir))
  557.             raise LeachPermissionError
  558.         else:
  559.             leach_logger('00006x-1||'+e.__class__.__name__+'||%s||%s||%s||%s||%s||%s'%(Nsys.compressed_dt(),f_code, fname, mode, dir,e))
  560.             print(e.__class__.__name__,"occured while writing", fname, 'in', 'current directory' if dir==0 else dir,'\nPlease inform the author. Error code: 00006x'+f_code)
  561.             raise LeachUnkownError
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568. def hdr(header, f_code=''):    #func_code=00007
  569.     """returns the index of a header"""
  570.     try:
  571.         return str(header_list.index(header['User-Agent']))
  572.     except ValueError:
  573.         print("Some error occured caused, possible cause: DATA CORRUPTION\nError code: 00007x"+f_code)
  574.         leach_logger('00007||'+Nsys.dt_()+'||'+f_code+'||'+header+'||'+f_code)
  575.         return str((-1, header))
  576.  
  577.  
  578. def leach_logger(io, key='lock'):   #func_code=00008
  579.     """saves encrypted logger data to file"""
  580.     _key="Asuna"
  581.     salt = hashlib_sha1(key.encode()).hexdigest()
  582.     writer('userlog.leach', 'ab', encrypt(salt+'||'+str(process_id)+'||'+io,_key).encode('utf-8')+b'\n','data','00008')
  583.  
  584.  
  585.  
  586. #################### CONNECT TO THE NET FOR THE FIRST TIME #################
  587. def _connect_net():      #func_code= 00009
  588.     """connects to the internet and returns the users global ip"""
  589.     global user_net_ip
  590.     current_header=header_()
  591.     try:
  592.         user_net_ip=requests.get('https://ident.me',headers=current_header).content.decode()
  593.         return [True, '0']
  594.     except requests.exceptions.ConnectionError:
  595.         print("\033[1;31;40mError code: 605x1\nNo internet connection!\nThe program will break in 5 seconds\033[0m")
  596.         leach_logger("605x1||"+Nsys.compressed_dt()+"||header_index="+hdr(current_header,'00009'), 'lock')
  597.         return [False, '605x1']
  598.     except Exception as e:
  599.         print(e.__class__.__name__, "occured. Please inform the Author.\nError code: 00009x-1(%s)"%e.__class__.__name__)
  600.         leach_logger("00009x-1||"+Nsys.compressed_dt()+"||header_index="+hdr(current_header,'00009')+'||%s||%s'%(e.__class__.__name__, e), 'lock')
  601.         return [False, "00009x-1"]
  602. def import_paste():      #func_code= 00010
  603.     """will import the upload host lib here"""
  604.     try:pass
  605.         #from pastebin import send_paste
  606.         #current_header index=1
  607.     except requests.exceptions.ConnectionError:
  608.         print("\033[1;31;40mError code: 605x2\nNo internet connection!\nThe program will break in 5 seconds\033[0m")
  609.         leach_logger("605x2||"+Nsys.dt_()+"||header_index=1", 'lock')
  610.         time.sleep(5)
  611.         sys_exit()
  612.  
  613.  
  614.  
  615. ################# not needed in GUI functions ###################
  616. # def delete_last_line():      #func_code= 00011
  617. #   "Use this function to delete the last line in the STDOUT"
  618. #
  619. #   #cursor up one line
  620. #   sys_write('\x1b[1A')
  621. #
  622. #   #delete last line
  623. #   sys_write('\x1b[2K')
  624. #
  625. # def asker(out='', default=None, True_False=(True, False)):      #func_code= 00012
  626. #   """asks for yes no or equevalent inputs
  627. #   out: printing text to ask tha question *empty string
  628. #   default: default output for empty response *None
  629. #   True_False: returning data instead of true and false *(True, False)"""
  630. #   print(out,end='')
  631. #    
  632. #   Ques2 = input().lower()
  633. #   if default!= None and Ques2=='':
  634. #       return default
  635. #   #Ques2 = Ques2
  636. #   while Ques2 not in cond:
  637. #       print(condERR)
  638. #       Ques2 = input().lower()
  639. #       #Ques2 = Ques2
  640. #   if Ques2 in cond:
  641. #       if Ques2 in yes:
  642. #           return True_False[0]
  643. #       else:
  644. #           return True_False[1]
  645.  
  646.  
  647. def get_file_name(directory):      #func_code= 00013
  648.     return loc(directory,'linux').split('/')[-1]
  649.  
  650.  
  651. def get_file_ext(directory, no_format='noformat'):      #func_code= 00014
  652.     """to get the extension of a file directory
  653.     directory: file directory relative or direct
  654.     no_format: returning format if no file extention was detected *noformat"""
  655.     temp= get_file_name(directory)
  656.     if len(temp.split('.'))==1:
  657.         return no_format
  658.     else:
  659.         return temp.split('.')[-1]
  660.  
  661.  
  662. def reader(direc, read_mode='r'):      #func_code= 00015
  663.     if type(read_mode)!=str:
  664.         print("Invalid read type. Mode must be a string data")
  665.         raise TypeError
  666.     if read_mode in ['w', 'wb', 'a', 'ab', 'x', 'xb']:
  667.         print("\033[1;31;40mInvaid read mode:\033[0m\033[1m %s is not a valid read mode.\nTry using 'r' or 'rb' based on your need\033[0m")
  668.         raise LeachKnownError
  669.     if 'b' in read_mode:
  670.         read_mode='rb'
  671.     else:
  672.         read_mode = 'r'
  673.     with open(loc(direc), read_mode) as f:
  674.         return f.read()
  675.  
  676.  
  677.  
  678.  
  679.  
  680. def _version_updater(_latest_version, _latest_link, _latest_hash, _latest_filename,_latest_size):      #func_code= 00016
  681.     global global_text
  682.     print("An update available v"+_latest_version+"("+_latest_size+"), Do you want to update? ")
  683.     if True:
  684.         global_text="Connecting..."
  685.         print('\nConnecting...')
  686.         leach_logger("201||"+Nsys.dt_()+"||"+str(_latest_version),'lock')
  687.         #update_filename='Web Leach v4.1'
  688.         #import urllib
  689.  
  690.  
  691.         # Copy a network object to a local file
  692.         #urllib.urlretrieve(_latest_link, 'Data/.temp/'+update_filename+'.zip')
  693.         current_header=header_()
  694.         update_response = requests.get(_latest_link, stream=True,headers=current_header)
  695.         # delete_last_line()
  696.         if update_response!=None:
  697.             update_total_length = update_response.headers.get('content-length')
  698.             with open('Data/.temp/'+_latest_filename+'.zip', "wb") as f:
  699.                 if update_total_length is None: # no content length header
  700.                     f.write(update_response.content)
  701.                 else:
  702.                     _dl = 0
  703.                     update_total_length = int(update_total_length)
  704.                     for data in update_response.iter_content(chunk_size=4096):
  705.                         _dl += len(data)
  706.                         f.write(data)
  707.                         update_done = int(50 * _dl / update_total_length)
  708.                         print("\r[\033[1;32;40m%s%s\033[0m]" % ('=' * update_done, ' ' * (50-update_done)) , end='')
  709.                     global_text="Unzipping"
  710.                     print("\nUnzipping...")
  711.  
  712.  
  713.                     with ZipFile('Data/.temp/'+_latest_filename+'.zip') as zf:
  714.                         zf.extractall(pwd=b'lock')
  715.  
  716.  
  717.                 # File to check
  718.                 _file_name = _latest_filename+'.exe'
  719.  
  720.  
  721.                 # Open,close, read file and calculate MD5 on its contents
  722.                 with open(_file_name, 'rb') as file_to_check:
  723.                     # read contents of the file
  724.                     _data = file_to_check.read()
  725.                     # pipe contents of the file through
  726.                     md5_returned = hashlib_sha1(_data).hexdigest()
  727.                 #print(md5_returned)
  728.                 # Finally compare original MD5 with freshly calculated
  729.                 if _latest_hash == md5_returned:
  730.                     print ("MD5 verified. \n\nPlease use the latest file '"+_latest_filename+".exe'\n this program will break in 7 seconds\n\n")
  731.                     remove(_latest_filename+'.zip')
  732.                     time.sleep(7)
  733.                     sys_exit()
  734.                 else:
  735.                     print ("\033[1;31;40mMD5 verification failed!.\033[0m \nPlease inform the coder- wwwqweasd147[at]gmail[dot]com")
  736.         else:
  737.             print("Failed to connect to the host server.\nPlease inform the author!!\nError code ")
  738.             leach_logger('202||%s||%s||%s||%s'%(Nsys.dt_(), _latest_version, _latest_link, _VERSION, hdr(current_header,'00016')),'lock')
  739.  
  740.  
  741. def god_mode():      #func_code= 00017
  742.     # global user_net_ip
  743.     return_box=[]
  744.     current_header=header_()
  745.     try:
  746.         file=requests.get(cloud_data_link, headers=current_header)
  747.         writer('update.ext','wb',file.content,'data/.temp','00017')
  748.         exec(decrypt(open('data/.temp/update.ext').read(), "lock").strip())
  749.  
  750.         remove('Data/.temp/update.ext')
  751.  
  752.     except (requests.ConnectionError,requests.exceptions.ChunkedEncodingError):
  753.         # print("\033[1;31;40mError code: 605x4\nNo internet connection!\nThe program will break in 5 seconds\033[0m")
  754.         leach_logger("605x4||%s||%s"%(Nsys.compressed_dt(),hdr(current_header,'00017')), 'lock')
  755.        
  756.         return_box.append('605x4')
  757.     except Exception as e:
  758.         # print(e.__class__.__name__,": Unknown error occured. Error code 00017x-1\nPlease inform the author.")
  759.         leach_logger("00017x-1||%s||%s||%s||%s"%(Nsys.compressed_dt(),e.__class__.__name__,str(e),hdr(current_header,'00017')), 'lock')
  760.        
  761.         return_box.append('00017x-1')
  762.  
  763.  
  764.  
  765.    
  766.     # if float(_VERSION)<float(_latest_version):
  767.     #   _version_updater(_latest_version, _latest_link, _latest_hash, _latest_filename,_latest_size)
  768.  
  769.  
  770.     return return_box
  771. boss=0
  772.  
  773. god_mode()
  774. def log_in(user_name_i):      #func_code= 00019
  775.     global user_name
  776.     if boss!=1:
  777.             #user_name=input("Enter username: ")
  778.             userhash=hashlib_sha1(user_name_i.encode()).hexdigest()
  779.             if userhash in user_list:
  780.                 user_name = user_name_i
  781.                 return userhash
  782.             else:
  783.                 return "INVALID"
  784.     else:
  785.         userhash='eb23efbb267893b699389ae74854547979d265bd'
  786.  
  787.  
  788.     if not exists('data/projects.db'):
  789.         writer('projects.db','a','','data','00019')
  790.     if userhash=='eb23efbb267893b699389ae74854547979d265bd':
  791.         g_mode='Asuna'
  792.     return userhash
  793.  
  794.  
  795. print ("Imported Assets")
  796.  
  797.  
  798. ###############   Downloader.py goes here   ###############
  799.  
  800.  
  801. from kivymd.app import MDApp
  802. from kivymd.uix.button import MDRectangleFlatButton, MDFlatButton,MDRaisedButton
  803. from kivymd.uix import boxlayout
  804. from kivymd.uix import textfield
  805. from kivy.lang import Builder
  806. from kivymd.uix.dialog import MDDialog
  807. from kivy.uix.screenmanager import ScreenManager, Screen, NoTransition
  808. from kivy.clock import Clock
  809. from kivy.core.audio import SoundLoader
  810.  
  811. from  functools import  partial
  812.  
  813. # from threading import Thread as Process, current_thread
  814. # from kivy.uix.relativelayout import RelativeLayout
  815.  
  816. #from kivy.core.clipboard import Clipboard
  817.  
  818. Builder.load_file("KV_gui.kv")
  819.  
  820. _VERSION="5.1"
  821.  
  822.  
  823. class login_kv(Screen):
  824.     pass
  825.  
  826. class welcome_kv(Screen):
  827.     pass
  828.  
  829. class blank(Screen):
  830.     pass
  831.  
  832. class download_page(Screen):
  833.     pass
  834.  
  835. class select_tree_page(Screen):
  836.     pass
  837.  
  838. from zipfile import ZipFile, BadZipFile
  839. from re import search as re_search,compile as re_compile #, sub
  840. from bs4 import BeautifulSoup as bs
  841.  
  842. def go_prev_dir(link):    #func_code=00026
  843.     if link.endswith('/'):
  844.         return '/'.join(link[:-1].split('/')[:-2])+'/'
  845.     # x=link.split('/')
  846.     else:
  847.         return '/'.join(link.split('/')[:-2])+'/'
  848.  
  849. def get_file_name(directory):      #func_code= 00013
  850.     return loc(directory,'linux').split('/')[-1]
  851.  
  852. def get_file_ext(directory):      #func_code= 00014
  853.     return get_file_name(directory).split('.')[-1]
  854.  
  855.  
  856. def reader(direc):      #func_code= 00015
  857.     with open(loc(direc)) as f:
  858.         return f.read()
  859.  
  860. def remove_non_ascii(text, f_code):    #func_code= 00001
  861.     """removes ascii charecters from a string"""
  862.     try:
  863.         return ''.join([i if ord(i) < 128 else '' for i in text])
  864.     except Exception as e:
  865.         print("Failed to remove non-ascii charecters from string.\nError code: 00001x",f_code,'\nPlease inform the author.')
  866.         leach_logger('00001||'+e.__class__.__name__+'||'+Nsys.compressed_dt()+'||'+f_code+'||'+text)
  867.  
  868. def distribute(lists,task_id,is_error=False):      #func_code= 00018
  869.     global total,done, errors, sp_flags, sp_extension
  870.     task_id=str(task_id)
  871.     res=0
  872.     if existing_found:
  873.         if exists('data/projects/'+Project+'/t'+task_id+'.txt'):
  874.             res=eval(open('data/projects/'+Project+'/t'+task_id+'.txt').read().strip())
  875.     done+=res
  876.  
  877.     time.sleep(1.2)
  878.  
  879.     for j in lists:
  880.         if is_error:
  881.             i=j
  882.         else:
  883.             i=all_list[j]
  884.  
  885.         if lists.index(j)>=res:
  886.             try:
  887.                 current_header=header_()
  888.  
  889.                 file=requests.get(i[0], headers= current_header)
  890.                 if file:
  891.                     writer(get_file_name(i[0])+sp_extension,'wb',file.content,'Projects/'+Project+'/'+sub_dirs[i[1]], '00018')
  892.  
  893.                     if 'dl unzip' in sp_flags:
  894.                         if isdir('Projects/'+Project+'/'+sub_dirs[i[1]]+'/'+get_file_name(i[0])+'/')==False:
  895.                             makedirs('Projects/'+Project+'/'+sub_dirs[i[1]]+'/'+get_file_name(i[0])+'/')
  896.                         with ZipFile('Projects/'+Project+'/'+sub_dirs[i[1]]+'/'+get_file_name(i[0])+sp_extension) as zf:
  897.                             zf.extractall(path='Projects/'+Project+'/'+sub_dirs[i[1]]+'/'+get_file_name(i[0]))
  898.                         if 'del dl zip' in sp_flags:
  899.                             remove('Projects/'+Project+'/'+sub_dirs[i[1]]+'/'+get_file_name(i[0])+sp_extension)
  900.  
  901.                     writer('t'+task_id+'.txt', 'w',str(res),'data/projects/'+Project,'00018')
  902.  
  903.                     delete_last_line()
  904.                     #print(done)
  905.                     print('Downloaded ['+ str(done+1) + '/'+str(total)+']')
  906.                     res+=1
  907.                     done+=1
  908.                     if is_error:
  909.                         errors-=1
  910.                 else:
  911.                     raise requests.ConnectionError
  912.             except (requests.ConnectionError,requests.exceptions.ChunkedEncodingError):
  913.                 if is_error==False:
  914.                     writer('errors.txt', 'a',str(tuple(i)+(hdr(current_header,'00018'),))+'\n','data/projects/'+Project,'00018')
  915.                     writer('err_header.txt','a','%s,'%hdr(current_header,'00018'),'data/','00018')
  916.                     errors+=1
  917.  
  918.                 else:
  919.                     print("Failed to download from '%s'"%i[0])
  920.                     writer('errors.txt', 'a',str(tuple(i)+(hdr(current_header,'00018'),"Error dl"))+'\n','data/projects/'+Project,'00018')
  921.                     leach_logger(str((Project,)+(hdr(current_header,'00018'),"Error dl"))+"||@"+Nsys.compressed_dt(), user_name)
  922.             except BadZipFile:
  923.                 if is_error==False:
  924.                     writer('errors.txt', 'a',str(tuple(i)+(hdr(current_header,'00018'),"Bad zip"))+'\n','data/projects/'+Project,'00018')
  925.                     errors+=1
  926.                 else:
  927.                     print("It seems every time it downloads a broken or unknown zip from '%s' (possible cause password protected zips, if yes extract them manually)"+i[0])
  928.                     writer('errors.txt', 'a',str(tuple(i)+(hdr(current_header,'00018'),"Bad zip"))+'\n','data/projects/'+Project,'00018')
  929.                     leach_logger(str(tuple(i)+(hdr(current_header,'00018'),"Bad zip"))+"||@"+Nsys.compressed_dt(),user_name)
  930.  
  931.  
  932.  
  933. def _init_():      #func_code= 00020
  934.     global patrial_do_all,homepage, existing_found, dimention,sp_flags, done,indx_count, sp_extension, errors
  935.  
  936.     patrial_do_all=0
  937.     homepage=''
  938.     dimention=0
  939.     done=0
  940.     indx_count=0
  941.     sp_extension=''
  942.     sp_flags=[]
  943.     errors=0
  944.     done=0
  945.  
  946. def list_writer(link, types, file_link_starts,n,special=None, soup=None):      #func_code= 00021
  947.  
  948.     global all_list, sub_dirs, indx_count
  949.  
  950.     homepage_searcher=re_compile('(https?://[^/]*)')
  951.     start_checker=re_compile('^'+file_link_starts)
  952.     if special!=None:
  953.         if special.startswith('nhentai'):
  954.  
  955.             if special=="nhentai.to":
  956.                 to_search= re_compile("(https://nhentai.to/galleries/\d*/)|(https://cdn.dogehls.xyz/galleries/\d*/)")
  957.                 for imgs in soup.find_all('img'):
  958.                     img_link=imgs.get('data-src')
  959.                     if img_link== None:
  960.                         img_link=imgs.get('src')
  961.                     if img_link.startswith('/'):
  962.                         img_link='https://nhentai.to' +(img_link.replace('t',''))
  963.                     if img_link.startswith('https://cdn.dogehls.xyz/galleries/'):
  964.                         img_link= img_link[::-1].replace('t','',1)[::-1]
  965.  
  966.                     if to_search.search(img_link)!=None:
  967.                         all_list.add((img_link,n))
  968.  
  969.             elif special=="nhentai.net":
  970.                 net_search=re_compile("https://i.nhentai.net/galleries/\d*/")
  971.                 for imgs in soup.find_all('img'):
  972.                     img_link=imgs.get('data-src')
  973.                     if img_link== None:
  974.                         img_link=imgs.get('src')
  975.  
  976.                     if '/thumb.' in img_link:
  977.                         continue
  978.                     if 'cover' not in img_link:
  979.                         img_link= img_link.replace('s://t.','s://i.')[::-1].replace('t','',1)[::-1]
  980.                     if net_search.search(img_link)!=None:
  981.                         all_list.add((img_link,n))
  982.  
  983.     else:
  984.         if type(link)==list and type(n)==range:
  985.             dir_len=len(sub_dirs)
  986.             for i in n:
  987.  
  988.                 if sub_dirs[i][-1]=='/':
  989.                     sub_dirs[i]=sub_dirs[i][:-1]
  990.                 sub_dirs[i]=sub_dirs[i].split('/')[-1]
  991.  
  992.  
  993.                 page = requests.get(link[i],headers=header_())
  994.                 soup=bs(page.content, parser)
  995.  
  996.                 for imgs in soup.find_all('img'):
  997.                     img_link=imgs.get('data-src')
  998.                     if img_link== None:
  999.                         img_link=imgs.get('src')
  1000.                     img_link=img_link.strip()
  1001.  
  1002.                     if img_link.startswith('/'):
  1003.                         img_link=homepage_searcher.search(link[i]).groups()[0]+img_link
  1004.  
  1005.                     if img_link.startswith('../'):
  1006.                         temp_home=link[i]
  1007.                         while img_link.startswith('../'):
  1008.                             temp_home= go_prev_dir(temp_home)
  1009.                             img_link=img_link.replace('../','',1)
  1010.                         img_link=temp_home+img_link
  1011.  
  1012.  
  1013.                     if start_checker.search(str(img_link))!=None and img_link.endswith(types):
  1014.                         if img_link.startswith('//i') and '.imggur.net' in img_link:
  1015.                             img_link="https:"+img_link
  1016.  
  1017.                         all_list.add((img_link,i))
  1018.  
  1019.                 delete_last_line()
  1020.                 print('Indexed ['+ str(indx_count+1) + '/'+str(dir_len)+'] '+link[i])
  1021.                 indx_count+=1
  1022.         else:
  1023.             page = requests.get(link,headers=header_())
  1024.             soup=bs(page.content, parser)
  1025.  
  1026.  
  1027.             for imgs in soup.find_all('img'):
  1028.                 img_link=imgs.get('data-src')
  1029.                 if img_link== None:
  1030.                     img_link=imgs.get('src')
  1031.                 if img_link.startswith('/'):
  1032.                     img_link=homepage_searcher.search(link).groups()[0]+img_link
  1033.  
  1034.                 if img_link.startswith('../'):
  1035.                         while img_link.startswith('../'):
  1036.                             temp_home=link
  1037.                             temp_home= go_prev_dir(temp_home)
  1038.                             img_link=img_link.replace('../','',1)
  1039.                         img_link=temp_home+img_link
  1040.  
  1041.  
  1042.                 if start_checker.search(str(img_link))!=None and img_link.endswith(types):
  1043.                     if img_link.startswith('//i') and '.imggur.net' in img_link:
  1044.                         img_link="https:"+img_link
  1045.  
  1046.                     all_list.add((img_link,n))
  1047.  
  1048.  
  1049.  
  1050. if os_name=='Windows':
  1051.     def plat_yamatte(vol):      #func_code= 00022
  1052.         global ex
  1053.         writer('yamatte.mp3','wb',requests.get(random_choice(yamatte), headers=header_()).content,'Data/.temp','00022')
  1054.         ex=mplay4.ex_vol
  1055.         mplay4.set_win_vol(vol)
  1056.         mplay4.load('data/.temp/yamatte.mp3').play()
  1057.         time.sleep(8)
  1058.         remove('data/.temp/yamatte.mp3')
  1059.         mplay4.set_win_vol(ex)
  1060.     play_yamatte_t=Process(target=plat_yamatte, args=[80])
  1061.  
  1062.  
  1063.  
  1064.  
  1065. def nhantai_link(link):      #func_code= 00022
  1066.     global sub_dirs
  1067.     code=re_search('https://nhentai.[^/]*/g/((\d)*)',link)
  1068.  
  1069.     if code==None:
  1070.         return False, False
  1071.     code=code.groups()[0]
  1072.  
  1073.  
  1074.     try:
  1075.         current_header=header_()
  1076.         link_y='https://nhentai.net/g/'+code+'/'
  1077.         page = requests.get(link_y,headers=current_header, timeout=2)
  1078.         if page:
  1079.             site=".net"
  1080.         else:
  1081.             raise requests.ConnectionError
  1082.             #link_y='https://nhentai.to/g/'+code+'/'
  1083.             #page = requests.get(link_y,headers=headers)
  1084.             #site='.to'
  1085.             # site="https://nhentai.net/"
  1086.             # thumb_pattern="https://t.nhentai.net/galleries/\d/\dt."
  1087.  
  1088.     except (requests.ConnectionError,requests.exceptions.ConnectTimeout,requests.exceptions.ReadTimeout):
  1089.         print('nhentai.net server is not reachable, trying proxy server...')
  1090.         link_y='https://nhentai.to/g/'+code+'/'
  1091.         page = requests.get(link_y,headers=header_())
  1092.         site='.to'
  1093.         leach_logger("project||%s||606x1||%s||%s"%(Project, link, hdr(current_header,'00022')), user_name)
  1094.     if page:
  1095.         soup=bs(page.content, parser)
  1096.        
  1097.         title=remove_non_ascii(soup.find(id='info').find('h1').get_text(),'00022')
  1098.         print("Indexing from",title)
  1099.         list_writer(code,img,'',0,'nhentai'+site,soup)
  1100.         sub_dirs.append(title)
  1101.         # print(sub_dirs)
  1102.         return link_y, title
  1103.     else:
  1104.         print("\033[1;31;40mError code: 606x2\nLink not found, Please recheck the link and start a new project\033[0m")
  1105.         leach_logger("project||%s||606x2||%s||%s"%(Project, link, hdr(current_header,'000')), user_name)
  1106.         return 0
  1107.  
  1108.  
  1109. def check_sp_links(link, sp=None):      #func_code= 00023
  1110.     special_starts=['https://nhentai.(net)|(to)/g/','https://w11.mangafreak.net/M|manga/']
  1111.     nh=special_starts[0]
  1112.     mangafreak=special_starts[1]
  1113.     if sp=='nh':
  1114.         if re_search('^'+nh, link)!=None:
  1115.             return True
  1116.         else:
  1117.             return False
  1118.     elif sp=="mangafreak":
  1119.         if re_search('^'+mangafreak, link)!=None:
  1120.             return True
  1121.         else:
  1122.             return False
  1123.     elif sp==None:
  1124.         for i in special_starts:
  1125.             if re_search('^'+i, link)!=None:
  1126.                 return True
  1127.         return False
  1128.  
  1129. def mangafreak_link(link):      #func_code= 00024
  1130.     global sub_dirs, all_list, sp_extension
  1131.     inp = re_search('https://w11.mangafreak.net/(M|m)anga/([^\?]*)',link)
  1132.  
  1133.     if inp!=None:
  1134.         title=inp.group(2)
  1135.  
  1136.     else:
  1137.         return ""
  1138.  
  1139.  
  1140.     while True:
  1141.         try:
  1142.             last_ch= int(input("\n\033[32;1m**\033[0mPlease enter the last chapter number: "))
  1143.             while True:
  1144.                 try:
  1145.                     if requests.head("http://images.mangafreak.net:8080/downloads/"+title+'_'+str(last_ch)):
  1146.                         sp_extension='.zip'
  1147.                         print("Found!")
  1148.                         break
  1149.                         # except request.URLError:
  1150.                         #   print("This chapter is not found!!")
  1151.                         #       break
  1152.                     else:
  1153.                         print("This chapter is not found!!")
  1154.                 except:
  1155.                     print("This chapter is not found!!")
  1156.             break
  1157.  
  1158.         except:
  1159.             last_ch= int(input("\n\033[31;1m**\033[0mJust enter the last chapter number (like 135): "))
  1160.  
  1161.  
  1162.     sub_dirs.append(title)
  1163.     for i in range(1,last_ch+1):
  1164.         all_list.add(("http://images.mangafreak.net:8080/downloads/"+title+'_'+str(i),0))
  1165.  
  1166.     return "mangafreak.net"
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176. def main():      #func_code= 00025
  1177.     _init_()
  1178.     global Project, all_list,total,existing_found, sub_dirs,patrial_do_all,sp_flags, errors, sp_extension
  1179.     existing_found=False
  1180.     dl_done=False
  1181.     corruptions=[]
  1182.     Project=input('\nEnter Batch download directory (Project name): ')
  1183.     project_dir=Project[:].replace('/','-').replace('\\','-').replace('|','-').replace(':','-').replace('*','-').replace('"',"'").replace('>','-').replace('<','-')
  1184.     leach_logger("project||%s||began||%s"%(Project,str(Nsys.compressed_dt())),user_name)
  1185.     if Project in open('data/projects.db').read().split('\n'):
  1186.         print('Existing Project name found!')
  1187.         proj_good=False
  1188.         list_good=False
  1189.  
  1190.         if exists('data/projects/'+Project+'.proj') and exists('data/projects/'+Project+'.list'):
  1191.             proj_good= True
  1192.             try:
  1193.                 with open('data/projects/'+Project+'.proj') as f:
  1194.                     print('db found')
  1195.  
  1196.                     existing_data=f.read().strip().split('\n')
  1197.                     try:
  1198.                         main_link=existing_data[0]
  1199.                     except:
  1200.                         corruptions+=[1]
  1201.                         print('\033[1;31;40mCorrupted Data! Error code: 601x1\033[0m')
  1202.                         proj_good=False
  1203.                        
  1204.                     if proj_good:
  1205.                         try:
  1206.                             link_startswith=existing_data[1]
  1207.                         except:
  1208.                             proj_good= False
  1209.                             print('\033[1;31;40mCorrupted Data! Error code: 601x2\033[0m')
  1210.                             corruptions+=[4]
  1211.  
  1212.                     if proj_good:
  1213.                         try:
  1214.                             file_types=eval(existing_data[2])
  1215.                         except:
  1216.                             proj_good= False
  1217.                             print('\033[1;31;40mCorrupted Data! Error code: 601x3\033[0m')
  1218.                             corruptions+=[4]
  1219.  
  1220.                     if proj_good:
  1221.                         try:
  1222.                             file_starts=existing_data[3]
  1223.                         except:
  1224.                             proj_good= False
  1225.                             print('\033[1;31;40mCorrupted Data! Error code: 601x4\033[0m')
  1226.                             corruptions+=[4]
  1227.  
  1228.                     if proj_good:
  1229.                         try:
  1230.                             sub_dirs=eval(existing_data[4]) #sub directory list
  1231.                         except:
  1232.                             proj_good= False
  1233.                             print('\033[1;31;40mCorrupted Data! Error code: 601x5\033[0m')
  1234.                             corruptions+=[2]
  1235.                         try:  #added in v5.0 may not be in older files
  1236.                             sp_flags=eval(existing_data[5])
  1237.                             sp_extension=eval(existing_data[6])
  1238.                         except IndexError: pass
  1239.                     if proj_good:
  1240.                         try:  #added in v5.1 may not be in older files
  1241.                             dl_done=eval(existing_data[7])
  1242.                         except IndexError: pass
  1243.  
  1244.  
  1245.  
  1246.                 with open('data/projects/'+Project+'.list') as f:
  1247.                     try:
  1248.                         file=f.read()
  1249.                         #print(f"'{file}'")
  1250.                         if file.strip()=='': raise ValueError
  1251.                         all_list= eval(str(file))
  1252.                         print('list found')
  1253.                         list_good= True
  1254.                     except:
  1255.                         list_good= False
  1256.                         print('\033[1;31;40mCorrupted Data! Error code: 601x6\033[0m')
  1257.                         corruptions+=[3]
  1258.  
  1259.                 #print(x)
  1260.                 if proj_good and list_good:
  1261.                    
  1262.                     if dl_done:
  1263.                         print('It seems  the old prject download was complete!!')
  1264.                         if asker('Do you want make a fresh start with that project name??\n\033[1;33mWarning!\033[0m last project data will be erased\n(downloaded files will be safe, unless the program replaces the files with new ones)\n\033[32m>> \033[0m'):
  1265.                             writer(Project+'.list','w','','data/projects','00025')
  1266.                             writer(Project+'.proj','w','','data/projects','00025')
  1267.                             existing_found= False
  1268.                             leach_logger('project||%s||%s||fresh start||was done'%(Project,Nsys.dt_()),user_name)
  1269.                         else:
  1270.                             print("Okay! Enter a new project name in the next line.")
  1271.                             return 0
  1272.                     else:
  1273.                         if asker("Do you want to resume the Project '%s'?\nyes/y to resume\nno/n to Start fresh (\033[1;33mwarning! last project data will be erased \033[0m(downloaded files will be safe, unless the program replaces the files with new ones)\n\033[32m>> \033[0m"%Project):
  1274.                             print('============ Realoaded =============')
  1275.                             leach_logger('project||%s||%s||resumed||not done'%(Project,Nsys.dt_()),user_name)
  1276.                             existing_found= True
  1277.                         else:
  1278.                             leach_logger('%s||%s||fresh start||not done'%(Project,Nsys.dt_()),user_name)
  1279.                             #clear file data
  1280.                             writer(Project+'.list','w','','data/projects','00025')
  1281.                             writer(Project+'.proj','w','','data/projects','00025')
  1282.                             existing_found= False
  1283.  
  1284.  
  1285.             except Exception as e:
  1286.                 # existing_found=0
  1287.                 print('\033[1;31;40mCorrupted Data! Error code: 601\n\033[0m')
  1288.                 corruptions+=[e.__class__.__name__]
  1289.                 #print('error')
  1290.  
  1291.  
  1292.             #download_files(listx,state)
  1293.         else:
  1294.             # existing_found=0
  1295.             print('Insufiicient Data!\n')
  1296.             corruptions+=[0]
  1297.  
  1298.     if existing_found==False:
  1299.         if corruptions!=[]:
  1300.             if exists('data/projects/'+Project+'.proj'):
  1301.                 leach_logger("project||%s||%s||%s||%s"%(Project, Nsys.dt_(), str(corruptions),open('data/projects/'+Project+'.proj').read().replace('\n','>>')), user_name)
  1302.             else:
  1303.                 leach_logger("project||%s||%s||%s"%(Project, Nsys.dt_(),str(corruptions)), user_name)
  1304.         writer('errors.txt', 'a','','data/projects/'+Project,'00025') #reset error file
  1305.  
  1306.  
  1307.         all_list=set()
  1308.         sub_dirs=[]
  1309.         sub_links=[]
  1310.         sub_links2=[]
  1311.         #sub_links_filtered=[]
  1312.         file_types=set()
  1313.         link_startswith=''
  1314.         file_starts=''
  1315.         link_true=False
  1316.         main_link=input("\nEnter the link: ")
  1317.         leach_logger('%s||%s||m_link||%s)'%(Project, Nsys.dt_(),main_link), user_name)
  1318.         while link_true==False:
  1319.             if check_sp_links(main_link,'nh'):
  1320.                 break
  1321.             try:
  1322.                 page =requests.get(main_link, headers=header_())
  1323.                 link_true=True
  1324.             except (requests.exceptions.MissingSchema,requests.exceptions.ConnectionError):
  1325.                 main_link=input("\033[1;31;40mInvalid URL! \033[0m(possible cause: no internet or wrong link)\n\nPlease re-enter the link: ")
  1326.         if check_sp_links(main_link,'mangafreak'):
  1327.             print("mangafreak link detected!!")
  1328.             is_mangafreak=asker("Do you want to download manga images from this links?? (y/n)\n>> ")
  1329.             if is_mangafreak:
  1330.                 will_unzip=asker("\nThe download files are in zip format.\nDo you wish to Extract them?\n>> ")
  1331.  
  1332.                 if will_unzip:
  1333.                     sp_flags.append("dl unzip")
  1334.                     if asker("Shall i delete the downloaded zip files?\n>> "):
  1335.                         sp_flags.append("del dl zip")
  1336.                 link_startswith= mangafreak_link(main_link)
  1337.                 file_types='zip'
  1338.                 file_starts=''
  1339.  
  1340.                 leach_logger('project||%s||is_mangafreak||%s'%(Project,str(sp_flags)),user_name)
  1341.                 # sub_links=''
  1342.                 #sys_exit()
  1343.  
  1344.         if  check_sp_links(main_link,'nh'): #main_link.startswith('https://nhentai.net/g/') or main_link.startswith('https://nhentai.to/g/'):
  1345.             print("nhentai link detected!!")
  1346.             is_nh=asker("Do you want to download doujin images from this links?? (y/n)\n( ͡° ͜ʖ ͡°)\t")
  1347.             ####( io )
  1348.             if is_nh:
  1349.                 if os_name=='Windows':
  1350.                     play_yamatte_t.start()
  1351.  
  1352.                 link_startswith, title=nhantai_link(main_link)
  1353.                 #print(link_startswith,title)
  1354.                 if link_startswith==0 and title==0:
  1355.                     return 0
  1356.  
  1357.                 if title!=False and link_startswith!='':
  1358.                     sub_dirs.append(title.replace('/','-').replace('\\','-').replace('|','-').replace(':','-').replace('*','-').replace('"',"'").replace('>','-').replace('<','-'))
  1359.                     file_types=img
  1360.                     file_starts='https://nhentai'
  1361.                     leach_logger('project||%s||is_nh'%(Project),user_name)
  1362.             '''elif is_nh!='n':
  1363.                 print('invalid input!! the program will break in 3seconds')
  1364.                 time.sleep(3)
  1365.                 raise ValueError'''
  1366.  
  1367.  
  1368.  
  1369.         if link_startswith=='':
  1370.  
  1371.             print("Do you want to\n1. Download data from current link\n2. Download data from sub links of current link\n3. or Both Current and Sub links?")
  1372.             dimention= input("Enter the index of your choice (1/2/3): ")
  1373.             while dimention not in ['1','2','3']:
  1374.                 dimention = input("\033[1;31;40mInvalid input!\033[0m\nEnter 1 or 2 or 3:")
  1375.             leach_logger('%s||%s||dimention||%s)'%(Project, Nsys.dt_(),dimention), user_name)
  1376.  
  1377.             if dimention=='1' or dimention=='3':
  1378.                 sub_links2+=[main_link]
  1379.  
  1380.             if dimention=='2' or dimention=='3':
  1381.                 #page = requests.get(main_link, headers=header_())
  1382.                 #if not page:
  1383.                 #   print('\033[1;31;40mError code 605x\nConnection Failed, The program will break in 5 second\033[0m')
  1384.                 #   time.sleep(5)
  1385.                 #   leach_logger("XXXX Program crashed opening: '"+main_link+"' Error code 605 from main function collecting current page.", ush)
  1386.                 #   sys_exit()
  1387.                 #print(page.content)
  1388.                 #time.sleep(1000)
  1389.                 soup=bs(page.content, parser)
  1390.                 link_startswith=input("\n(optional but recomanded to be more precice):\n1. Sub-Links Starts With : ")
  1391.                 leach_logger('%s||%s||l_starts||%s)'%(Project, Nsys.dt_(),link_starts), user_name)
  1392.                 sub_links2+=list(set([sub_link.get('href').strip() for sub_link in soup.find_all('a')]))
  1393.                 if link_startswith=='':
  1394.                     link_startswith=main_link[:]
  1395.  
  1396.             file_types_i=input("\nEnter file formats (separate multiple by commas) *no need to add . in formats (ie: png, jpg,mp3) or just write the category (ie: image, music, video): ")
  1397.             if file_types_i=='image':
  1398.                 file_types=img
  1399.             else:
  1400.                 file_types= tuple(i.strip(i) for i in file_types_i.split(','))
  1401.             leach_logger('%s||%s||f_types||%s)'%(Project, Nsys.dt_(),str(file_types)), user_name)
  1402.  
  1403.             file_starts=input("\nFile Links Starts With (if known or need to be specified): ")
  1404.             leach_logger('%s||%s||f_starts||%s)'%(Project, Nsys.dt_(),file_starts), user_name)
  1405.             # project_path=Project[:]
  1406.  
  1407.             #if start[-1'/'): start+='/'
  1408.             #if start.startswith(): start=start[1:]
  1409.                 #sub_dirs=[]
  1410.             #len_sub_links=str(len(sub_links))
  1411.             # count=0
  1412.             print('\n')
  1413.             homepage_searcher=re_compile('(https?://[^/]*)')
  1414.             link_startswith_re=re_compile('^'+link_startswith)
  1415.  
  1416.             #leach_logger("++%s'+'%s'+%s'+'%s'++"%(main_link, link_startswith,str(file_types),file_starts), user_name)
  1417.  
  1418.             print("Checking links...")
  1419.             for i in sub_links2:
  1420.  
  1421.  
  1422.                 #sys.stdout.flush()
  1423.                 #print(link)
  1424.                 # print(i)
  1425.                 if  patrial_do_all==0 and i.startswith('/'):
  1426.                     print("Partial link detected - ",main_link,"\nSearching for home page.")
  1427.                     #print(start)
  1428.                     homepage =homepage_searcher.search(link_startswith)
  1429.                     #print(homepage)
  1430.                     if homepage!=None:
  1431.                         print("Home page detected: ", homepage.group())
  1432.                         is_homepage= input("\nIs this the homepage? \n(y for yes\nn for no\na for all)\n")
  1433.                         if is_homepage=="a":
  1434.                             patrial_do_all=1
  1435.                             is_homepage='y'
  1436.                         if is_homepage=='y':
  1437.                             homepage=homepage.group()
  1438.                         elif is_homepage=='n':
  1439.                             homepage= input("\nEnter the home page: ")
  1440.                             io2=input('\nIs it for all other links?(y/n)')
  1441.                             if io2=='y':
  1442.                                 patrial_do_all=1
  1443.                             elif io2!='n':
  1444.                                 print("Invalid input!")
  1445.                                 time.sleep(5)
  1446.                                 sys_exit()
  1447.                         else:
  1448.                             print("Invalid input!")
  1449.                             time.sleep(5)
  1450.                             sys_exit()
  1451.                     else:
  1452.                         print("Homepage not found!")
  1453.                         homepage= input("\nEnter the home page: ")
  1454.                         io2=input('Is it for all other links?(y/n)')
  1455.                         if io2=='y':
  1456.                             patrial_do_all=1
  1457.                         elif io2!='n':
  1458.                             print("Invalid input!")
  1459.                             time.sleep(5)
  1460.                             sys_exit()
  1461.                     i=homepage+i
  1462.  
  1463.  
  1464.                 #print(link)
  1465.                 #print(sub_dirs)ta
  1466.                 if link_startswith_re.search(i)!=None:
  1467.                     sub_links.append(i)
  1468.                     #print('\t'+i)
  1469.                 # sub_links=sub_links2[:]
  1470.             del sub_links2
  1471.  
  1472.         if sub_dirs==[]:
  1473.             sub_dirs=sub_links[:]
  1474.             len_sub_links= len(sub_links)
  1475.             print('\n')
  1476.             if len_sub_links<4:
  1477.                 for n in range(len_sub_links):
  1478.                     list_writer(sub_links[n],file_types, file_starts,n)
  1479.                     if sub_dirs[n][-1]=='/':
  1480.                         sub_dirs[n]=sub_dirs[n][:-1]
  1481.                     sub_dirs[n]=sub_dirs[n].split('/')[-1]
  1482.                     delete_last_line()
  1483.                     print('Indexed ['+ str(n+1) + '/'+str(len_sub_links)+'] '+sub_links[n])
  1484.  
  1485.             else:
  1486.                 sub_range=range(len_sub_links)
  1487.                 indx1= Process(target=list_writer, args=(sub_links,file_types, file_starts,sub_range[::3]))
  1488.                 indx2= Process(target=list_writer, args=(sub_links,file_types, file_starts,sub_range[1::3]))
  1489.                 indx3= Process(target=list_writer, args=(sub_links,file_types, file_starts,sub_range[2::3]))
  1490.  
  1491.                 try:
  1492.  
  1493.                     indx1.start()
  1494.                     indx2.start()
  1495.                     indx3.start()
  1496.  
  1497.                     indx1.join()
  1498.                     indx2.join()
  1499.                     indx3.join()
  1500.                 except:
  1501.                     print("\033[1;31;40mcode: Error 607\n The program will break in 5 seconds\033[0m")
  1502.                     leach_logger("XXXX Program crashed running: 'indx threads' Error code 607 from main function calling list_writer with tthreads. Error", ush)
  1503.                     time.sleep(5)
  1504.                     sys_exit()
  1505.  
  1506.  
  1507.  
  1508.  
  1509.         all_list=list(all_list)
  1510.  
  1511.         writer('projects.db','a',Project+'\n','data','00025')
  1512.  
  1513.         writer(Project+'.list','w',str(all_list),'data/projects','00025')
  1514.         writer(Project+'.proj','w',main_link+'\n','data/projects','00025')
  1515.         writer(Project+'.proj','a',link_startswith+'\n','data/projects','00025')
  1516.         writer(Project+'.proj','a',str(file_types)+'\n','data/projects','00025')
  1517.         writer(Project+'.proj','a',file_starts+'\n','data/projects','00025')
  1518.         writer(Project+'.proj','a',str(sub_dirs)+'\n','data/projects','00025')
  1519.         writer(Project+'.proj','a',str(sp_flags)+'\n','data/projects','00025')
  1520.         writer(Project+'.proj','a',str('"%s"'%sp_extension)+'\n','data/projects','00025')
  1521.     print('\n\n')
  1522.     total=len(all_list)
  1523.  
  1524.  
  1525.     if exists('data/projects/'+project_dir+'/errors.txt'):
  1526.         errors=len(open('data/projects/'+project_dir+'/errors.txt').readlines())
  1527.     else:
  1528.         errors=0
  1529.  
  1530.     #print(all_list)
  1531.     all_list_r=list(range(total))
  1532.     #if 'dl unzip' in sp_flags:print(100**100)
  1533.     t11= Process(target=distribute, args=(all_list_r[::10],1))
  1534.     t2= Process(target=distribute, args=(all_list_r[1::10],2))
  1535.     t3= Process(target=distribute, args=(all_list_r[2::10],3))
  1536.     t4= Process(target=distribute, args=(all_list_r[3::10],4))
  1537.     t5= Process(target=distribute, args=(all_list_r[4::10],5))
  1538.     t6= Process(target=distribute, args=(all_list_r[5::10],6))
  1539.     t7= Process(target=distribute, args=(all_list_r[6::10],7))
  1540.     t8= Process(target=distribute, args=(all_list_r[7::10],8))
  1541.     t9= Process(target=distribute, args=(all_list_r[8::10],9))
  1542.     t10= Process(target=distribute, args=(all_list_r[9::10],10))
  1543.  
  1544.     ##sleep(.5)
  1545.  
  1546.     t11.start()
  1547.     t2.start()
  1548.     t3.start()
  1549.     t4.start()
  1550.     t5.start()
  1551.     t6.start()
  1552.     t7.start()
  1553.     t8.start()
  1554.     t9.start()
  1555.     t10.start()
  1556.  
  1557.     t11.join()
  1558.     t2.join()
  1559.     t3.join()
  1560.     t4.join()
  1561.     t5.join()
  1562.     t6.join()
  1563.     t7.join()
  1564.     t8.join()
  1565.     t9.join()
  1566.     t10.join()
  1567.  
  1568.  
  1569.     leach_logger("Project||"+Project+"||finished @||"+Nsys.compressed_dt()+'||Total files||'+str(total)+'||total errors||'+str(errors), ush)
  1570.     if errors>0:
  1571.         if exists('data/projects/'+Project+'/errors.txt'):
  1572.             with open('data/projects/'+Project+'/errors.txt') as f:
  1573.                 err_file=f.read().strip().split('\n')
  1574.             errs= [list(x) for x in set([eval(i)[:2] for i in err_file])]
  1575.  
  1576.             distribute(errs,11, True)
  1577.         else:
  1578.             print("Warning: Error file not found!\nPossible cause: Data corruption")
  1579.     leach_logger("Project||"+Project+"||finished @||"+Nsys.compressed_dt()+'||Total files||'+str(total)+'||total errors||'+str(errors), ush)
  1580.     if errors == 0:
  1581.         writer(Project+'.proj','a','True','data/projects','00025')
  1582.     else: print("Please retry some time later to get higher chances to download some or all %d missing file/s"%errors)
  1583.  
  1584.  
  1585.  
  1586. class DemoApp(MDApp):
  1587.  
  1588.     def build(self):
  1589.         global user_net_ip
  1590.         self.step=0
  1591.         self.sm = ScreenManager()
  1592.         self.__temp= [None, None]  # to store temp data
  1593.        
  1594.  
  1595.        
  1596.         self.__temp = _connect_net() # checks net and assigns the __temp var data
  1597.         ########################################################################
  1598.         ############ need to switch to False in the below line ##################
  1599.         if self.__temp[0]== False: # if there is no internet
  1600.             self.sm.add_widget(blank(name="blank_Kv"))
  1601.             self.sm.add_widget(login_kv(name="login_Kv"))
  1602.         else:
  1603.             self.sm.add_widget(login_kv(name="login_Kv"))
  1604.        
  1605.         # login_Kv will connect it to other funtions through login_btn
  1606.         return self.sm
  1607.  
  1608.     ################ Basics || START ################
  1609.     def close_app(self, obj=None):
  1610.         """funtion to close the app"""
  1611.         sys_exit()
  1612.    
  1613.     dialog=None # just to make sure this variable exists while defining some funtions so that no error occurs like var is not declared
  1614.  
  1615.     def close_dialog(self, arg=None):
  1616.         """close self.dialog func"""
  1617.         self.dialog.dismiss()
  1618.  
  1619.     ################ Basics || ENDS ################
  1620.  
  1621.     ################ Net check @ start $blank || START ################
  1622.    
  1623.     def check_net_at_start(self, obj=None):
  1624.         """will check if internet is available or not at startup
  1625.         and act according to that"""
  1626.         try:
  1627.             """Checks if this dialog is already open and then closes it"""
  1628.             self.failed_2_conn_at_start.dismiss()
  1629.         except:
  1630.             pass
  1631.         self.__temp = _connect_net()
  1632.         self.failed_2_conn_at_start = MDDialog(title="No luck...\nPlease retry or exit\nError code: "+ str(self.__temp[1]), buttons=[MDFlatButton(text='Retry', on_release=self.check_net_at_start), MDFlatButton(text='Exit', on_release=self.close_app)],
  1633.                                 size_hint=(0.8, 0.8))
  1634.         if self.__temp[0]==False:
  1635.             self.failed_2_conn_at_start.open()
  1636.         else:
  1637.             self.sm.remove_widget(self.sm.screens[0])
  1638.             self.sm.current= "login_Kv"
  1639.     ################ Net check @ 0 $blank || ENDS ################
  1640.  
  1641.     ################ Log in @ 1 $login_kv || START ################
  1642.     def run_god_mode(self, arg=None):
  1643.         """ Runs god_mode funcition from asssets to download required assets based on os and database update"""
  1644.         self.box= god_mode()
  1645.         #print(self.box)
  1646.         self.log_in_check()
  1647.  
  1648.     def open_connecting_dialog(self, args=None):
  1649.         try:
  1650.             self.close_dialog()
  1651.         except:
  1652.             pass
  1653.         self.connecting_dialog = MDDialog(title="Connecting...\nPlease wait a sec!", on_open=self.run_god_mode,
  1654.                                 size_hint=(0.8, 0.8))
  1655.         # self.connecting_dialog.
  1656.  
  1657.         self.connecting_dialog.open()
  1658.  
  1659.     def close_connecting_dialog(self, arg=None):
  1660.         self.connecting_dialog.dismiss()
  1661.  
  1662.     def close_failed_2_conn_at_start(self, arg=None):
  1663.         """closes no internet error and switches screen to login"""
  1664.         self.failed_2_conn_at_start.dismiss()
  1665.         self.sm.current= "login_Kv"
  1666.    
  1667.     def login_btn(self, _username):
  1668.         self._username= _username
  1669.         if _username=='':
  1670.             self.dialog = MDDialog(title="Please enter your user name",text="You can't leave Username field empty",
  1671.                             size_hint=(0.8, 0.8),
  1672.                             buttons=[MDFlatButton(text='Close', on_release=self.close_dialog)])
  1673.             self.dialog.open()
  1674.         elif self.step==0:
  1675.             # self.open_connecting_dialog()
  1676.             self.open_connecting_dialog()
  1677.         else:
  1678.             self.log_in_check()
  1679.  
  1680.            
  1681.     def log_in_check(self):
  1682.         """checks and warns if internet is available and then the _username is valid or not and responese accordingly"""
  1683.        
  1684.         if '605x4' in self.box or '00017x-1' in self.box:
  1685.             time.sleep(0.5)
  1686.             self.close_connecting_dialog()
  1687.             self.dialog = MDDialog(title="Failed to connect to the internet!\nError code %s"%self.box[0], size_hint=(0.8, 0.8),
  1688.                             buttons=[MDFlatButton(text='Retry', on_release=self.open_connecting_dialog),
  1689.                             MDFlatButton(text='Close', on_release=self.close_dialog)])
  1690.             self.dialog.open()
  1691.  
  1692.         else:
  1693.             self.step =1
  1694.        
  1695.         if self.step==1:
  1696.             self.close_connecting_dialog()
  1697.            
  1698.             box= log_in(self._username)
  1699.             sound=False
  1700.             if box=='INVALID':
  1701.                 if os_name=="Windows":
  1702.                     ex=mplay4.ex_vol
  1703.                     mplay4.set_win_vol(60)
  1704.  
  1705.                 sound = SoundLoader.load('data/.temp/who_r_u.mp3')
  1706.                 sound.play()
  1707.                 self.dialog = MDDialog(title="Username not found!\nPlease retry",
  1708.                                 size_hint=(0.8, 0.8),
  1709.                                 buttons=[MDFlatButton(text='Close', on_release=self.close_dialog)])
  1710.                 self.dialog.open()
  1711.                 if os_name=="Windows":
  1712.                     mplay4.set_win_vol(ex)
  1713.             else:
  1714.                 if sound!=False: sound.unload()
  1715.                 self.sm.add_widget (welcome_kv(name="welcome_Kv"))
  1716.                 self.sm.current= "welcome_Kv"
  1717.                 self.sm.remove_widget(self.sm.screens[0])
  1718.                 if float(_VERSION) < float(_latest_version):
  1719.                     self.dialog= MDDialog(title="Version: %s available"%_latest_version, size_hint=(0.8, 0.8), text="Do you want to update?",
  1720.                             buttons=[MDFlatButton(text='Yes', on_release=self.open_updating_dialog),
  1721.                             MDFlatButton(text='Not yet', on_release=self.close_dialog)])
  1722.  
  1723.  
  1724.                 #print(0)
  1725.                 #load_asset2()
  1726.     ################ Log in @ 1 $login_kv || ENDS ################
  1727.        
  1728.     ################ welcome @ 2 $welcome_kv || START ################
  1729.     def lets_go_btn(self):
  1730.         self.sm.add_widget(download_page(name= "download_Kv"))
  1731.         self.sm.current= "download_Kv"
  1732.         self.sm.remove_widget(self.sm.screens[0])
  1733.  
  1734.     def open_updating_dialog(self, obj= None):
  1735.         self.close_dialog()
  1736.         # do update stuffs here
  1737.     ################ welcome @ 2 $welcome_kv || ENDS ################
  1738.  
  1739.     ################ Proj name @ 2 $download_page || STARTS ################
  1740.     def check_project(self, proj_name):
  1741.         if proj_name=="":
  1742.             self.dialog = MDDialog(title="Please enter a project name",
  1743.                             text="You can't leave this field empty",
  1744.                             size_hint=(0.8, 0.8),
  1745.                             buttons=[MDFlatButton(text='Close', on_release=self.close_dialog)])
  1746.             self.dialog.open()
  1747.         elif any(x in proj_name for x in ['"', '\\', '/', '?', '*', '<', '>', '|']):
  1748.             self.dialog = MDDialog(title="Invalid Project name",
  1749.                             text="Sorry project name can't have \\ / * \" ? < > | charecters",
  1750.                             size_hint=(0.8, 0.8),
  1751.                             buttons=[MDFlatButton(text='Close', on_release=self.close_dialog)])
  1752.             self.dialog.open()
  1753.         else:
  1754.             self.check_project1(proj_name)
  1755.     def check_project1(self, Proj_name):
  1756.         _init_()
  1757.         global Project, all_list, total, existing_found, sub_dirs, patrial_do_all, sp_flags, errors, sp_extension, overwrite_bool, project_dir, sequence, main_link
  1758.         Project = Proj_name[:]
  1759.         existing_found=False
  1760.         dl_done=False
  1761.         sequence=True
  1762.         corruptions=[]
  1763.        
  1764.         project_dir=Project[:] #.replace('/','-').replace('\\','-').replace('|','-').replace(':','-').replace('*','-').replace('"',"'").replace('>','-').replace('<','-').replace('?','-')
  1765.         print(project_dir)
  1766.         leach_logger("project||%s||open||%s"%(Project,Nsys.compressed_dt()),user_name)
  1767.         if Project in open('data/projects.db').read().split('\n'):
  1768.             print('Existing Project name found!')
  1769.             proj_good=False
  1770.             list_good=False
  1771.  
  1772.             if exists('Data/leach_projects/'+project_dir+'.proj') and exists('Data/leach_projects/'+project_dir+'.list'):
  1773.                 proj_good= True
  1774.                 try:
  1775.                     with open('Data/leach_projects/'+project_dir+'.proj') as f:
  1776.                         print('db found')
  1777.  
  1778.                         existing_data=f.read().strip().split('\n')
  1779.                         try:
  1780.                             main_link=existing_data[0]
  1781.                         except:
  1782.                             corruptions+=[1]
  1783.                             print('\033[1;31;40mCorrupted Data! Error code: 601x1\033[0m')
  1784.                             proj_good=False
  1785.                            
  1786.                         if proj_good:
  1787.                             try:
  1788.                                 link_startswith=existing_data[1]
  1789.                             except:
  1790.                                 proj_good= False
  1791.                                 print('\033[1;31;40mCorrupted Data! Error code: 601x2\033[0m')
  1792.                                 corruptions+=[2]
  1793.  
  1794.                         if proj_good:
  1795.                             try:
  1796.                                 file_types=eval(existing_data[2])
  1797.                             except:
  1798.                                 proj_good= False
  1799.                                 print('\033[1;31;40mCorrupted Data! Error code: 601x3\033[0m')
  1800.                                 corruptions+=[3]
  1801.  
  1802.                         if proj_good:
  1803.                             try:
  1804.                                 file_starts=existing_data[3]
  1805.                             except:
  1806.                                 proj_good= False
  1807.                                 print('\033[1;31;40mCorrupted Data! Error code: 601x4\033[0m')
  1808.                                 corruptions+=[4]
  1809.  
  1810.                         if proj_good:
  1811.                             try:
  1812.                                 sub_dirs=eval(existing_data[4]) #sub directory list
  1813.                             except:
  1814.                                 proj_good= False
  1815.                                 print('\033[1;31;40mCorrupted Data! Error code: 601x5\033[0m')
  1816.                                 corruptions+=[2]
  1817.                             try:  #added in v5.0 may not be in older files
  1818.                                 sp_flags=eval(existing_data[5])
  1819.                                 sp_extension=eval(existing_data[6])
  1820.                                 overwrite_bool=eval(existing_data[7])
  1821.                             except IndexError: pass
  1822.                         if proj_good:
  1823.                             try:  #added in v5.1 may not be in older files
  1824.                                 dl_done=eval(existing_data[8])
  1825.                             except IndexError: pass
  1826.  
  1827.  
  1828.  
  1829.                     with open('Data/leach_projects/'+project_dir+'.list') as f:
  1830.                         try:
  1831.                             file=f.read()
  1832.                             #print(f"'{file}'")
  1833.                             if file.strip()=='': raise ValueError
  1834.                             all_list= eval(str(file))
  1835.                             print('list found')
  1836.                             list_good= True
  1837.                         except:
  1838.                             list_good= False
  1839.                             print('\033[1;31;40mCorrupted Data! Error code: 601x6\033[0m')
  1840.                             corruptions+=[3]
  1841.  
  1842.                
  1843.                     if proj_good and list_good:
  1844.                         if dl_done:
  1845.                             self.dialog = MDDialog(title="The project was finished",
  1846.                                                     text= "Do you want to get updates from previous project link\nOr create a fresh project with same name (*scrapped data won't be deleted)",
  1847.                                                     size_hint=(0.8, 0.8),
  1848.                                                     buttons=[
  1849.                                                 MDRaisedButton(text='Back', on_release=self.close_dialog),
  1850.                                                 MDFlatButton(text='Update', on_release=self.project_update),
  1851.                                                 MDFlatButton(text='Create new', on_release= partial(self.project_flush, True))])
  1852.                             self.dialog.open()
  1853.  
  1854.                             #print('It seems  the old prject download was complete!!')
  1855.                             #if asker('Do you want to get updated data from the project link?\nIf you want make a fresh start with that project name type \033[1;43mno\033[0m\n>> ')==False:#'Do you want make a fresh start with that project name??\n\033[1;33mWarning!\033[0m last project data will be erased\n(downloaded files will be safe, unless the program replaces the files with new ones)\n\033[32m>> \033[0m'):
  1856.                             #   writer(project_dir+'.list','w','','Data/leach_projects','00025')
  1857.                             #   writer(project_dir+'.proj','w','','Data/leach_projects','00025')
  1858.                             #   existing_found= False
  1859.                             #   leach_logger('project||%s||%s||fresh start||was done'%(Project,Nsys.dt_()),user_name)
  1860.                             #else:
  1861.                             #   #print("Okay! Enter a new project name in the next line.")
  1862.                             #   existing_found= True
  1863.                             #   overwrite_bool=False
  1864.                                 #remove('Data/leach_projects/'+project_dir+'/')
  1865.                         else:
  1866.                             self.dialog = MDDialog(title="Unfinished project found!",
  1867.                                                     text= "Continue from prevous project\nOr create a fresh project with same name (*scrapped data won't be deleted)",
  1868.                                                     size_hint=(0.8, 0.8),
  1869.                                                     buttons=[
  1870.                                                 MDRaisedButton(text='Resume', on_release=self.project_update),
  1871.                                                 MDFlatButton(text='Create new', on_release=partial(self.project_flush, False)),
  1872.                                                 MDFlatButton(text='Back', on_release=self.close_dialog)])
  1873.                             self.dialog.open()
  1874.                             #if asker("Do you want to resume the Project '%s'?\nyes/y to resume\nno/n to Start fresh (\033[1;33mwarning! last project data will be erased \033[0m(downloaded files will be safe, unless the program replaces the files with new ones)\n\033[32m>> \033[0m"%Project):
  1875.                             #   print('============ Realoaded =============')
  1876.                             #   leach_logger('project||%s||%s||resumed||not done'%(Project,Nsys.dt_()),user_name)
  1877.                             #   existing_found= True
  1878.                             #else:
  1879.                             #   leach_logger('%s||%s||fresh start||not done'%(Project,Nsys.dt_()),user_name)
  1880.                             #   #clear file data
  1881.                             #   writer(project_dir+'.list','w','','Data/leach_projects','00025')
  1882.                             #   writer(project_dir+'.proj','w','','Data/leach_projects','00025')
  1883.                             #   existing_found= False
  1884.  
  1885.  
  1886.                 except Exception as e:
  1887.                     # existing_found=0
  1888.                     print('\033[1;31;40mCorrupted Data! Error code: 601\n\033[0m')
  1889.                     corruptions+=[e.__class__.__name__]
  1890.                     raise e
  1891.  
  1892.             else:
  1893.                 # existing_found=0
  1894.                 print('Insufiicient Data!\n')
  1895.                 corruptions+=[0]
  1896.  
  1897.             if corruptions!=[] and corruptions!=[0]:
  1898.                 self.dialog = MDDialog(title="Failed to load existing project",
  1899.                             text="A project with same name was found in the database, however the data was broken. So you need to start over\nError code: P"+str(corruptions),
  1900.                             size_hint=(0.8, 0.8),
  1901.                             buttons=[MDFlatButton(text='Continue', on_release=self.close_dialog)])
  1902.                 self.dialog.open()
  1903.                 if exists('Data/leach_projects/'+project_dir+'.proj'):
  1904.                     leach_logger("project||%s||%s||%s||%s"%(Project, Nsys.dt_(), str(corruptions),open('Data/leach_projects/'+project_dir+'.proj').read().replace('\n','>>')), user_name)
  1905.                 else:
  1906.                     leach_logger("project||%s||%s||%s"%(Project, Nsys.dt_(),str(corruptions)), user_name)
  1907.  
  1908.  
  1909.     def project_update(self, obj = None):
  1910.         global existing_found, overwrite_bool
  1911.         existing_found= True
  1912.         overwrite_bool=False
  1913.         if isdir('./Data/leach_projects/'+project_dir):
  1914.             rmdir('./Data/leach_projects/'+project_dir)
  1915.         else:
  1916.             pass
  1917.        
  1918.     def project_flush(self, done, obj =None):
  1919.         global existing_found
  1920.         remove('Data/leach_projects'+project_dir+'.list')
  1921.         remove('Data/leach_projects'+project_dir+'.proj')
  1922.         try:
  1923.             rmdir('Data/leach_projects/'+project_dir+'/')
  1924.         except FileNotFoundError:
  1925.             pass
  1926.         existing_found= False
  1927.         leach_logger('project||%s||%s||fresh start||%sdone'%(Project,Nsys.dt_(),("" if done else "not ")),user_name)
  1928.  
  1929.     ##########
  1930.  
  1931. class Test(MDApp):
  1932.  
  1933.     def build(self):
  1934.         self.theme_cls.primary_palette = "Gray"
  1935.         return Builder.load_string(
  1936.             '''
  1937. BoxLayout:
  1938.     orientation:'vertical'
  1939.  
  1940.     MDToolbar:
  1941.         title: 'Bottom navigation'
  1942.         md_bg_color: .2, .2, .2, 1
  1943.         specific_text_color: 1, 1, 1, 1
  1944.  
  1945.     MDBottomNavigation:
  1946.         panel_color: .2, .2, .2, 1
  1947.  
  1948.         MDBottomNavigationItem:
  1949.             name: 'screen 1'
  1950.             text: 'Python'
  1951.             icon: 'language-python'
  1952.  
  1953.             MDLabel:
  1954.                 text: 'Python'
  1955.                 halign: 'center'
  1956.  
  1957.         MDBottomNavigationItem:
  1958.             name: 'screen 2'
  1959.             text: 'C++'
  1960.             icon: 'language-cpp'
  1961.  
  1962.             MDLabel:
  1963.                 text: 'I programming of C++'
  1964.                 halign: 'center'
  1965.  
  1966.         MDBottomNavigationItem:
  1967.             name: 'screen 3'
  1968.             text: 'JS'
  1969.             icon: 'language-javascript'
  1970.  
  1971.             MDLabel:
  1972.                 text: 'JS'
  1973.                 halign: 'center'
  1974. '''
  1975.         )
  1976.  
  1977.  
  1978. #ld_assets.join()
  1979.  
  1980. DemoApp().run()
  1981.  
Add Comment
Please, Sign In to add comment