This is a personal projects that aims to be the perfect online student. It auromatically joins zoom meetings, records classes and mirrors a pre-recorded video to a virtual loopback camera. Keep in mind that this is only meant to work on linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.3 KiB

4 years ago
  1. import requests
  2. from html.parser import HTMLParser
  3. import sys
  4. import json
  5. import re
  6. import datetime
  7. from urllib3.exceptions import InsecureRequestWarning
  8. import selenium
  9. from selenium import webdriver
  10. from selenium.webdriver.common.keys import Keys
  11. requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
  12. now = datetime.datetime.now()
  13. proxies = {"http": "http://127.0.0.1:8080", "https": "http://127.0.0.1:8080"}
  14. headers = {
  15. "Host":"portal.tedankara.k12.tr",
  16. "User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
  17. "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
  18. "Accept-Language":"en-US,en;q=0.5",
  19. "Accept-Encoding":"gzip, deflate",
  20. "Content-Type":"application/x-www-form-urlencoded",
  21. "Origin":"https://portal.tedankara.k12.tr",
  22. "Connection":"close",
  23. "Referer":"https://portal.tedankara.k12.tr/login",
  24. "DNT":"1"
  25. }
  26. class JDParser(HTMLParser):
  27. def handle_starttag(self, tag, attrs):
  28. self.attributes = {}
  29. for attr in attrs:
  30. self.attributes[attr[0]] = attr[1]
  31. def get_meetings(uname, passwd):
  32. url = "https://portal.tedankara.k12.tr/login"
  33. r = requests.get(url,verify=False)
  34. cookies = r.cookies
  35. content = r.content
  36. lines = content.splitlines()
  37. line = list(filter(lambda x: b'_token' in x, lines))[0].decode("utf-8")
  38. parser = JDParser()
  39. parser.feed(line)
  40. parser.feed(line)
  41. parser.close()
  42. _token = parser.attributes["content"]
  43. data = "_token={}&kimlikno={}&sifre={}".format(_token,uname,passwd)
  44. r = requests.post(url,data=data,cookies=cookies,headers=headers,verify=False)
  45. cookies = r.cookies
  46. r = requests.get("https://portal.tedankara.k12.tr/veli/zoom",cookies=cookies,verify=False, headers=headers)
  47. content = r.json()
  48. data = {"current_day": content["current_day"],
  49. "current_class": content["current_class"],
  50. "current_student": content["current_student"]}
  51. headers2 = {"Host":"portal.tedankara.k12.tr",
  52. "User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
  53. "Accept":"application/json, text/plain, */*",
  54. "Accept-Language":"en-US,en;q=0.5",
  55. "Accept-Encoding":"gzip, deflate",
  56. "X-Requested-With":"XMLHttpRequest",
  57. "Content-Type":"application/json;charset=utf-8",
  58. "Origin":"https://portal.tedankara.k12.tr",
  59. "Connection":"close",
  60. "Referer":"https://portal.tedankara.k12.tr/",
  61. "DNT":"1"}
  62. headers2["X-XSRF-TOKEN"] = r.cookies["XSRF-TOKEN"]
  63. headers2["X-CSRF-TOKEN"] = _token
  64. r = requests.post("https://portal.tedankara.k12.tr/veli/zoom",cookies=r.cookies,verify=False, json=data, headers=headers2)
  65. classes = r.json()
  66. options = webdriver.ChromeOptions()
  67. options.add_argument('--headless')
  68. try:
  69. client = webdriver.Chrome(options=options)
  70. except:
  71. pass
  72. meetings = []
  73. for i in classes["meetings"]:
  74. data = "_token={}&student={}&id={}".format(_token, content["students"][0],i["meeting_id"])
  75. r = requests.post("https://portal.tedankara.k12.tr/veli/yoklama",allow_redirects=False, cookies=cookies,verify=False, data=data, headers=headers)
  76. if "Location" not in r.headers:
  77. continue
  78. invitation = r.headers["Location"]
  79. client.get(invitation)
  80. meeting_url = client.find_element_by_css_selector("a[launch='']").get_attribute("href")
  81. meetings.append({"meeting_url": meeting_url,
  82. "class": i["topic"],
  83. "time":i["meeting_time"]})
  84. return meetings